Allow passing a playlist URL to diva instead of an id

This commit is contained in:
I-Al-Istannen
2020-05-10 11:11:28 +02:00
parent f6faacabb0
commit 9950144e97
2 changed files with 42 additions and 4 deletions

View File

@ -147,7 +147,7 @@ class Pferd(Location):
def diva_kit(
self,
target: Union[PathLike, Organizer],
playlist_id: str,
playlist_location: str,
transform: Transform = lambda x: x,
download_strategy: DivaDownloadStrategy = diva_download_new,
clean: bool = True
@ -157,7 +157,8 @@ class Pferd(Location):
Arguments:
organizer {Organizer} -- The organizer to use.
playlist_id {str} -- the playlist id
playlist_location {str} -- the playlist id or the playlist URL
in the format 'https://mediaservice.bibliothek.kit.edu/#/details/DIVA-2019-271'
Keyword Arguments:
transform {Transform} -- A transformation function for the output paths. Return None
@ -169,6 +170,11 @@ class Pferd(Location):
"""
tmp_dir = self._tmp_dir.new_subdir()
if playlist_location.startswith("http"):
playlist_id = DivaPlaylistCrawler.fetch_id(playlist_link=playlist_location)
else:
playlist_id = playlist_location
if target is None:
PRETTY.starting_synchronizer("None", "DIVA", playlist_id)
raise FatalException("Got 'None' as target directory, aborting")