mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
commit1663e1be9eAuthor: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:37:25 2021 -0700 Setting downloader to video when a channel schedules it's videos for download. commita6811f9e87Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:33:27 2021 -0700 Setting channel downloader when spreading channel downloads. commitb63c8f132aAuthor: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:28:53 2021 -0700 Fixing DownloadManager.kill commit120ce7cd2cAuthor: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:10:12 2021 -0700 Fixing OTP api urls. commitd3b985241bAuthor: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:07:48 2021 -0700 Channel Cancel button does not submit form. commit9d1a0ecd55Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:00:53 2021 -0700 A Channel without an existing Download cannot be downloaded. commite7c920f382Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:41:02 2021 -0700 Fixing typing. commitd56c8fde24Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:36:02 2021 -0700 Testing bad downloader param. commite3c57ef674Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:31:35 2021 -0700 Adding __json__ to Downloader for sending them to the FE. Hiding ChannelDownloader because it will be handled specifically. commit047b507119Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:20:37 2021 -0700 Downloader can be specified by the user. commit4a169ba43cAuthor: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:37:30 2021 -0700 Download info a set in create_downloads. commit8778d53fa1Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:21:43 2021 -0700 Fixing Download.info_json name. commitb28bacfd5bAuthor: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:17:53 2021 -0700 Downloader names are in the class, not in the init. commitf5ce952da0Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:07:42 2021 -0700 Download info can be saved during the download process and can be used by the Downloader.
38 lines
1 KiB
Python
38 lines
1 KiB
Python
from abc import ABC
|
|
from typing import Tuple
|
|
|
|
from wrolpi.common import logger
|
|
from wrolpi.downloader import Downloader, Download
|
|
from wrolpi.errors import UnrecoverableDownloadError
|
|
from . import lib
|
|
from .api import bp # noqa
|
|
|
|
PRETTY_NAME = 'Archive'
|
|
|
|
logger = logger.getChild(__name__)
|
|
|
|
|
|
class ArchiveDownloader(Downloader, ABC):
|
|
name = 'archive'
|
|
pretty_name = 'Archive'
|
|
|
|
def __repr__(self):
|
|
return f'<ArchiveDownloader name={self.name}>'
|
|
|
|
@classmethod
|
|
def valid_url(cls, url: str) -> Tuple[bool, None]:
|
|
"""
|
|
Archiver will attempt to archive anything, so it should be last!
|
|
"""
|
|
return True, None
|
|
|
|
def do_download(self, download: Download):
|
|
if download.attempts > 3:
|
|
raise UnrecoverableDownloadError(f'Max download attempts reached for {download.url}')
|
|
|
|
lib.new_archive(download.url, sync=True)
|
|
return True
|
|
|
|
|
|
# Archive downloader is the last downloader which should be used.
|
|
archive_downloader = ArchiveDownloader(priority=100)
|