Join urls

This commit is contained in:
Nathan Thomas 2021-06-22 14:17:18 -07:00 committed by GitHub
parent 67657723ca
commit a40bfd8374
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,44 +112,44 @@ class MusicDL(list):
self.db = [] self.db = []
def handle_urls(self, urls): def handle_urls(self, urls):
for url in urls: """Download a url.
"""Download a url.
:param url: :param url:
:type url: str :type url: str
:raises InvalidSourceError :raises InvalidSourceError
:raises ParsingError :raises ParsingError
""" """
# youtube is handled by youtube-dl, so much of the url = ' '.join(urls)
# processing is not necessary # youtube is handled by youtube-dl, so much of the
youtube_urls = self.youtube_url_parse.findall(url) # processing is not necessary
if youtube_urls != []: youtube_urls = self.youtube_url_parse.findall(url)
self.extend(YoutubeVideo(u) for u in youtube_urls) if youtube_urls != []:
self.extend(YoutubeVideo(u) for u in youtube_urls)
parsed = self.parse_urls(url) parsed = self.parse_urls(url)
if not parsed and len(self) == 0: if not parsed and len(self) == 0:
if "last.fm" in url: if "last.fm" in url:
message = ( message = (
f"For last.fm urls, use the {click.style('lastfm', fg='yellow')} " f"For last.fm urls, use the {click.style('lastfm', fg='yellow')} "
f"command. See {click.style('rip lastfm --help', fg='yellow')}." f"command. See {click.style('rip lastfm --help', fg='yellow')}."
) )
else: else:
message = url message = url
raise ParsingError(message) raise ParsingError(message)
for source, url_type, item_id in parsed: for source, url_type, item_id in parsed:
if item_id in self.db: if item_id in self.db:
logger.info( logger.info(
f"ID {item_id} already downloaded, use --no-db to override." f"ID {item_id} already downloaded, use --no-db to override."
) )
click.secho( click.secho(
f"ID {item_id} already downloaded, use --no-db to override.", f"ID {item_id} already downloaded, use --no-db to override.",
fg="magenta", fg="magenta",
) )
continue continue
self.handle_item(source, url_type, item_id) self.handle_item(source, url_type, item_id)
def handle_item(self, source: str, media_type: str, item_id: str): def handle_item(self, source: str, media_type: str, item_id: str):
"""Get info and parse into a Media object. """Get info and parse into a Media object.