MusicMatchModel

final class MusicMatchModel : ObservableObject, @unchecked Sendable

The model for MusicMatchView

  • The status of matching songs between Kodi and Music

    Declaration

    Swift

    @Published
    var status: Status { get set }
  • Matching progress values

    Declaration

    Swift

    @Published
    var progress: Progress { get set }
  • Setting which ratings will be used

    Declaration

    Swift

    @AppStorage
    var ratingAction: MusicMatchModel.RatingAction { get set }
  • Setting which playcount will be used

    Declaration

    Swift

    @AppStorage
    var playcountAction: MusicMatchModel.PlaycountAction { get set }
  • 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

Get Kodi and Music songs

  • getKodiSongs() Asynchronous

    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

  • matchSongs() Asynchronous

    Match songs between Kodi and Music

    Declaration

    Swift

    func matchSongs() async

Synchronise songs

  • syncAllSongs() Asynchronous

    Sync all songs between Kodi and Music

    Declaration

    Swift

    func syncAllSongs() async
  • syncSong(song:) Asynchronous

    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

  • setMusicMatchCache() Asynchronous

    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