fix: force IPv4 in worker, count real Qobuz files, flatten nested output
- worker had no IPv6 route -> Qobuz CDN (dual-stack) failed ~half the tracks with 'Network is unreachable'; disable IPv6 in the container (IPv4 only). - StreamripClient counted metadata tracks (always full) -> a partial download falsely imported; now count the actual files written (short count -> needs_attention). - streamrip writes into a nested 'Artist - Album [..]/' folder the tagger never saw; flatten audio files up into the album dir so tagging/organization runs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
from lyra_worker.adapters._streamrip import _flatten_audio
|
||||
|
||||
|
||||
def test_flatten_moves_nested_audio_up_and_counts(tmp_path):
|
||||
nested = tmp_path / "John Mayer - Continuum (2006) [FLAC] [24B-96kHz]"
|
||||
nested.mkdir()
|
||||
(nested / "01. Waiting.flac").write_bytes(b"x")
|
||||
(nested / "02. Belief.flac").write_bytes(b"x")
|
||||
(nested / "cover.jpg").write_bytes(b"x") # non-audio stays behind
|
||||
|
||||
count = _flatten_audio(str(tmp_path))
|
||||
|
||||
assert count == 2
|
||||
assert (tmp_path / "01. Waiting.flac").exists()
|
||||
assert (tmp_path / "02. Belief.flac").exists()
|
||||
assert not (nested / "01. Waiting.flac").exists() # audio moved out of the nested folder
|
||||
|
||||
|
||||
def test_flatten_counts_flat_files_and_ignores_non_audio(tmp_path):
|
||||
(tmp_path / "a.flac").write_bytes(b"x")
|
||||
(tmp_path / "b.mp3").write_bytes(b"x")
|
||||
(tmp_path / "notes.txt").write_bytes(b"x")
|
||||
assert _flatten_audio(str(tmp_path)) == 2
|
||||
|
||||
|
||||
def test_flatten_partial_download_reports_true_short_count(tmp_path):
|
||||
# streamrip continues past per-track failures; only 3 of an album's tracks landed.
|
||||
nested = tmp_path / "sub"
|
||||
nested.mkdir()
|
||||
for n in ["01.flac", "02.flac", "03.flac"]:
|
||||
(nested / n).write_bytes(b"x")
|
||||
assert _flatten_audio(str(tmp_path)) == 3 # not the album's metadata count
|
||||
assert not nested.exists() # emptied subfolder removed
|
||||
Reference in New Issue
Block a user