diff --git a/streamrip/bases.py b/streamrip/bases.py index f532985..b19fb6c 100644 --- a/streamrip/bases.py +++ b/streamrip/bases.py @@ -865,7 +865,7 @@ class Tracklist(list): :param codec: :param kwargs: """ - if (sr := kwargs.get("sampling_rate")) : + if sr := kwargs.get("sampling_rate"): if sr < 44100: logger.warning( "Sampling rate %d is lower than 44.1kHz." diff --git a/streamrip/cli.py b/streamrip/cli.py index 41e7ba6..1131e6d 100644 --- a/streamrip/cli.py +++ b/streamrip/cli.py @@ -36,7 +36,7 @@ if not os.path.isdir(CACHE_DIR): @click.option("-t", "--text", metavar="PATH") @click.option("-nd", "--no-db", is_flag=True) @click.option("--debug", is_flag=True) -@click.version_option(prog_name='streamrip') +@click.version_option(prog_name="streamrip") @click.pass_context def cli(ctx, **kwargs): """Streamrip: The all-in-one Qobuz, Tidal, SoundCloud, and Deezer music downloader. diff --git a/streamrip/clients.py b/streamrip/clients.py index 1a7c17a..9d042a3 100644 --- a/streamrip/clients.py +++ b/streamrip/clients.py @@ -643,7 +643,7 @@ class TidalClient(Client): click.launch(login_link) start = time.time() - elapsed = 0 + elapsed = 0.0 while elapsed < 600: # 5 mins to login elapsed = time.time() - start status = self._check_auth_status() diff --git a/streamrip/config.py b/streamrip/config.py index 88fb273..4ecc110 100644 --- a/streamrip/config.py +++ b/streamrip/config.py @@ -25,22 +25,14 @@ yaml = YAML() logger = logging.getLogger(__name__) -# ---------- Utilities ------------- -def _set_to_none(d: dict): - for k, v in d.items(): - if isinstance(v, dict): - _set_to_none(v) - else: - d[k] = None - - class Config: """Config class that handles command line args and config files. Usage: - >>> config = Config('test_config.yaml') - >>> config.defaults['qobuz']['quality'] - 3 + + >>> config = Config('test_config.yaml') + >>> config.defaults['qobuz']['quality'] + 3 If test_config was already initialized with values, this will load them into `config`. Otherwise, a new config file is created with the default @@ -204,7 +196,7 @@ class Config: if source == "tidal": return self.tidal_creds if source == "deezer" or source == "soundcloud": - return dict() + return {} raise InvalidSourceError(source) @@ -348,6 +340,7 @@ class ConfigDocumentation: # ------------- ~~ Experimental ~~ ----------------- # + def load_yaml(path: str): """Load a streamrip config YAML file. @@ -374,33 +367,33 @@ def load_yaml(path: str): level += 1 chars.prev() - if (c := next(chars)) == '#': + if (c := next(chars)) == "#": # is a comment continue - elif c == '-': + elif c == "-": # is an item in a list next(chars) val_l = list(chars) level += 2 # it is a child of the previous key - item_type = 'list' + item_type = "list" else: # undo char read chars.prev() if not val_l: - while (c := next(chars)) != ':': + while (c := next(chars)) != ":": key_l.append(c) - val_l = list(''.join(chars).strip()) + val_l = list("".join(chars).strip()) if val_l: - val = ''.join(val_l) + val = "".join(val_l) else: # start of a section - item_type = 'dict' + item_type = "dict" val = type_dict[item_type]() - key = ''.join(key_l) + key = "".join(key_l) if level == 0: settings[key] = val elif level == 2: @@ -424,7 +417,7 @@ class StringWalker: :param s: :type s: str """ - self.__val = s.replace('\n', '') + self.__val = s.replace("\n", "") self.__pos = 0 def __next__(self) -> str: diff --git a/streamrip/constants.py b/streamrip/constants.py index 3fac0ce..9099ca6 100644 --- a/streamrip/constants.py +++ b/streamrip/constants.py @@ -70,6 +70,7 @@ __MP4_KEYS = ( "disk", None, None, + None, ) __MP3_KEYS = ( @@ -93,6 +94,7 @@ __MP3_KEYS = ( id3.TPOS, None, None, + None, ) __METADATA_TYPES = ( @@ -116,6 +118,7 @@ __METADATA_TYPES = ( "discnumber", "tracktotal", "disctotal", + "date", ) diff --git a/streamrip/utils.py b/streamrip/utils.py index 947bcd4..ebcc135 100644 --- a/streamrip/utils.py +++ b/streamrip/utils.py @@ -324,11 +324,9 @@ def get_container(quality: int, source: str) -> str: :rtype: str """ if quality >= 2: - container = "FLAC" - else: - if source == "tidal": - container = "AAC" - else: - container = "MP3" + return "FLAC" - return container + if source == "tidal": + return "AAC" + + return "MP3"