mirror of https://github.com/Nezreka/SoulSync.git
#915: redownload pulls full album_data from the primary source for iTunes/Deezer too
Second leak of the same class: redownload_start built full album_data (release_date/album_type/
total_tracks) only in the Spotify branch. The iTunes and Deezer branches set just track/disc number
and left album_data lean ({'name': ...}), so single-track redownloads on those sources dropped the
$year — same symptom as #915 in the add/download path.
Fix: both branches now fetch the album via get_album_for_source (cached, source-aware) and build
album_data through the shared _album_data_from_source helper, mirroring the Spotify branch. Falls
back to the lean default if the fetch returns nothing (no regression). get_album is cached on both
iTunes and Deezer, so no extra API cost.
Tests: _album_data_from_source (full build, image-url fallback, defaults). 694 library+downloads
tests green.
pull/919/head
parent
2b17ed8451
commit
d4e80fdaa0
@ -0,0 +1,38 @@
|
||||
"""Redownload builds full album_data from the primary source (#915).
|
||||
|
||||
iTunes/Deezer single-track redownloads used to carry a lean album_data ({'name': ...}),
|
||||
dropping the $year folder. _album_data_from_source mirrors the Spotify branch so the real
|
||||
release_date / album_type / total_tracks come through.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from core.library.redownload import _album_data_from_source
|
||||
|
||||
|
||||
def test_builds_full_album_data_from_source():
|
||||
full = {'id': 'it-1', 'name': 'Big OST', 'release_date': '2024-04-17',
|
||||
'album_type': 'album', 'total_tracks': 70, 'image_url': 'http://x/cover.jpg'}
|
||||
out = _album_data_from_source(full, 'it-1', 'fallback')
|
||||
assert out['release_date'] == '2024-04-17' # real date, not YYYY-01-01
|
||||
assert out['album_type'] == 'album'
|
||||
assert out['total_tracks'] == 70
|
||||
assert out['id'] == 'it-1'
|
||||
assert out['name'] == 'Big OST'
|
||||
assert out['image_url'] == 'http://x/cover.jpg'
|
||||
|
||||
|
||||
def test_image_url_falls_back_to_images_array():
|
||||
full = {'name': 'A', 'release_date': '2020-01-01', 'images': [{'url': 'http://x/img.jpg'}]}
|
||||
out = _album_data_from_source(full, 'a1', 'fb')
|
||||
assert out['image_url'] == 'http://x/img.jpg'
|
||||
|
||||
|
||||
def test_defaults_when_fields_missing():
|
||||
out = _album_data_from_source({}, 'a1', 'Fallback Album')
|
||||
assert out['id'] == 'a1' # falls back to the queried id
|
||||
assert out['name'] == 'Fallback Album'
|
||||
assert out['album_type'] == 'album' # default
|
||||
assert out['total_tracks'] == 0
|
||||
assert out['release_date'] == ''
|
||||
assert out['image_url'] == ''
|
||||
Loading…
Reference in new issue