Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Amperfy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@
5068D37F26A85C2D0006710D /* DownloadError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadError.swift; sourceTree = "<group>"; };
506B3A3823B4539D00E31F21 /* Amperfy v2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Amperfy v2.xcdatamodel"; sourceTree = "<group>"; };
506C314D2EE6D2100011A2C3 /* Amperfy v49.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Amperfy v49.xcdatamodel"; sourceTree = "<group>"; };
50B9C4D92EF0000100C0DEC0 /* Amperfy v50.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Amperfy v50.xcdatamodel"; sourceTree = "<group>"; };
5070ED2C2D46979A00EB2972 /* Amperfy v42.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Amperfy v42.xcdatamodel"; sourceTree = "<group>"; };
507148AB2B767FE200557904 /* ContextQueuePrevSectionHeader.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ContextQueuePrevSectionHeader.xib; sourceTree = "<group>"; };
507148AC2B767FE200557904 /* ContextQueuePrevSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextQueuePrevSectionHeader.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3516,6 +3517,7 @@
500BB49521CAAA2700D367CF /* Amperfy.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
50B9C4D92EF0000100C0DEC0 /* Amperfy v50.xcdatamodel */,
506C314D2EE6D2100011A2C3 /* Amperfy v49.xcdatamodel */,
5084F70C2ED9D87500D8D3DA /* Amperfy v48.xcdatamodel */,
507C9AD82E29905D001589F8 /* Amperfy v47.xcdatamodel */,
Expand Down Expand Up @@ -3566,7 +3568,7 @@
506B3A3823B4539D00E31F21 /* Amperfy v2.xcdatamodel */,
500BB49621CAAA2700D367CF /* Amperfy.xcdatamodel */,
);
currentVersion = 506C314D2EE6D2100011A2C3 /* Amperfy v49.xcdatamodel */;
currentVersion = 50B9C4D92EF0000100C0DEC0 /* Amperfy v50.xcdatamodel */;
path = Amperfy.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
2 changes: 2 additions & 0 deletions AmperfyKit/Api/Ampache/SongParserDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class SongParserDelegate: PlayableParserDelegate {
songBuffer?.genre = genre
genreIdToCreate = nil
}
case "composer":
songBuffer?.composer = buffer
case "song":
parsedCount += 1
parseNotifier?.notifyParsedObject(ofType: .song)
Expand Down
3 changes: 3 additions & 0 deletions AmperfyKit/Api/Subsonic/SsSongParserDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class SsSongParserDelegate: SsPlayableParserDelegate {
dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
songBuffer?.addedDate = dateFormatter.date(from: createdTag)
}
if let composer = attributeDict["composer"] {
songBuffer?.composer = composer
}
}

super.parser(
Expand Down
17 changes: 17 additions & 0 deletions AmperfyKit/Storage/EntityWrappers/Song.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ public class Song: AbstractPlayable, Identifyable {
}
}

public var composer: String? {
get {
guard let composer = managedObject.composer,
!composer.isEmpty else { return nil }
return composer
}
set {
let composer = newValue?.trimmingCharacters(in: .whitespacesAndNewlines)
managedObject.composer = composer?.isEmpty == true ? nil : composer
}
}

public var isOrphaned: Bool {
guard let album = album else { return true }
return album.isOrphaned
Expand Down Expand Up @@ -117,6 +129,8 @@ public class Song: AbstractPlayable, Identifyable {
info += "album: \(albumName),"
let genreName = genre?.name ?? "-"
info += " genre: \(genreName),"
let composerInfo = composer ?? "-"
info += " composer: \(composerInfo),"

info += " id: \(id),"
info += " track: \(track),"
Expand Down Expand Up @@ -149,6 +163,9 @@ public class Song: AbstractPlayable, Identifyable {
if let genre = genre {
infoContent.append("Genre: \(genre.name)")
}
if let composer = composer {
infoContent.append("Composer: \(composer)")
}
if details.isShowDetailedInfo {
if bitrate > 0 {
infoContent.append("Bitrate: \(bitrate)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Amperfy v49.xcdatamodel</string>
<string>Amperfy v50.xcdatamodel</string>
</dict>
</plist>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum CoreDataMigrationVersion: String, CaseIterable {
case v48 = "Amperfy v48" // Account support: add account (url + user)
case v49 =
"Amperfy v49" // Remove PlayableFile and Artwork data (they were already deprecated); Account: add apiType
case v50 = "Amperfy v50" // Add composer metadata for songs

// MARK: - Current

Expand Down Expand Up @@ -172,6 +173,8 @@ enum CoreDataMigrationVersion: String, CaseIterable {
case .v48:
return .v49
case .v49:
return .v50
case .v50:
return nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extension SongMO {
@NSManaged
public var addedDate: Date?
@NSManaged
public var composer: String?
@NSManaged
public var album: AlbumMO?
@NSManaged
public var artist: ArtistMO?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class PlaylistSongsParserTest: AbstractAmpacheTest {
XCTAssertEqual(song.id, "56")
XCTAssertEqual(song.title, "Black&BlueSmoke")
XCTAssertEqual(song.rating, 4)
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "2")
Expand Down Expand Up @@ -182,6 +183,7 @@ class PlaylistSongsParserTest: AbstractAmpacheTest {
XCTAssertEqual(song.id, "107")
XCTAssertEqual(song.title, "Arrest Me")
XCTAssertEqual(song.rating, 1)
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "20")
Expand Down Expand Up @@ -217,6 +219,7 @@ class PlaylistSongsParserTest: AbstractAmpacheTest {
XCTAssertEqual(song.id, "115")
XCTAssertEqual(song.title, "Are we going Crazy")
XCTAssertEqual(song.rating, 0)
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "27")
Expand Down Expand Up @@ -248,6 +251,7 @@ class PlaylistSongsParserTest: AbstractAmpacheTest {
XCTAssertEqual(song.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.id, "85")
XCTAssertEqual(song.title, "Beq Ultra Fat")
XCTAssertEqual(song.composer, "Jeffrey Melton")
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "14")
Expand Down
4 changes: 4 additions & 0 deletions AmperfyKitTests/Cases/API/Ampache/SongParserTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SongParserTest: AbstractAmpacheTest {
XCTAssertEqual(song.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.id, "115")
XCTAssertEqual(song.title, "Are we going Crazy")
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "27")
Expand Down Expand Up @@ -92,6 +93,7 @@ class SongParserTest: AbstractAmpacheTest {
XCTAssertEqual(song.id, "107")
XCTAssertEqual(song.title, "Arrest Me")
XCTAssertEqual(song.rating, 2)
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "20")
Expand Down Expand Up @@ -131,6 +133,7 @@ class SongParserTest: AbstractAmpacheTest {
XCTAssertEqual(song.id, "85")
XCTAssertEqual(song.title, "Beq Ultra Fat")
XCTAssertEqual(song.rating, 1)
XCTAssertEqual(song.composer, "Jeffrey Melton")
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "14")
Expand Down Expand Up @@ -166,6 +169,7 @@ class SongParserTest: AbstractAmpacheTest {
XCTAssertEqual(song.id, "56")
XCTAssertEqual(song.title, "Black&BlueSmoke")
XCTAssertEqual(song.rating, 0)
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "2") // Artist not pre created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
status="ok" version="1.8.0">

<album id="11053" name="High Voltage" coverArt="al-11053" songCount="8" created="2004-11-27T20:23:32" duration="2414" artist="AC/DC" artistId="5432">
<song id="71463" parent="71381" title="The Jack" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-08T23:36:11" duration="352" bitRate="128" size="5624132" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - The Jack.mp3" albumId="11053" artistId="5432" starred="2024-07-21T20:02:24.995815902Z" type="music"/>
<song id="71463" parent="71381" title="The Jack" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-08T23:36:11" duration="352" bitRate="128" size="5624132" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - The Jack.mp3" albumId="11053" artistId="5432" composer="Angus Young" starred="2024-07-21T20:02:24.995815902Z" type="music"/>
<song id="71464" parent="71381" title="Tnt" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-08T23:36:11" duration="215" bitRate="128" size="3433798" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - TNT.mp3" albumId="11053" artistId="5432" type="music"/>
<song id="71458" parent="71381" title="It&apos;s A Long Way To The Top" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-27T20:23:32" duration="315" bitRate="128" year="1976" genre="Rock" size="5037357" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - It&apos;s a long way to the top if you wanna rock &apos;n &apos;roll.mp3" albumId="11053" artistId="5432" type="music" userRating="1" starred="2022-09-12T13:08:58Z">
<replayGain trackGain="0.1" albumGain="2.3" trackPeak="9.1" albumPeak="0" baseGain="4.1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
artist="Brad Sucks" isDir="false" coverArt="655" created="2008-04-10T07:10:32" duration="159"
bitRate="202" track="1" year="2003" size="4060113" suffix="mp3" contentType="audio/mpeg" isVideo="false"
path="Brad Sucks/I Don&apos;t Know What I&apos;m Doing/01 - Making Me Nervous.mp3" albumId="58"
artistId="45" type="music" userRating="2"/>
artistId="45" composer="Brad Turcotte" type="music" userRating="2"/>
<entry id="823" parent="784" title="Piano escena" album="BSO Sebastian" artist="PeerGynt Lobogris"
isDir="false" coverArt="784" created="2009-01-14T22:26:29" duration="129" bitRate="170" track="8"
year="2008" genre="Blues" size="2799954" suffix="mp3" contentType="audio/mpeg" isVideo="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class SsPlaylistSongsParserTest: AbstractSsParserTest {
XCTAssertEqual(song.id, "657")
XCTAssertEqual(song.title, "Making Me Nervous")
XCTAssertEqual(song.rating, 2)
XCTAssertEqual(song.composer, "Brad Turcotte")
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "45")
Expand Down Expand Up @@ -160,6 +161,7 @@ class SsPlaylistSongsParserTest: AbstractSsParserTest {
XCTAssertEqual(song.id, "748")
XCTAssertEqual(song.title, "Stories from Emona II")
XCTAssertEqual(song.rating, 0)
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "51") // Artist not pre created
Expand Down Expand Up @@ -189,6 +191,7 @@ class SsPlaylistSongsParserTest: AbstractSsParserTest {
XCTAssertEqual(song.id, "805")
XCTAssertEqual(song.title, "Bajo siete lunas (intro)")
XCTAssertEqual(song.rating, 1)
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "54")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SsSongExample1ParserTest: AbstractSsParserTest {
XCTAssertEqual(song.id, "71463")
XCTAssertEqual(song.title, "The Jack")
XCTAssertEqual(song.rating, 0)
XCTAssertEqual(song.composer, "Angus Young")
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "5432")
Expand Down Expand Up @@ -99,6 +100,7 @@ class SsSongExample1ParserTest: AbstractSsParserTest {
XCTAssertEqual(song.id, "71458")
XCTAssertEqual(song.title, "It's A Long Way To The Top")
XCTAssertEqual(song.rating, 1)
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "5432")
Expand Down Expand Up @@ -140,6 +142,7 @@ class SsSongExample1ParserTest: AbstractSsParserTest {
XCTAssertEqual(song.id, "71462")
XCTAssertEqual(song.rating, 5)
XCTAssertEqual(song.title, "She's Got Balls")
XCTAssertNil(song.composer)
XCTAssertEqual(song.artist?.account?.serverHash, TestAccountInfo.test1ServerHash)
XCTAssertEqual(song.artist?.account?.userHash, TestAccountInfo.test1UserHash)
XCTAssertEqual(song.artist?.id, "5432")
Expand Down
12 changes: 12 additions & 0 deletions AmperfyKitTests/Cases/Storage/ManagedObjects/SongTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SongTest: XCTestCase {
XCTAssertEqual(song.title, "Unknown Title")
XCTAssertEqual(song.track, 0)
XCTAssertEqual(song.url, nil)
XCTAssertNil(song.composer)
XCTAssertEqual(song.album, nil)
XCTAssertEqual(song.artist, nil)
XCTAssertNil(song.addedDate)
Expand Down Expand Up @@ -121,6 +122,17 @@ class SongTest: XCTestCase {
XCTAssertEqual(songFetched.url, testUrl)
}

func testComposer() {
testSong.composer = " Florence Price "
XCTAssertEqual(testSong.composer, "Florence Price")
library.saveContext()
guard let songFetched = library.getSong(for: account, id: testId) else { XCTFail(); return }
XCTAssertEqual(songFetched.composer, "Florence Price")

songFetched.composer = ""
XCTAssertNil(songFetched.composer)
}

func testArtworkAndImage() {
let testData = UIImage.getGeneratedArtwork(theme: .blue, artworkType: .song).pngData()!
let relFilePath = URL(string: "testArtwork")!
Expand Down