Downloader names are in the class, not in the init.

This commit is contained in:
Roland 2021-12-28 18:17:53 -07:00
parent f5ce952da0
commit b28bacfd5b
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
6 changed files with 44 additions and 20 deletions

View file

@ -13,6 +13,8 @@ logger = logger.getChild(__name__)
class ArchiveDownloader(Downloader, ABC):
name = 'archive'
@classmethod
def valid_url(cls, url: str) -> Tuple[bool, None]:
"""
@ -29,4 +31,4 @@ class ArchiveDownloader(Downloader, ABC):
# Archive downloader is the last downloader which should be used.
archive_downloader = ArchiveDownloader('archive', priority=100)
archive_downloader = ArchiveDownloader(priority=100)

View file

@ -114,8 +114,8 @@ def video_download_manager(test_download_manager) -> DownloadManager:
"""
Get a DownloadManager ready to download Videos and Channels.
"""
channel_downloader = ChannelDownloader('video_channel')
video_downloader = VideoDownloader('video', priority=40)
channel_downloader = ChannelDownloader()
video_downloader = VideoDownloader(priority=40)
test_download_manager.register_downloader(channel_downloader)
test_download_manager.register_downloader(video_downloader)

View file

@ -47,6 +47,7 @@ class ChannelDownloader(Downloader, ABC):
"""
Handling downloading of all Videos in a Channel.
"""
name = 'video_channel'
@classmethod
def valid_url(cls, url) -> tuple[bool, None]:
@ -90,6 +91,7 @@ class VideoDownloader(Downloader, ABC):
"""
Download a single video. Store the video in it's channel's directory, otherwise store it in `videos/NO CHANNEL`.
"""
name = 'video'
@classmethod
def valid_url(cls, url) -> tuple[bool, Optional[dict]]:
@ -205,9 +207,9 @@ class VideoDownloader(Downloader, ABC):
return final_filename, entry
channel_downloader = ChannelDownloader('video_channel')
channel_downloader = ChannelDownloader()
# Videos may match the ChannelDownloader, give it a higher priority.
video_downloader = VideoDownloader('video', 40)
video_downloader = VideoDownloader(40)
def get_or_create_channel(source_id: str = None, link: str = None, url: str = None, name: str = None) -> Channel:

View file

@ -119,8 +119,8 @@ class TestVideosDownloaders(TestAPI):
def setUp(self) -> None:
super().setUp()
self.vd = VideoDownloader('video')
self.cd = ChannelDownloader('channel')
self.vd = VideoDownloader()
self.cd = ChannelDownloader()
self.mgr = DownloadManager()
self.mgr.register_downloader(self.vd)
self.mgr.register_downloader(self.cd)