MusicMatchModel

final class MusicMatchModel: ObservableObject, @unchecked Sendable

The model for MusicMatchView

  • Undocumented

    Declaration

    Swift

    init(kodi: KodiConnector)
  • The status of matching songs between Kodi and Music

    Declaration

    Swift

    var status: Status = .none
  • Matching progress values

    Declaration

    Swift

    var progress: Progress = .init(total: 0, current: 0)
  • Setting which ratings will be used

    Declaration

    Swift

    var ratingAction: MusicMatchModel.RatingAction = .useKodiRating
  • Setting which playcount will be used

    Declaration

    Swift

    var playcountAction: MusicMatchModel.PlaycountAction = .useKodiPlaycount
  • The items to match

    Declaration

    Swift

    var musicMatchItems: [MusicMatchModel.Item] = []
  • The optional cache of the Music Match

    Declaration

    Swift

    var cache: [MusicMatchModel.Item]?
  • The MusicBridge class

    Declaration

    Swift

    let musicBridge = MusicBridge()
  • The current host

    Declaration

    Swift

    let kodi: KodiConnector

Get Kodi and Music songs

  • Get all songs from Kodi

    Declaration

    Swift

    private func getKodiSongs() async
  • Get all songs from Music

    Declaration

    Swift

    private func getMusicSongs() -> [ITLibMediaItem]

    Return Value

    All songs from the Music database

Match songs

  • Match songs between Kodi and Music

    Declaration

    Swift

    func matchSongs() async

Synchronise songs

  • Sync all songs between Kodi and Music

    Declaration

    Swift

    func syncAllSongs() async
  • Sync one song between Kodi and Music

    Declaration

    Swift

    func syncSong(song: MusicMatchModel.Item) async

    Parameters

    item

    The song to sync as Item

Helpers

  • Calculate the sync values

    Declaration

    Swift

    func calculateSyncValues(item: MusicMatchModel.Item) -> MusicMatchModel.Values

    Parameters

    item

    The Music Match Item

    Return Value

    The sync values

  • Calculate the sync rating

    Declaration

    Swift

    private func calculateRatingValue(item: MusicMatchModel.Item) -> Int

    Parameters

    item

    The Music Match Item

    Return Value

    The rating

  • Set the progress values for the MusicMatchView

    Declaration

    Swift

    func setProgress(total: Double? = nil, current: Double? = nil)

    Parameters

    total

    The total items

    current

    The current item

  • Store the Match struct in cache

    Declaration

    Swift

    func setMusicMatchCache() async
  • The status of song matching

    See more

    Declaration

    Swift

    enum Status: String
  • Which rating to use for syncing

    See more

    Declaration

    Swift

    enum RatingAction: String, CaseIterable
  • Which playcount to use for syncing

    See more

    Declaration

    Swift

    enum PlaycountAction: String, CaseIterable
  • A Music Match Item

    See more

    Declaration

    Swift

    struct Item: Codable, Identifiable, Equatable
  • The sync values of an Item (Kodi or Music song)

    See more

    Declaration

    Swift

    struct Values: Codable, Equatable
  • Progress values of matching

    See more

    Declaration

    Swift

    struct Progress