KurtBestor / Hitomi-Downloader

:cake: Desktop utility to download images/videos/music/text from various websites, and more.
22.16k stars 2.05k forks source link

Doubts about LazyUrl #6756

Open rickmiron opened 10 months ago

rickmiron commented 10 months ago

How does LazyUrl work? What attributes are used of the classes besides filename and url?

class Image:
     def __init__(self, name, urli):
         self.filename = name
         self.url = LazyUrl(urli, self.get, self)

     def get(self, urlg):
         return urlg

Is it possible to increase the number of files to download when the download process has already started? For example, I start downloading 20 files and when finished it loads more files and continues with those new files title (0/20) --> title (20/20) --> title (20/34) --> title (34/34)

KurtBestor commented 10 months ago

You may want to use utils.File, i.e.: https://github.com/KurtBestor/Hitomi-Downloader/blob/9c0519d155abd95b03c761ea3885bb84066a290e/src/extractor/nozomi_downloader.py#L13-L28

rickmiron commented 10 months ago

My question was, when I start the file download process and when I complete the entire download, is it possible to add more links to continue downloading? title (0/20) --> title (20/20) --> title (20/40) --> title (40/40) --> title (40/52) --> title (52/52 ) or the only thing that would be done is to place title(0/1000000) --> title(52/1000000)

KurtBestor commented 10 months ago

No such behavior is currently implemented; the progress bar should show how far the download has progressed.

rickmiron commented 10 months ago

I tried using something like that but the list no longer increases when the first files finish downloading.

def read(self):
    arid = []
    self.title = get_imgs(self.url, self.urls, arid)

def get_imgs(url, selfurls, arid):
    response = requests.get(url)
    if response.status_code==200:
        for jo in response.json():
            arid.append(jo['id'])
            selfurls.append(Image(jo['id'], jo['file'], url, arid, selfurls).url)
    return clean_title(url)

class Image:
    def __init__(self, id, url, referer, arid, arselfurls):
        self.id = id
        self.referer = referer
        self.arid = arid
        self.arselfurls = arselfurls
        self.url = LazyUrl(url, self.get, self)

    def get(self, url):
        if self.id == self.arid[-1]:
            urx = f'{self.referer}&next={self.id-1}'
            jsonx(urx, self.arid, self.arselfurl)
        ext = os.path.splitext(url)[1].split('?')[0]
        self.filename = f'{self.id}{ext}'
        return url

def jsonx(url, arrayid, selfurls):
    response = requests.get(url)
    if response.status_code==200:
        for jo in response.json():
            arrayid.append(jo['id'])
            selfurls.append(Image(jo['id'], jo['file'], url, arrayid, selfurls).url)