mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-17 16:45:13 -04:00
Show user message when config KeyError
s
Formatting
This commit is contained in:
parent
8ccf74fd76
commit
0367a04137
5 changed files with 46 additions and 25 deletions
|
@ -50,7 +50,7 @@ def cli(ctx, **kwargs):
|
|||
global config
|
||||
global core
|
||||
|
||||
if ctx.invoked_subcommand == 'config':
|
||||
if ctx.invoked_subcommand == "config":
|
||||
return
|
||||
|
||||
if kwargs["debug"]:
|
||||
|
|
|
@ -489,7 +489,7 @@ class TidalClient(ClientInterface):
|
|||
try:
|
||||
manifest = json.loads(base64.b64decode(resp["manifest"]).decode("utf-8"))
|
||||
except KeyError:
|
||||
raise Exception(resp['userMessage'])
|
||||
raise Exception(resp["userMessage"])
|
||||
|
||||
logger.debug(manifest)
|
||||
return {
|
||||
|
|
|
@ -154,6 +154,7 @@ class MusicDL(list):
|
|||
self.append(item)
|
||||
|
||||
def download(self):
|
||||
try:
|
||||
arguments = {
|
||||
"database": self.db,
|
||||
"parent_folder": self.config.session["downloads"]["folder"],
|
||||
|
@ -168,8 +169,22 @@ class MusicDL(list):
|
|||
"stay_temp": self.config.session["conversion"]["enabled"],
|
||||
"conversion": self.config.session["conversion"],
|
||||
"concurrent_downloads": self.config.session["concurrent_downloads"],
|
||||
"new_tracknumbers": self.config.session['metadata']['new_playlist_tracknumbers']
|
||||
"new_tracknumbers": self.config.session["metadata"][
|
||||
"new_playlist_tracknumbers"
|
||||
],
|
||||
}
|
||||
except KeyError as err:
|
||||
click.secho(
|
||||
"There was a problem with your config file. This happens "
|
||||
"sometimes after updates. Run ",
|
||||
nl=False,
|
||||
fg="red",
|
||||
)
|
||||
click.secho("rip config --reset ", fg="yellow", nl=False)
|
||||
click.secho("to reset it. You will need to log in again.", fg="red")
|
||||
logger.debug(err)
|
||||
exit()
|
||||
|
||||
logger.debug("Arguments from config: %s", arguments)
|
||||
|
||||
source_subdirs = self.config.session["downloads"]["source_subdirectories"]
|
||||
|
|
|
@ -217,7 +217,7 @@ class Track:
|
|||
try:
|
||||
dl_info = self.client.get_file_url(url_id, self.quality)
|
||||
except Exception as e:
|
||||
click.secho(f"Unable to download track. {e}", fg='red')
|
||||
click.secho(f"Unable to download track. {e}", fg="red")
|
||||
return False
|
||||
|
||||
self.path = os.path.join(gettempdir(), f"{hash(self.id)}_{self.quality}.tmp")
|
||||
|
@ -237,10 +237,14 @@ class Track:
|
|||
# --------- Download Track ----------
|
||||
if self.client.source in ("qobuz", "tidal"):
|
||||
logger.debug("Downloadable URL found: %s", dl_info.get("url"))
|
||||
tqdm_download(dl_info["url"], self.path, desc=self._progress_desc) # downloads file
|
||||
tqdm_download(
|
||||
dl_info["url"], self.path, desc=self._progress_desc
|
||||
) # downloads file
|
||||
|
||||
elif self.client.source == "deezer": # Deezer
|
||||
logger.debug("Downloadable URL found: %s", dl_info, desc=self._progress_desc)
|
||||
logger.debug(
|
||||
"Downloadable URL found: %s", dl_info, desc=self._progress_desc
|
||||
)
|
||||
try:
|
||||
tqdm_download(dl_info, self.path) # downloads file
|
||||
except NonStreamable:
|
||||
|
@ -317,7 +321,7 @@ class Track:
|
|||
|
||||
@property
|
||||
def _progress_desc(self):
|
||||
return click.style(f"Track {int(self.meta.tracknumber):02}", fg='blue')
|
||||
return click.style(f"Track {int(self.meta.tracknumber):02}", fg="blue")
|
||||
|
||||
def download_cover(self):
|
||||
"""Downloads the cover art, if cover_url is given."""
|
||||
|
@ -329,7 +333,9 @@ class Track:
|
|||
# click.secho(f"\nDownloading cover art for {self!s}", fg="blue")
|
||||
|
||||
if not os.path.exists(self.cover_path):
|
||||
tqdm_download(self.cover_url, self.cover_path, desc=click.style('Cover', fg='cyan'))
|
||||
tqdm_download(
|
||||
self.cover_url, self.cover_path, desc=click.style("Cover", fg="cyan")
|
||||
)
|
||||
else:
|
||||
logger.debug("Cover already exists, skipping download")
|
||||
|
||||
|
@ -1253,7 +1259,7 @@ class Playlist(Tracklist):
|
|||
|
||||
if kwargs.get("new_tracknumbers", True):
|
||||
item["tracknumber"] = self.__download_index
|
||||
item['discnumber'] = 1
|
||||
item["discnumber"] = 1
|
||||
|
||||
self.__download_index += 1
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ class TrackMetadata:
|
|||
for k, v in FLAC_KEY.items():
|
||||
tag = getattr(self, k)
|
||||
if tag:
|
||||
if k in ('tracknumber', 'discnumber', 'tracktotal', 'disctotal'):
|
||||
if k in ("tracknumber", "discnumber", "tracktotal", "disctotal"):
|
||||
tag = f"{int(tag):02}"
|
||||
|
||||
logger.debug("Adding tag %s: %s", v, tag)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue