mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-18 00:54:50 -04:00
Added more colors
This commit is contained in:
parent
129f3d8fe6
commit
c3da93ed08
5 changed files with 21 additions and 17 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -18,7 +18,6 @@ __pycache__/
|
|||
*.db
|
||||
*.sh
|
||||
|
||||
*.txt
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
|
|
|
@ -9,6 +9,7 @@ import click
|
|||
from .config import Config
|
||||
from .constants import CACHE_DIR, CONFIG_DIR, CONFIG_PATH
|
||||
from .core import MusicDL
|
||||
from .utils import init_log
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
config = Config(CONFIG_PATH)
|
||||
|
@ -21,12 +22,7 @@ if not os.path.isdir(CACHE_DIR):
|
|||
config = Config(CONFIG_PATH)
|
||||
|
||||
|
||||
def _get_config(ctx):
|
||||
config.update_from_cli(**ctx.params)
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.option("--debug", default=False, is_flag=True, help="Enable debug logging")
|
||||
@click.option(
|
||||
"--flush-cache",
|
||||
metavar="PATH",
|
||||
|
@ -48,7 +44,6 @@ def cli(ctx, **kwargs):
|
|||
|
||||
> download discography with given filters
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@click.command(name="dl")
|
||||
|
@ -59,6 +54,7 @@ def cli(ctx, **kwargs):
|
|||
@click.option("-c", "--convert", metavar="CODEC")
|
||||
@click.option("-sr", "--sampling-rate", metavar="INT")
|
||||
@click.option("-bd", "--bit-depth", metavar="INT")
|
||||
@click.option("--debug", default=False, is_flag=True, help="Enable debug logging")
|
||||
@click.argument("items", nargs=-1)
|
||||
@click.pass_context
|
||||
def download(ctx, **kwargs):
|
||||
|
@ -82,7 +78,10 @@ def download(ctx, **kwargs):
|
|||
|
||||
* Tidal (album, artist, track, playlist)
|
||||
"""
|
||||
config = _get_config(ctx)
|
||||
if kwargs.get("debug"):
|
||||
init_log()
|
||||
|
||||
config.update_from_cli(**ctx.params)
|
||||
core = MusicDL(config, database=list() if kwargs["no_db"] else None)
|
||||
for item in kwargs["items"]:
|
||||
try:
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import os
|
||||
|
||||
import appdirs
|
||||
import click
|
||||
import mutagen.id3 as id3
|
||||
|
||||
APPNAME = "qobuz-dl"
|
||||
APPNAME = "music-dl"
|
||||
|
||||
CACHE_DIR = appdirs.user_cache_dir(APPNAME)
|
||||
CONFIG_DIR = appdirs.user_config_dir(APPNAME)
|
||||
CACHE_DIR = click.get_app_dir(APPNAME)
|
||||
CONFIG_DIR = click.get_app_dir(APPNAME)
|
||||
CONFIG_PATH = os.path.join(CONFIG_DIR, "config.yaml")
|
||||
LOG_DIR = appdirs.user_config_dir(APPNAME)
|
||||
DB_PATH = os.path.join(LOG_DIR, "qobuz-dl.db")
|
||||
LOG_DIR = click.get_app_dir(APPNAME)
|
||||
DB_PATH = os.path.join(LOG_DIR, "music-dl.db")
|
||||
|
||||
AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0"
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ class MusicDL(list):
|
|||
logger.debug("Arguments from config: %s", arguments)
|
||||
|
||||
item.load_meta()
|
||||
click.secho(f"Downloading {item!s}")
|
||||
click.secho(f"Downloading {item!s}", fg="bright_green")
|
||||
item.download(**arguments)
|
||||
|
||||
def convert_all(self, codec, **kwargs):
|
||||
|
|
|
@ -164,14 +164,15 @@ class Track:
|
|||
self.__is_downloaded = True
|
||||
self.__is_tagged = True
|
||||
click.secho(
|
||||
f"{self['title']} already logged in database, skipping.", fg="green"
|
||||
f"{self['title']} already logged in database, skipping.",
|
||||
fg="magenta",
|
||||
)
|
||||
return
|
||||
|
||||
if os.path.isfile(self.format_final_path()):
|
||||
self.__is_downloaded = True
|
||||
self.__is_tagged = True
|
||||
click.secho(f"Track already downloaded: {self.final_path}", fg="green")
|
||||
click.secho(f"Track already downloaded: {self.final_path}", fg="magenta")
|
||||
return False
|
||||
|
||||
if hasattr(self, "cover_url"):
|
||||
|
@ -396,6 +397,11 @@ class Track:
|
|||
if not hasattr(self, "final_path"):
|
||||
self.format_final_path()
|
||||
|
||||
if not os.path.isfile(self.final_path):
|
||||
logger.debug(f"File {self.final_path} does not exist. Skipping conversion.")
|
||||
click.secho(f"{self!s} does not exist. Skipping conversion.", fg="red")
|
||||
return
|
||||
|
||||
engine = CONV_CLASS[codec.upper()](
|
||||
filename=self.final_path,
|
||||
sampling_rate=kwargs.get("sampling_rate"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue