Giter VIP home page Giter VIP logo

Comments (5)

porridgexj avatar porridgexj commented on August 29, 2024

I think it is a bug from pyrogram, we just can't catch the FLOOD error from app.download_media function. So I find another way to solve this, when show a FloodWait error, the file downloaded size usually is 0KB, so we can test whether the file size is 0KB.

def is_file_empty(file_path):
    if os.path.exists(file_path):
        return os.path.getsize(file_path) == 0
    else:
        return True

flag = True
while flag:
    # 'download_media' is a function from 'pyrogram'
    file_path = app.download_media(file_id)
    if file_path and not is_file_empty(file_path):  
        flag = False
        # solve success situation
    else:
        time.sleep(10)
        # sleep for several seconds and retry

from telegram_media_downloader.

AIRDOGE avatar AIRDOGE commented on August 29, 2024

the same problem

from telegram_media_downloader.

AIRDOGE avatar AIRDOGE commented on August 29, 2024

I think it is a bug from pyrogram, we just can't catch the FLOOD error from app.download_media function. So I find another way to solve this, when show a FloodWait error, the file downloaded size usually is 0KB, so we can test whether the file size is 0KB.

def is_file_empty(file_path):
    if os.path.exists(file_path):
        return os.path.getsize(file_path) == 0
    else:
        return True

flag = True
while flag:
    # 'download_media' is a function from 'pyrogram'
    file_path = app.download_media(file_id)
    if file_path and not is_file_empty(file_path):  
        flag = False
        # solve success situation
    else:
        time.sleep(10)
        # sleep for several seconds and retry

Where should I need to insert this code?

from telegram_media_downloader.

AIRDOGE avatar AIRDOGE commented on August 29, 2024

Is there any way to make the program automatically wait for the time required by telegram and than restarting the download?

from telegram_media_downloader.

porridgexj avatar porridgexj commented on August 29, 2024

Is there any way to make the program automatically wait for the time required by telegram and than restarting the download?

We can’t get the seconds that telegram required, because we just can’t catch the FLOOD error info from pyrogram. If you want to make the program wait for the time required by telegram exactly, I think you can let time.sleep from 10 to 1…but i think it will put pressure on telegram’s server, i think check every 30 seconds is ok

by the way, I didn’t try to insert my code to TELEGRAM_MEIDA_DOWNLOADER, because I just want to download all pics from a channel, it is easy to achieve By just using PYROGRAM, so I wrote my own code, and not use TELEGRAM_MEDIA_DOWNLOADER

from telegram_media_downloader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.