mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-28 23:08:59 +02:00
fix(extensions): preserve explicit track metadata
This commit is contained in:
@@ -73,7 +73,8 @@ function track(id) {
|
||||
genre: "Pop",
|
||||
composer: "Composer",
|
||||
audioQuality: "FLAC 24-bit",
|
||||
audioModes: "DOLBY_ATMOS"
|
||||
audioModes: "DOLBY_ATMOS",
|
||||
explicit: true
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ func normalizeExtensionTrackMetadataMap(
|
||||
"composer": track.Composer,
|
||||
"audio_quality": track.AudioQuality,
|
||||
"audio_modes": track.AudioModes,
|
||||
"explicit": track.Explicit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,6 +792,7 @@ func CustomSearchWithExtensionJSONWithRequestID(extensionID, query string, optio
|
||||
"composer": track.Composer,
|
||||
"audio_quality": track.AudioQuality,
|
||||
"audio_modes": track.AudioModes,
|
||||
"explicit": track.Explicit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,6 +858,7 @@ func HandleURLWithExtensionJSON(url string) (string, error) {
|
||||
"isrc": result.Track.ISRC,
|
||||
"provider_id": result.Track.ProviderID,
|
||||
"composer": result.Track.Composer,
|
||||
"explicit": result.Track.Explicit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,6 +884,7 @@ func HandleURLWithExtensionJSON(url string) (string, error) {
|
||||
"item_type": track.ItemType,
|
||||
"album_type": track.AlbumType,
|
||||
"composer": track.Composer,
|
||||
"explicit": track.Explicit,
|
||||
}
|
||||
}
|
||||
response["tracks"] = tracks
|
||||
@@ -978,6 +982,7 @@ func HandleURLWithExtensionJSON(url string) (string, error) {
|
||||
"provider_id": track.ProviderID,
|
||||
"spotify_id": track.SpotifyID,
|
||||
"composer": track.Composer,
|
||||
"explicit": track.Explicit,
|
||||
}
|
||||
}
|
||||
artistResponse["top_tracks"] = topTracks
|
||||
|
||||
@@ -69,6 +69,41 @@ func TestGetProviderMetadataPrefersEnabledDeezerExtension(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtensionTrackExportsPreserveExplicitFlag(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := InitExtensionSystem(filepath.Join(dir, "extensions"), filepath.Join(dir, "data")); err != nil {
|
||||
t.Fatalf("InitExtensionSystem: %v", err)
|
||||
}
|
||||
|
||||
ext := newTestLoadedExtension(t, ExtensionTypeMetadataProvider)
|
||||
manager := getExtensionManager()
|
||||
manager.mu.Lock()
|
||||
manager.extensions = map[string]*loadedExtension{ext.ID: ext}
|
||||
manager.mu.Unlock()
|
||||
defer CleanupExtensions()
|
||||
|
||||
assertExplicit := func(name, jsonText string, err error) {
|
||||
t.Helper()
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
if !strings.Contains(jsonText, `"explicit":true`) {
|
||||
t.Fatalf("%s dropped explicit flag: %s", name, jsonText)
|
||||
}
|
||||
}
|
||||
|
||||
jsonText, err := CustomSearchWithExtensionJSON(ext.ID, "needle", `{"filter":"tracks"}`)
|
||||
assertExplicit("custom search", jsonText, err)
|
||||
|
||||
for _, resourceType := range []string{"track", "album", "playlist", "artist"} {
|
||||
jsonText, err = GetProviderMetadataJSON(ext.ID, resourceType, resourceType+"-1")
|
||||
assertExplicit("provider metadata "+resourceType, jsonText, err)
|
||||
}
|
||||
|
||||
jsonText, err = HandleURLWithExtensionJSON("https://example.test/track/1")
|
||||
assertExplicit("URL handler", jsonText, err)
|
||||
}
|
||||
|
||||
func TestExportsJSONWrappersAndExtensionManagerSurface(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
dataDir := filepath.Join(dir, "data")
|
||||
|
||||
@@ -409,6 +409,7 @@ class _ArtistScreenState extends ConsumerState<ArtistScreen>
|
||||
composer: data['composer']?.toString(),
|
||||
source: data['provider_id']?.toString() ?? widget.extensionId,
|
||||
previewUrl: data['preview_url']?.toString(),
|
||||
explicit: parseExplicitFlag(data['explicit']),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1317,6 +1317,7 @@ class _ExtensionArtistScreenState extends ConsumerState<ExtensionArtistScreen>
|
||||
composer: base.composer,
|
||||
source: (data['provider_id'] ?? widget.extensionId).toString(),
|
||||
previewUrl: base.previewUrl,
|
||||
explicit: base.explicit,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,22 @@ void main() {
|
||||
});
|
||||
|
||||
group('Track', () {
|
||||
test('preserves a generic extension explicit flag', () {
|
||||
final track = Track.fromBackendMap({
|
||||
'id': 'extension-track-1',
|
||||
'name': 'Explicit Song',
|
||||
'artists': 'Artist',
|
||||
'album_name': 'Album',
|
||||
'duration_ms': 180000,
|
||||
'provider_id': 'extension.example',
|
||||
'explicit': true,
|
||||
});
|
||||
|
||||
expect(track.source, 'extension.example');
|
||||
expect(track.explicit, isTrue);
|
||||
expect(track.isExplicit, isTrue);
|
||||
});
|
||||
|
||||
test('exposes collection, source, and quality flags', () {
|
||||
const album = Track(
|
||||
id: 'album-1',
|
||||
|
||||
Reference in New Issue
Block a user