Add option to download videos and booklets in config; #53

This commit is contained in:
nathom 2021-04-17 13:13:32 -07:00
parent b0f6e7b197
commit c4f2740d93
4 changed files with 15 additions and 6 deletions

View file

@ -594,6 +594,8 @@ class Video:
p = subprocess.Popen(command)
p.wait() # remove this?
return False # so that it is not tagged
@classmethod
def from_album_meta(cls, track: dict, client: Client):
return cls(

View file

@ -48,6 +48,7 @@ class Config:
defaults = {
"qobuz": {
"quality": 3,
"download_booklets": True,
"email": None,
"password": None,
"app_id": "",
@ -55,6 +56,7 @@ class Config:
},
"tidal": {
"quality": 3,
"download_videos": True,
"user_id": None,
"country_code": None,
"access_token": None,
@ -115,10 +117,11 @@ class Config:
self.load()
def update(self):
"""Resets the config file except for credentials."""
self.reset()
temp = copy.deepcopy(self.defaults)
temp["qobuz"] = self.file["qobuz"]
temp["tidal"] = self.file["tidal"]
temp["qobuz"].update(self.file["qobuz"])
temp['tidal'].update(self.file['tidal'])
self.dump(temp)
def save(self):
@ -209,11 +212,13 @@ class ConfigDocumentation:
"""Documentation is stored in this docstring.
qobuz:
quality: 1: 320kbps MP3, 2: 16/44.1, 3: 24/<=96, 4: 24/>=96
download_booklets: This will download booklet pdfs that are included with some albums
password: This is an md5 hash of the plaintext password
app_id: Do not change
secrets: Do not change
tidal:
quality: 0, 1, 2, or 3
download_videos: This will download videos included in Video Albums.
user_id: Do not change any of the fields below
token_expiry: Tokens last 1 week after refresh. This is the Unix timestamp of the expiration time.
deezer: Deezer doesn't require login

View file

@ -132,6 +132,8 @@ class MusicDL(list):
"new_tracknumbers": self.config.session["metadata"][
"new_playlist_tracknumbers"
],
"download_videos": self.config.session['tidal']['download_videos'],
'download_booklets': self.config.session['qobuz']['download_booklets'],
}
def download(self):

View file

@ -7,7 +7,7 @@ import logging
import os
import re
from tempfile import gettempdir
from typing import Generator, Iterable
from typing import Generator, Iterable, Union
import click
from pathvalidate import sanitize_filename
@ -139,20 +139,20 @@ class Album(Tracklist):
self.cover_obj = None
# Download the booklet if applicable
if self.get("booklets"):
if self.get("booklets") and kwargs.get('download_booklets', True):
click.secho("\nDownloading booklets", fg='blue')
for item in self.booklets:
Booklet(item).download(parent_folder=self.folder)
def _download_item(
self,
track: Track,
track: Union[Track, Video],
quality: int = 3,
database: MusicDB = None,
**kwargs,
) -> bool:
logger.debug("Downloading track to %s", self.folder)
if self.disctotal > 1:
if self.disctotal > 1 and isinstance(track, Track):
disc_folder = os.path.join(self.folder, f"Disc {track.meta.discnumber}")
kwargs["parent_folder"] = disc_folder
else: