1 // Collect and manage the available and enabled source
4 // List of sources enabled for the crurent platform
5 var availableSources: [String: Source] = [
6 "apple_music": AppleMusicSource(),
7 "spotify": SpotifySource()
10 // Iterate over the sources until we find a track or run out of sources
11 var currentTrack: Track? {
12 for source in enabledSources {
13 if let currentTrack = source.currentTrack {
21 // Return the list of enabled sources based on the configuration
22 var enabledSources: [Source] {
24 // Checks the config and returns an array of sources based on the
25 // enabled and available ones
27 var sources = [Source]()
29 if let sourceNames = Configuration.shared["enabled_sources"] as? [String] {
30 for sourceName in sourceNames {
31 if let source = availableSources[sourceName] {
32 sources.append(source)
40 // Given a source name, it will enable it and add it to the enabled sources config
41 func enable(sourceName: String) {
44 // Given a source name, it will remove it from the enabled sources config
45 func disable(sourceName: String) {
48 // Given a source name, it removes any stored configuration and disables it
49 func reset(sourceName: String) {