mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-20 10:15:23 -04:00
Misc changes
Formatting, remove extra functions, documentation
This commit is contained in:
parent
0966263556
commit
f93a018163
6 changed files with 26 additions and 32 deletions
|
@ -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."
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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",
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue