fix(import): keep the values a service set on exported tracks and export a song as a song

This commit is contained in:
imSp4rky
2026-12-02 17:19:10 -07:00
parent 95d36378f4
commit 0c93f1dc63
6 changed files with 122 additions and 18 deletions
+16 -1
View File
@@ -22,7 +22,7 @@ from unshackle.core.drm.clearkey import ClearKey
from unshackle.core.drm.clearkey_cenc import ClearKeyCENC
from unshackle.core.export_writer import ExportWriter
from unshackle.core.import_service import ImportService
from unshackle.core.titles import Movie
from unshackle.core.titles import Album, Movie, Song
from unshackle.core.tracks import Audio, Chapter, Subtitle, Video
from unshackle.core.wire import drm_from_dict
@@ -570,3 +570,18 @@ def test_a_title_with_no_record_logs_that_nothing_was_exported(
writer.log_title(second)
assert caplog.messages == ["Exported nothing for 'Example Movie' (2024)"]
def test_a_song_stays_a_song_of_an_album_through_export_and_import(tmp_path: Path) -> None:
writer = make_writer(tmp_path)
title = Song(
id_="song-1", service=StubService, name="Example Song", artist="Example Artist", album="Example Album", track=4
)
title.tracks.add(make_title().tracks.audio[0])
writer.record(title, title.tracks.audio[0])
titles = ImportService(import_ctx(), "EXAMPLE", "song-1", str(written(writer))).get_titles()
assert isinstance(titles, Album)
assert [(type(t).__name__, t.artist, t.album, t.track) for t in titles] == [
("Song", "Example Artist", "Example Album", 4)
]