This commit is contained in:
Jesse Bannon 2021-09-10 22:55:15 -07:00
parent 9f1ee7cfa4
commit ed182d79f6
2 changed files with 18 additions and 13 deletions

View file

@ -5,17 +5,19 @@ parser = argparse.ArgumentParser(
description="YoutubeDL-Subscribe: Download and organize your favorite media easily."
)
parser.add_argument(
"-c", "--config",
metavar='CONFIGPATH',
"-c",
"--config",
metavar="CONFIGPATH",
type=str,
help="path to the config yaml, uses subscriptions.yaml if not provided",
default="subscriptions.yaml",
)
parser.add_argument(
"-s", "--subscriptions",
metavar='SUB',
nargs='+',
help='specific subscriptions to download, downloads all if not provided'
"-s",
"--subscriptions",
metavar="SUB",
nargs="+",
help="specific subscriptions to download, downloads all if not provided",
)

View file

@ -199,15 +199,12 @@ class SoundcloudSubscription(Subscription):
tracks = []
if self.options.get("download_strategy") == "albums_then_tracks":
track_ytdl_opts = {
"download_archive": self.WORKING_DIRECTORY
+ "/ytdl-download-archive.txt",
}
# Get the album tracks first, but do not download. Unfortunately we cannot use download_archive for
# this be
# Get the album info first, but do not download. This tells us which track ids belong
# to an album. Unfortunately we cannot use download_archive or info.json for this
with ytdl.YoutubeDL(self.ytdl_opts) as ytd:
info = ytd.extract_info(base_url + "/albums", download=False)
# For each album, parse each entry in the album
album_entries = [self.parse_album_entry(a) for a in info["entries"]]
for album_entry in album_entries:
tracks += [
@ -216,9 +213,15 @@ class SoundcloudSubscription(Subscription):
if not self.is_entry_skippable(e)
]
# Download the tracks now, and use download_archive to cache
track_ytdl_opts = {
"download_archive": self.WORKING_DIRECTORY
+ "/ytdl-download-archive.txt",
}
with ytdl.YoutubeDL(dict(self.ytdl_opts, **track_ytdl_opts)) as ytd:
# Get the rest of the tracks that are part of the album tracks
info = ytd.extract_info(base_url + "/tracks")
# Skip parsing entries that have already been parsed when parsing albums
album_track_ids = [t["id"] for t in tracks]
tracks += [
self.parse_entry(e)