main
This commit is contained in:
parent
9f1ee7cfa4
commit
ed182d79f6
2 changed files with 18 additions and 13 deletions
|
|
@ -5,17 +5,19 @@ parser = argparse.ArgumentParser(
|
||||||
description="YoutubeDL-Subscribe: Download and organize your favorite media easily."
|
description="YoutubeDL-Subscribe: Download and organize your favorite media easily."
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c", "--config",
|
"-c",
|
||||||
metavar='CONFIGPATH',
|
"--config",
|
||||||
|
metavar="CONFIGPATH",
|
||||||
type=str,
|
type=str,
|
||||||
help="path to the config yaml, uses subscriptions.yaml if not provided",
|
help="path to the config yaml, uses subscriptions.yaml if not provided",
|
||||||
default="subscriptions.yaml",
|
default="subscriptions.yaml",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-s", "--subscriptions",
|
"-s",
|
||||||
metavar='SUB',
|
"--subscriptions",
|
||||||
nargs='+',
|
metavar="SUB",
|
||||||
help='specific subscriptions to download, downloads all if not provided'
|
nargs="+",
|
||||||
|
help="specific subscriptions to download, downloads all if not provided",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,15 +199,12 @@ class SoundcloudSubscription(Subscription):
|
||||||
tracks = []
|
tracks = []
|
||||||
|
|
||||||
if self.options.get("download_strategy") == "albums_then_tracks":
|
if self.options.get("download_strategy") == "albums_then_tracks":
|
||||||
track_ytdl_opts = {
|
# Get the album info first, but do not download. This tells us which track ids belong
|
||||||
"download_archive": self.WORKING_DIRECTORY
|
# to an album. Unfortunately we cannot use download_archive or info.json for this
|
||||||
+ "/ytdl-download-archive.txt",
|
|
||||||
}
|
|
||||||
# Get the album tracks first, but do not download. Unfortunately we cannot use download_archive for
|
|
||||||
# this be
|
|
||||||
with ytdl.YoutubeDL(self.ytdl_opts) as ytd:
|
with ytdl.YoutubeDL(self.ytdl_opts) as ytd:
|
||||||
info = ytd.extract_info(base_url + "/albums", download=False)
|
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"]]
|
album_entries = [self.parse_album_entry(a) for a in info["entries"]]
|
||||||
for album_entry in album_entries:
|
for album_entry in album_entries:
|
||||||
tracks += [
|
tracks += [
|
||||||
|
|
@ -216,9 +213,15 @@ class SoundcloudSubscription(Subscription):
|
||||||
if not self.is_entry_skippable(e)
|
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:
|
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")
|
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]
|
album_track_ids = [t["id"] for t in tracks]
|
||||||
tracks += [
|
tracks += [
|
||||||
self.parse_entry(e)
|
self.parse_entry(e)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue