mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-20 10:15:23 -04:00
Implement Disc folders (#679)
* Add disc subdirectories * Smoother recovery on broken config
This commit is contained in:
parent
527b52cae2
commit
22d6a9b137
9 changed files with 30 additions and 15 deletions
|
@ -1,4 +1,5 @@
|
|||
"""A config class that manages arguments between the config file and CLI."""
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
|
@ -15,7 +16,7 @@ logger = logging.getLogger("streamrip")
|
|||
APP_DIR = click.get_app_dir("streamrip")
|
||||
os.makedirs(APP_DIR, exist_ok=True)
|
||||
DEFAULT_CONFIG_PATH = os.path.join(APP_DIR, "config.toml")
|
||||
CURRENT_CONFIG_VERSION = "2.0.3"
|
||||
CURRENT_CONFIG_VERSION = "2.0.6"
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
|
@ -181,6 +182,8 @@ class DownloadsConfig:
|
|||
folder: str
|
||||
# Put Qobuz albums in a 'Qobuz' folder, Tidal albums in 'Tidal' etc.
|
||||
source_subdirectories: bool
|
||||
# Put tracks in an album with 2 or more discs into a subfolder named `Disc N`
|
||||
disc_subdirectories: bool
|
||||
# Download (and convert) tracks all at once, instead of sequentially.
|
||||
# If you are converting the tracks, or have fast internet, this will
|
||||
# substantially improve processing speed.
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
folder = ""
|
||||
# Put Qobuz albums in a 'Qobuz' folder, Tidal albums in 'Tidal' etc.
|
||||
source_subdirectories = false
|
||||
|
||||
# Put tracks in an album with 2 or more discs into a subfolder named `Disc N`
|
||||
disc_subdirectories = true
|
||||
# Download (and convert) tracks all at once, instead of sequentially.
|
||||
# If you are converting the tracks, or have fast internet, this will
|
||||
# substantially improve processing speed.
|
||||
|
@ -186,6 +187,6 @@ max_search_results = 100
|
|||
|
||||
[misc]
|
||||
# Metadata to identify this config file. Do not change.
|
||||
version = "2.0.3"
|
||||
version = "2.0.6"
|
||||
# Print a message if a new version of streamrip is available
|
||||
check_for_updates = true
|
||||
|
|
|
@ -148,11 +148,18 @@ class PendingTrack(Pending):
|
|||
|
||||
quality = self.config.session.get_source(source).quality
|
||||
downloadable = await self.client.get_downloadable(self.id, quality)
|
||||
|
||||
downloads_config = self.config.session.downloads
|
||||
if downloads_config.disc_subdirectories and self.album.disctotal > 1:
|
||||
folder = os.path.join(self.folder, f"Disc {meta.discnumber}")
|
||||
else:
|
||||
folder = self.folder
|
||||
|
||||
return Track(
|
||||
meta,
|
||||
downloadable,
|
||||
self.config,
|
||||
self.folder,
|
||||
folder,
|
||||
self.cover_path,
|
||||
self.db,
|
||||
)
|
||||
|
|
|
@ -101,7 +101,7 @@ class AlbumMetadata:
|
|||
if isinstance(_label, dict):
|
||||
_label = _label["name"]
|
||||
label = typed(_label or "", str)
|
||||
description = typed(resp.get("description", "") or None, str)
|
||||
description = typed(resp.get("description", ""), str)
|
||||
disctotal = typed(
|
||||
max(
|
||||
track.get("media_number", 1)
|
||||
|
|
|
@ -153,6 +153,8 @@ def rip(ctx, config_path, folder, no_db, quality, codec, no_progress, verbose):
|
|||
@coro
|
||||
async def url(ctx, urls):
|
||||
"""Download content from URLs."""
|
||||
if ctx.obj["config"] is None:
|
||||
return
|
||||
with ctx.obj["config"] as cfg:
|
||||
cfg: Config
|
||||
updates = cfg.session.misc.check_for_updates
|
||||
|
@ -237,7 +239,7 @@ def config():
|
|||
@click.pass_context
|
||||
def config_open(ctx, vim):
|
||||
"""Open the config file in a text editor."""
|
||||
config_path = ctx.obj["config"].path
|
||||
config_path = ctx.obj["config_path"]
|
||||
|
||||
console.print(f"Opening file at [bold cyan]{config_path}")
|
||||
if vim:
|
||||
|
|
Binary file not shown.
|
@ -43,6 +43,7 @@ def test_sample_config_data_fields(sample_config_data):
|
|||
downloads=DownloadsConfig(
|
||||
folder="test_folder",
|
||||
source_subdirectories=False,
|
||||
disc_subdirectories=True,
|
||||
concurrency=True,
|
||||
max_connections=6,
|
||||
requests_per_minute=60,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
folder = "test_folder"
|
||||
# Put Qobuz albums in a 'Qobuz' folder, Tidal albums in 'Tidal' etc.
|
||||
source_subdirectories = false
|
||||
disc_subdirectories = true
|
||||
|
||||
# Download (and convert) tracks all at once, instead of sequentially.
|
||||
# If you are converting the tracks, or have fast internet, this will
|
||||
|
@ -185,5 +186,5 @@ max_search_results = 100
|
|||
|
||||
[misc]
|
||||
# Metadata to identify this config file. Do not change.
|
||||
version = "2.0.3"
|
||||
version = "2.0.6"
|
||||
check_for_updates = true
|
||||
|
|
|
@ -19,7 +19,7 @@ def test_album_metadata_qobuz():
|
|||
assert info.explicit == False
|
||||
assert info.sampling_rate == 96
|
||||
assert info.bit_depth == 24
|
||||
assert info.booklets == None
|
||||
assert info.booklets is None
|
||||
|
||||
assert m.album == "Rumours"
|
||||
assert m.albumartist == "Fleetwood Mac"
|
||||
|
@ -29,19 +29,19 @@ def test_album_metadata_qobuz():
|
|||
assert not m.covers.empty()
|
||||
|
||||
assert m.albumcomposer == "Various Composers"
|
||||
assert m.comment == None
|
||||
assert m.compilation == None
|
||||
assert m.comment is None
|
||||
assert m.compilation is None
|
||||
assert (
|
||||
m.copyright
|
||||
== "© 1977 Warner Records Inc. ℗ 1977 Warner Records Inc. Marketed by Rhino Entertainment Company, A Warner Music Group Company."
|
||||
)
|
||||
assert m.date == "1977-02-04"
|
||||
assert m.description == None
|
||||
assert m.description == ""
|
||||
assert m.disctotal == 1
|
||||
assert m.encoder == None
|
||||
assert m.grouping == None
|
||||
assert m.lyrics == None
|
||||
assert m.purchase_date == None
|
||||
assert m.encoder is None
|
||||
assert m.grouping is None
|
||||
assert m.lyrics is None
|
||||
assert m.purchase_date is None
|
||||
assert m.tracktotal == 11
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue