mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-23 03:27:14 -04:00
Add support for multiple -u arguments.
This commit is contained in:
parent
6b794a1abb
commit
67657723ca
2 changed files with 35 additions and 33 deletions
|
@ -31,6 +31,7 @@ if not os.path.isdir(CACHE_DIR):
|
||||||
"--urls",
|
"--urls",
|
||||||
metavar="URLS",
|
metavar="URLS",
|
||||||
help="Url from Qobuz, Tidal, SoundCloud, or Deezer",
|
help="Url from Qobuz, Tidal, SoundCloud, or Deezer",
|
||||||
|
multiple=True,
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"-q",
|
"-q",
|
||||||
|
|
|
@ -111,44 +111,45 @@ class MusicDL(list):
|
||||||
else:
|
else:
|
||||||
self.db = []
|
self.db = []
|
||||||
|
|
||||||
def handle_urls(self, url: str):
|
def handle_urls(self, urls):
|
||||||
"""Download a url.
|
for url in urls:
|
||||||
|
"""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
|
# youtube is handled by youtube-dl, so much of the
|
||||||
# processing is not necessary
|
# processing is not necessary
|
||||||
youtube_urls = self.youtube_url_parse.findall(url)
|
youtube_urls = self.youtube_url_parse.findall(url)
|
||||||
if youtube_urls != []:
|
if youtube_urls != []:
|
||||||
self.extend(YoutubeVideo(u) for u in 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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue