small fixes
This commit is contained in:
parent
2ac8a4e1bc
commit
f11b5f014c
|
@ -13,7 +13,6 @@ from Crypto.Util import Counter
|
|||
from typing import Tuple
|
||||
from typing import BinaryIO
|
||||
|
||||
# MASTER_KEY = b64decode("UIlTTEMmmLfGowo/UC60x2H45W6MdGgTRfo/umg4754=")
|
||||
MASTER_KEY = (
|
||||
b"P\x89SLC&\x98\xb7\xc6\xa3\n?P.\xb4\xc7a\xf8\xe5n\x8cth\x13E\xfa?\xbah8\xef\x9e"
|
||||
)
|
||||
|
@ -96,16 +95,16 @@ def download_track(
|
|||
dest += ext
|
||||
break
|
||||
if os.path.exists(dest) and skip_dl:
|
||||
print(f"Skipping track")
|
||||
print("Skipping track")
|
||||
return
|
||||
|
||||
assert track.name and album.name
|
||||
with io.BytesIO() as b:
|
||||
print(f"Downloading track")
|
||||
print("Downloading track")
|
||||
key_id = manifest.get("keyId", None)
|
||||
mime = __download_file(url, b)
|
||||
if key_id:
|
||||
print(f"Decrypting track")
|
||||
print("Decrypting track")
|
||||
__decrypt_file(b, *__decode_key_id(key_id))
|
||||
metadata.write(
|
||||
b,
|
||||
|
@ -124,7 +123,7 @@ def download_track(
|
|||
http_failures += 1
|
||||
except KeyboardInterrupt as e:
|
||||
raise e
|
||||
except Exception as e:
|
||||
except:
|
||||
log_error(
|
||||
errorfile or "error.log",
|
||||
"Failure while downloading {artist} - {track}",
|
||||
|
|
|
@ -14,7 +14,9 @@ def get_conf(state_dir: str | None = None, conf_file: str | None = None) -> dict
|
|||
home = os.getenv("HOME")
|
||||
assert home
|
||||
|
||||
conf_file = (os.getenv("XDG_CONFIG_HOME") or home + "/.config") + "/tidal-scraper/conf.toml"
|
||||
conf_file = (
|
||||
os.getenv("XDG_CONFIG_HOME") or home + "/.config"
|
||||
) + "/tidal-scraper/conf.toml"
|
||||
with open(conf_file, "rb") as f:
|
||||
conf = tomllib.load(f)
|
||||
|
||||
|
@ -46,5 +48,5 @@ def log_error(logfile: str, template: str, **kwargs):
|
|||
|
||||
|
||||
def human_sleep() -> None:
|
||||
t = random.randrange(10, 50) / 10
|
||||
t = random.randrange(1000, 5000) / 1000
|
||||
time.sleep(t)
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
import json
|
||||
from datetime import datetime
|
||||
from tidalapi import session, user, playlist, media, album, artist
|
||||
from helper import log_error
|
||||
|
||||
|
||||
class State:
|
||||
def __init__(self, user_id: int, quality: str, dl_state_path: str):
|
||||
def __init__(
|
||||
self,
|
||||
user_id: int,
|
||||
quality: str,
|
||||
dl_state_path: str,
|
||||
conf: dict | None = None,
|
||||
errorfile: str | None = None,
|
||||
):
|
||||
if conf is None:
|
||||
assert errorfile is not None
|
||||
else:
|
||||
errorfile = errorfile or conf["error_log"]
|
||||
|
||||
match quality:
|
||||
case "master":
|
||||
q = session.Quality.master
|
||||
|
@ -22,7 +35,11 @@ class State:
|
|||
self.favorites = user.Favorites(self.session, user_id)
|
||||
try:
|
||||
self.load_dl_state(dl_state_path)
|
||||
except:
|
||||
except (FileNotFoundError, IndexError, AssertionError):
|
||||
log_error(
|
||||
errorfile or "error.log",
|
||||
f"Could not find state file at {dl_state_path}",
|
||||
)
|
||||
self._state = {
|
||||
"albums": {},
|
||||
"artists": {},
|
||||
|
|
Loading…
Reference in New Issue