示例#1
0
def UPLOAD(update, context):

    url = update.message.text
    url = url.split()[-1]
    sent_message = context.bot.send_message(chat_id=update.message.chat_id,
                                            text=TEXT.PROCESSING)

    ID = update.message.chat_id
    ID = str(ID)
    os.path.isfile(ID)
    if os.path.isfile(ID):
        # Openlaod Stuffs

        # I will Add This Later
        if "openload" in url or "oload" in url:

            DownloadStatus = False
            sent_message.edit_text("Openload No longer avalible")
            return

            # Here is DropBox Stuffs
        elif 'dropbox.com' in url:

            url = DPBOX(url)
            filename = url.split("/")[-1]
            print("Dropbox link Downloading Started : {}".format(
                url.split("/")[-1]))
            sent_message.edit_text(TEXT.DP_DOWNLOAD)
            # filename = wget.download(url)
            filename = wget_dl(str(url))
            print("Downloading Complete : {}".format(filename))
            sent_message.edit_text(TEXT.DOWN_COMPLETE)
            DownloadStatus = True
        # Here IS Mega Links stuffs
        elif 'mega.nz' in url:

            try:
                print("Downlaoding Started")
                sent_message.edit_text(TEXT.DOWN_MEGA)
                m = Mega.from_credentials(TEXT.MEGA_EMAIL, TEXT.MEGA_PASSWORD)
                filename = m.download_from_url(url)
                print("Downloading Complete Mega :", filename)
                sent_message.edit_text(TEXT.DOWN_COMPLETE)

                DownloadStatus = True
            except Exception as e:
                print("Mega Downloding Error :", e)
                sent_message.edit_text("Mega Downloading Error !!")

        else:
            try:
                filename = url.split("/")[-1]

                print("Downloading Started : {}".format(url.split("/")[-1]))
                sent_message.edit_text(TEXT.DOWNLOAD)
                # filename = wget.download(url)
                filename = wget_dl(str(url))
                print("Downloading Complete : {}".format(filename))
                sent_message.edit_text(TEXT.DOWN_COMPLETE)
                DownloadStatus = True

            except Exception as e:
                # switch To second download(SmartDl Downloader) `You can activate it throungh TEXT file`
                if TEXT.DOWN_TWO:
                    print(TEXT.DOWN_TWO)
                    try:
                        sent_message.edit_text(
                            "Downloader 1 Error:{} \n\n Downloader 2 :Downloading Started..."
                            .format(e))

                        obj = SmartDL(url)
                        obj.start()
                        filename = obj.get_dest()
                        DownloadStatus = True
                    except Exception as e:
                        print(e)
                        sent_message.edit_text(
                            "Downloading error :{}".format(e))
                        DownloadStatus = False
                else:
                    print(e)
                    sent_message.edit_text("Downloading error :{}".format(e))
                    DownloadStatus = False

            # Checking Error Filename
        if "error" in filename:
            # print(filename)
            # print(filename[0],filename[-1],filename[1])
            sent_message.edit_text("Downloading Error !! ")
            os.remove(filename[-1])

            ##########Uploading part  ###################
        try:

            if DownloadStatus:
                sent_message.edit_text(TEXT.UPLOADING)

                SIZE = (os.path.getsize(filename)) / 1048576
                SIZE = round(SIZE)
                FILENAME = filename.split("/")[-1]
                try:
                    FILELINK = upload(filename, update, context,
                                      TEXT.drive_folder_name)
                except Exception as e:
                    print("error Code : UPX11", e)
                    sent_message.edit_text("Uploading fail :{}".format(e))

                sent_message.edit_text(TEXT.DOWNLOAD_URL.format(
                    FILENAME, SIZE, FILELINK),
                                       parse_mode=ParseMode.HTML)
                print(filename)
                try:
                    os.remove(filename)
                except Exception as e:
                    print(e)
        except Exception as e:
            print("Error code UXP12", e)
            if DownloadStatus:
                sent_message.edit_text("Uploading fail : {}".format(e))
                try:
                    os.remove(filename)
                except Exception as e:
                    print("Error code UXP13", e)
            else:
                sent_message.edit_text("Uploading fail :", e)

    else:
        context.bot.send_message(chat_id=update.message.chat_id,
                                 text=TEXT.NOT_AUTH)
def filedl(update, context):
    docname = update.message.text
    docname = docname.split()[-1]
    print('update.message.text: ', update.message.text)
    print("Document name found: ", docname)
    with open(docname, 'r') as f:
        a = f.readlines()
    for movie in a:
        url = movie.strip()
        sent_message = context.bot.send_message(
            chat_id=update.message.chat_id, text=TEXT.PROCESSING)
        download_time = 'NA'
        ID = update.message.chat_id
        ID = str(ID)
        os.path.isfile(ID)
        if os.path.isfile(ID):
            
            try:
                filename = url.split("/")[-1]

                print("Downloading Started : {}".format(url.split("/")[-1]))
                sent_message.edit_text(TEXT.DOWNLOAD)
                    # filename = wget.download(url)
                #--------------------------------------------------

                filename, download_time = smart_dl(url, sent_message)
                if not filename:
                    raise ValueError('Download failed!! \n Switching to method 2')

                #--------------------------------------------------
                print("Downloading Complete : {}".format(filename))
                sent_message.edit_text(TEXT.DOWN_COMPLETE)
                DownloadStatus = True

            except Exception as e:
                    # switch To second download(SmartDl Downloader) `You can activate it throungh TEXT file`
                print("***********SMARTDL ERROR*********\n", e)
                if TEXT.DOWN_TWO:
                    print(TEXT.DOWN_TWO)
                    try:
                        sent_message.edit_text(
                            "Downloader 1 Error:{} \n\n Downloader 2 :Downloading Started...".format(e))
    ###-------> Download backup fn
                        filename = wget_dl(str(url))

                        DownloadStatus = True
                    except Exception as e:
                        print(e)
                        sent_message.edit_text(
                            "Downloading error :{}".format(e))
                        DownloadStatus = False
                else:
                    print(e)
                    sent_message.edit_text("Downloading error :{}".format(e))
                    DownloadStatus = False

                # Checking Error Filename
            if "error" in filename:
                    # print(filename)
                    # print(filename[0],filename[-1],filename[1])
                sent_message.edit_text("Downloading Error !! ")
                os.remove(filename[-1])
    #------_> UPLOAD FN

            ##########Uploading part  ###################
            try:

                if DownloadStatus:

                    SIZE = (os.path.getsize(filename))/1048576
                    SIZE = round(SIZE)

                    sent_message.edit_text(TEXT.UPLOADING.format(filename, SIZE))

                    try:
                        FILELINK = upload(filename, update,
                                        context, TEXT.drive_folder_name)
                    except Exception as e:
                        print("error Code : UPX11", e)
                        sent_message.edit_text("Uploading fail :{}".format(e))
                    else:
                        sent_message.edit_text(TEXT.DOWNLOAD_URL.format(
                            filename, SIZE, download_time, FILELINK), parse_mode=ParseMode.HTML)
                    print(filename)
                    try:
                        os.remove(filename)
                    except Exception as e:
                        print(e)
            except Exception as e:
                print("Error code UXP12", e)
                if DownloadStatus:
                    sent_message.edit_text("Uploading fail : {}".format(e))
                    try:
                        os.remove(filename)
                    except Exception as e:
                        print("Error code UXP13", e)
                else:
                    sent_message.edit_text("Uploading fail :", e)

        else:
            context.bot.send_message(
                chat_id=update.message.chat_id, text=TEXT.NOT_AUTH)
示例#3
0
def UPLOAD(update, context):

    url = update.message.text
    url = url.split()[-1]
    sent_message = context.bot.send_message(chat_id=update.message.chat_id,
                                            text=TEXT.PROCESSING)

    ID = update.message.chat_id
    ID = str(ID)
    os.path.isfile(ID)
    if os.path.isfile(ID):
        try:
            filename = url.split("/")[-1]

            print("Downloading Started : {}".format(url.split("/")[-1]))
            sent_message.edit_text(TEXT.DOWNLOAD)
            # filename = wget.download(url)
            filename = wget_dl(str(url))
            print("Downloading Complete : {}".format(filename))
            sent_message.edit_text(TEXT.DOWN_COMPLETE)
            DownloadStatus = True

        except Exception as e:
            # switch To second download(SmartDl Downloader) `You can activate it throungh TEXT file`
            if TEXT.DOWN_TWO:
                print(TEXT.DOWN_TWO)
                try:
                    sent_message.edit_text(
                        "Downloader 1 Error:{} \n\n Downloader 2 :Downloading Started..."
                        .format(e))

                    obj = SmartDL(url)
                    obj.start()
                    filename = obj.get_dest()
                    DownloadStatus = True
                except Exception as e:
                    print(e)
                    sent_message.edit_text("Downloading error :{}".format(e))
                    DownloadStatus = False
            else:
                print(e)
                sent_message.edit_text("Downloading error :{}".format(e))
                DownloadStatus = False

            # Checking Error Filename
        if "error" in filename:
            # print(filename)
            # print(filename[0],filename[-1],filename[1])
            sent_message.edit_text("Downloading Error !! ")
            os.remove(filename[-1])

            ##########Uploading part  ###################
        try:

            if DownloadStatus:
                sent_message.edit_text(TEXT.UPLOADING)

                SIZE = (os.path.getsize(filename)) / 1048576
                SIZE = round(SIZE)
                FILENAME = filename.split("/")[-1]
                try:
                    FILELINK = upload(filename, update, context,
                                      TEXT.drive_folder_name)
                except Exception as e:
                    print("error Code : UPX11", e)
                    sent_message.edit_text("Uploading fail :{}".format(e))

                sent_message.edit_text(TEXT.DOWNLOAD_URL.format(
                    FILENAME, SIZE, FILELINK),
                                       parse_mode=ParseMode.HTML)
                print(filename)
                try:
                    os.remove(filename)
                except Exception as e:
                    print(e)
        except Exception as e:
            print("Error code UXP12", e)
            if DownloadStatus:
                sent_message.edit_text("Uploading fail : {}".format(e))
                try:
                    os.remove(filename)
                except Exception as e:
                    print("Error code UXP13", e)
            else:
                sent_message.edit_text("Uploading fail :", e)

    else:
        context.bot.send_message(chat_id=update.message.chat_id,
                                 text=TEXT.NOT_AUTH)
示例#4
0
def UPLOAD(update, context):

    url = update.message.text
    url = url.split()[-1]
    sent_message = context.bot.send_message(chat_id=update.message.chat_id,
                                            text=TEXT.PROCESSING)
    glitch = [
        '( ͡° ͜ʖ ͡°)', '¯\_(ツ)_/¯',
        '̿̿ ̿̿ ̿̿ ̿\̿\'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿',
        '¯\_(ツ)_/¯', 'ʕ•ᴥ•ʔ', '(ง ͠° ͟ل͜ ͡°)ง', '(;´༎ຶД༎ຶ`)'
    ]
    download_time = 'NA'
    ID = update.message.chat_id
    ID = str(ID)
    os.path.isfile(ID)
    if os.path.isfile(ID):
        # Openlaod Stuffs

        # I will Add This Later
        if "openload" in url or "oload" in url:

            DownloadStatus = False
            sent_message.edit_text("Openload No longer avalible")
            return

            # Here is DropBox Stuffs
        elif 'dropbox.com' in url:

            url = DPBOX(url)
            filename = url.split("/")[-1]
            print("Dropbox link Downloading Started : {}".format(
                url.split("/")[-1]))
            sent_message.edit_text(TEXT.DP_DOWNLOAD)
            # filename = wget.download(url)
            filename = wget_dl(str(url))
            print("Downloading Complete : {}".format(filename))
            sent_message.edit_text(TEXT.DOWN_COMPLETE)
            DownloadStatus = True
        # Here IS Mega Links stuffs
        elif 'mega.nz' in url:

            try:
                print("Downlaoding Started")
                sent_message.edit_text(TEXT.DOWN_MEGA)
                m = Mega.from_credentials(TEXT.MEGA_EMAIL, TEXT.MEGA_PASSWORD)
                filename = m.download_from_url(url)
                print("Downloading Complete Mega :", filename)
                sent_message.edit_text(TEXT.DOWN_COMPLETE)

                DownloadStatus = True
            except Exception as e:
                print("Mega Downloding Error :", e)
                sent_message.edit_text("Mega Downloading Error !!")

        else:
            try:
                filename = url.split("/")[-1]

                print("Downloading Started : {}".format(url.split("/")[-1]))
                sent_message.edit_text(TEXT.DOWNLOAD)
                # filename = wget.download(url)
                #--------------------------------------------------
                #-------> Download function

                temp_name = unquote(url).split("/")[-1]
                dest = os.getcwd()
                obj = SmartDL(url, dest, progress_bar=False)
                obj.start(blocking=False)
                while not obj.isFinished():
                    try:
                        stats = "FileName: {} \nProgress: {:.2f}% \nSpeed: {} \nAlready Downloaded: {} \nEstimated time: {} \n  : {}  ".format(
                            temp_name, (obj.get_progress() * 100),
                            obj.get_speed(human=True),
                            obj.get_dl_size(human=True),
                            obj.get_eta(human=True), obj.get_progress_bar())
                        sent_message.edit_text(stats)
                        time.sleep(.5)
                    except:
                        sent_message.edit_text(choice(glitch))

                if obj.isSuccessful():
                    filename = obj.get_dest().split('/')[-1]
                    download_time = obj.get_dl_time(human=True)
                else:
                    raise ValueError(
                        'Download failed!! \n Switching to method 2')
                #--------------------------------------------------
                print("Downloading Complete : {}".format(filename))
                sent_message.edit_text(TEXT.DOWN_COMPLETE)
                DownloadStatus = True

            except Exception as e:
                # switch To second download(SmartDl Downloader) `You can activate it throungh TEXT file`
                if TEXT.DOWN_TWO:
                    print(TEXT.DOWN_TWO)
                    try:
                        sent_message.edit_text(
                            "Downloader 1 Error:{} \n\n Downloader 2 :Downloading Started..."
                            .format(e))
                        ###-------> Download backup fn
                        filename = wget_dl(str(url))

                        DownloadStatus = True
                    except Exception as e:
                        print(e)
                        sent_message.edit_text(
                            "Downloading error :{}".format(e))
                        DownloadStatus = False
                else:
                    print(e)
                    sent_message.edit_text("Downloading error :{}".format(e))
                    DownloadStatus = False

            # Checking Error Filename
        if "error" in filename:
            # print(filename)
            # print(filename[0],filename[-1],filename[1])
            sent_message.edit_text("Downloading Error !! ")
            os.remove(filename[-1])


#------_> UPLOAD FN

##########Uploading part  ###################
        try:

            if DownloadStatus:
                sent_message.edit_text(TEXT.UPLOADING)

                SIZE = (os.path.getsize(filename)) / 1048576
                SIZE = round(SIZE)
                try:
                    FILELINK = upload(filename, update, context,
                                      TEXT.drive_folder_name)
                except Exception as e:
                    print("error Code : UPX11", e)
                    sent_message.edit_text("Uploading fail :{}".format(e))
                else:
                    sent_message.edit_text(TEXT.DOWNLOAD_URL.format(
                        filename, SIZE, download_time, FILELINK),
                                           parse_mode=ParseMode.HTML)
                print(filename)
                try:
                    os.remove(filename)
                except Exception as e:
                    print(e)
        except Exception as e:
            print("Error code UXP12", e)
            if DownloadStatus:
                sent_message.edit_text("Uploading fail : {}".format(e))
                try:
                    os.remove(filename)
                except Exception as e:
                    print("Error code UXP13", e)
            else:
                sent_message.edit_text("Uploading fail :", e)

    else:
        context.bot.send_message(chat_id=update.message.chat_id,
                                 text=TEXT.NOT_AUTH)
示例#5
0
def UPLOAD(update, context):

    url = update.message.text
    url = url.split()[-1]
    sent_message = context.bot.send_message(chat_id=update.message.chat_id,
                                            text=TEXT.PROCESSING)

    ID = update.message.chat_id
    ID = str(ID)
    os.path.isfile(ID)
    if os.path.isfile(ID):
        # Openlaod Stuffs

        # I will Add This Later
        if "openload" in url or "oload" in url:

            DownloadStatus = False
            sent_message.edit_text("Openload No longer avalible")
            return

            # Here is DropBox Stuffs
        elif 'dropbox.com' in url:

            url = DPBOX(url)
            filename = url.split("/")[-1]
            print("Dropbox link Downloading Started : {}".format(
                url.split("/")[-1]))
            sent_message.edit_text(TEXT.DP_DOWNLOAD)
            # filename = wget.download(url)
            filename = wget_dl(str(url))
            print("Downloading Complete : {}".format(filename))
            sent_message.edit_text(TEXT.DOWN_COMPLETE)
            DownloadStatus = True
        # Here IS Mega Links stuffs
        elif 'mega.nz' in url:

            try:
                print("Downlaoding Started")
                sent_message.edit_text(TEXT.DOWN_MEGA)
                m = Mega.from_credentials(TEXT.MEGA_EMAIL, TEXT.MEGA_PASSWORD)
                filename = m.download_from_url(url)
                print("Downloading Complete Mega :", filename)
                sent_message.edit_text(TEXT.DOWN_COMPLETE)

                DownloadStatus = True
            except Exception as e:
                print("Mega Downloding Error :", e)
                sent_message.edit_text("Mega Downloading Error !!")

        else:
            try:

                #START - TAMBAHAN UNTUK FILE NAME TIDAK TERDETEKSI PAKAI WGET CONTENT-DISPOSITION
                #URL = str(input("url = "))
                remotefile = urlopen(url)
                '''
                filename1 = remotefile.info()['Content-Disposition']
                print(filename1)
                filename2 = remotefile.headers['Content-Disposition']
                print(filename2)
                '''
                try:
                    filename3 = remotefile.info()['Content-Disposition'].split(
                        'filename=')[1]
                    if filename3[0] == '"' or filename3[0] == "'":
                        filename3 = filename3[1:-1]
                    #print(filename3)
                    filename = filename3
                except Exception as e:
                    filename = url.split("/")[-1]
                #END - TAMBAHAN UNTUK FILE NAME TIDAK TERDETEKSI PAKAI WGET CONTENT-DISPOSITION

                #filename = url.split("/")[-1]

                print("Downloading Started : {}".format(filename))
                sent_message.edit_text(TEXT.DOWNLOAD)
                filename = wget.download(url)
                #filename = wget_dl(str(url))
                print("Downloading Complete : {}".format(filename))
                sent_message.edit_text(TEXT.DOWN_COMPLETE)
                DownloadStatus = True

            except Exception as e:

                print(e)
                sent_message.edit_text("Downloading error :{}".format(e))
                DownloadStatus = False

            # Checking Error Filename
        if "error" in filename:
            # print(filename)
            # print(filename[0],filename[-1],filename[1])
            sent_message.edit_text("Downloading Error !! ")
            os.remove(filename[-1])

            ##########Uploading part  ###################
        try:

            if DownloadStatus:
                sent_message.edit_text(TEXT.UPLOADING)

                SIZE = (os.path.getsize(filename)) / 1048576
                SIZE = round(SIZE)
                FILENAME = filename.split("/")[-1]
                try:
                    FILELINK = upload(filename, update, context,
                                      TEXT.drive_folder_name)
                except Exception as e:
                    print("error Code : UPX11", e)
                    sent_message.edit_text("Uploading fail :{}".format(e))
                else:
                    sent_message.edit_text(TEXT.DOWNLOAD_URL.format(
                        FILENAME, SIZE, FILELINK),
                                           parse_mode=ParseMode.HTML)
                print(filename)
                try:
                    os.remove(filename)
                except Exception as e:
                    print(e)
        except Exception as e:
            print("Error code UXP12", e)
            if DownloadStatus:
                sent_message.edit_text("Uploading fail : {}".format(e))
                try:
                    os.remove(filename)
                except Exception as e:
                    print("Error code UXP13", e)
            else:
                sent_message.edit_text("Uploading fail :", e)

    else:
        context.bot.send_message(chat_id=update.message.chat_id,
                                 text=TEXT.NOT_AUTH)