wrolpi/modules/archive/__init__.py
Roland 785ad8274c
DownloadResult.try_again is not necessary.
Removing unused fixture in test.

Simplifying logic after download completes.  Removing unused download sorting method.

ChannelDownloader returns location.

Hiding View link when no location is provided.

Performing video upsert in try/except so any errors are attached to the Download.

Including stderr only.

Including logs when returning Downloader.process_runner.

Warning when extention is replaced.

Providing location link on Downloads page.  Showing error modal on errors that fail.

Handling empty URL strings on import.

Fixing channel download test.

Reworking how Channels schedule Video downloads.

Bumping version for DownloadResult.

Updating tests to use DownloadResult.

VideoDownloader returns a DownloadResult.
2022-05-10 21:20:36 -06:00

38 lines
1 KiB
Python

from abc import ABC
from typing import Tuple
from wrolpi.common import logger
from wrolpi.downloader import Downloader, Download, DownloadResult
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>'
@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) -> DownloadResult:
if download.attempts > 3:
raise UnrecoverableDownloadError(f'Max download attempts reached for {download.url}')
lib.do_archive(download.url)
return DownloadResult(success=True)
# Archive downloader is the last downloader which should be used.
archive_downloader = ArchiveDownloader(priority=100)