mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Adding __json__ to Downloader for sending them to the FE. Hiding ChannelDownloader because it will be handled specifically.
This commit is contained in:
parent
047b507119
commit
e3c57ef674
3 changed files with 14 additions and 7 deletions
|
|
@ -50,6 +50,7 @@ class ChannelDownloader(Downloader, ABC):
|
|||
"""
|
||||
name = 'video_channel'
|
||||
pretty_name = 'Video Channel'
|
||||
listable = False
|
||||
|
||||
def __repr__(self):
|
||||
return f'<ChannelDownloader name={self.name}>'
|
||||
|
|
|
|||
|
|
@ -426,3 +426,11 @@ def test_selected_downloader(test_session, video_download_manager):
|
|||
mock_do_download.assert_called_once()
|
||||
|
||||
check_attempts(3)
|
||||
|
||||
|
||||
def test_channel_downloader_hidden(video_download_manager):
|
||||
"""
|
||||
ChannelDownloader should not be presented to the User.
|
||||
"""
|
||||
downloaders = video_download_manager.list_downloaders()
|
||||
assert downloaders == [(dict(name='video', pretty_name='Videos')), ]
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ class Download(ModelHelper, Base):
|
|||
class Downloader:
|
||||
name = None
|
||||
pretty_name = None
|
||||
listable = True
|
||||
|
||||
def __init__(self, priority: int = 50, name: str = None):
|
||||
"""
|
||||
|
|
@ -126,6 +127,9 @@ class Downloader:
|
|||
|
||||
download_manager.register_downloader(self)
|
||||
|
||||
def __json__(self):
|
||||
return dict(name=self.name, pretty_name=self.pretty_name)
|
||||
|
||||
@classmethod
|
||||
def valid_url(cls, url) -> Tuple[bool, Optional[dict]]:
|
||||
raise NotImplementedError()
|
||||
|
|
@ -530,13 +534,7 @@ class DownloadManager:
|
|||
"""
|
||||
Return a list of the Downloaders available on this Download Manager.
|
||||
"""
|
||||
downloaders = []
|
||||
for i in self.instances:
|
||||
downloaders.append(dict(
|
||||
name=i.name,
|
||||
pretty_name=i.pretty_name,
|
||||
))
|
||||
return downloaders
|
||||
return list(filter(lambda i: i.listable, self.instances))
|
||||
|
||||
|
||||
# The global DownloadManager. This should be used everywhere!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue