Skip to content

Commit

Permalink
chore: update some comments and add missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
angristan committed Aug 26, 2021
1 parent f1ca692 commit 77e867f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -53,7 +53,7 @@ Fill `SPOTIFY_API_TOKEN` in `firstfm/Config/Secrets.xcconfig`.
The last.fm API does not provide artworks [anymore](https://stackoverflow.com/a/59529682/6945353). Instead, it returns a default placeholder image. This is very inconvenient for us, but we have no choice to use another API.
To work around this limitation, the app uses the [Spotify Search API](https://developer.spotify.com/console/get-search-item/) to search for the entity (artist or album), and uses the images returned by Spotify. This means that:

- An extra call to the Spotify API has to be made for each entity displayed by the app (a list of 50 artists retrieved by a signel last.fm API call will be followed by 50 Spotify API calls). This is a waste of resources and make the whole app slower. Luckily, the app does not suffer much from this since the Spotify API is very fast, and caching + async mechanism are used.
- An extra call to the Spotify API has to be made for each entity displayed by the app (a list of 50 artists retrieved by a signed last.fm API call will be followed by 50 Spotify API calls). This is a waste of resources and make the whole app slower. Luckily, the app does not suffer much from this since the Spotify API is very fast, and memoization + async mechanism are used.
- Artwork do not always match in cases of homonyms ☹️

### Listenings reports
Expand Down
12 changes: 12 additions & 0 deletions firstfm.xcodeproj/project.pbxproj
Expand Up @@ -33,6 +33,9 @@
822E9A9226A9795200C5307B /* TagInfoResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 822E9A9126A9795200C5307B /* TagInfoResponse.swift */; };
822E9A9426A97B3600C5307B /* TagTopArtistsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 822E9A9326A97B3600C5307B /* TagTopArtistsResponse.swift */; };
822E9A9626A97B7200C5307B /* TagViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 822E9A9526A97B7200C5307B /* TagViewModel.swift */; };
82312FD826C0065300C58793 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 82312FD526C0065200C58793 /* LICENSE */; };
82312FD926C0065300C58793 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 82312FD626C0065200C58793 /* README.md */; };
82312FDA26C0065300C58793 /* commitlint.config.js in Resources */ = {isa = PBXBuildFile; fileRef = 82312FD726C0065300C58793 /* commitlint.config.js */; };
8240989C26ADF67F00A789D9 /* ArtistBioView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8240989B26ADF67E00A789D9 /* ArtistBioView.swift */; };
82428B2426AEC53C00AAC835 /* TopUserTracksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82428B2326AEC53C00AAC835 /* TopUserTracksView.swift */; };
82428B2626AECDBC00AAC835 /* TopUserAlbumsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82428B2526AECDBC00AAC835 /* TopUserAlbumsView.swift */; };
Expand Down Expand Up @@ -135,6 +138,9 @@
822E9A9126A9795200C5307B /* TagInfoResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagInfoResponse.swift; sourceTree = "<group>"; };
822E9A9326A97B3600C5307B /* TagTopArtistsResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagTopArtistsResponse.swift; sourceTree = "<group>"; };
822E9A9526A97B7200C5307B /* TagViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagViewModel.swift; sourceTree = "<group>"; };
82312FD526C0065200C58793 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
82312FD626C0065200C58793 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
82312FD726C0065300C58793 /* commitlint.config.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = commitlint.config.js; sourceTree = "<group>"; };
8240989B26ADF67E00A789D9 /* ArtistBioView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArtistBioView.swift; sourceTree = "<group>"; };
82428B2326AEC53C00AAC835 /* TopUserTracksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopUserTracksView.swift; sourceTree = "<group>"; };
82428B2526AECDBC00AAC835 /* TopUserAlbumsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopUserAlbumsView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -412,6 +418,9 @@
82844DF42673991F00578DD4 = {
isa = PBXGroup;
children = (
82312FD726C0065300C58793 /* commitlint.config.js */,
82312FD526C0065200C58793 /* LICENSE */,
82312FD626C0065200C58793 /* README.md */,
82844DFF2673991F00578DD4 /* firstfm */,
82844DFE2673991F00578DD4 /* Products */,
);
Expand Down Expand Up @@ -555,10 +564,13 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
82312FD926C0065300C58793 /* README.md in Resources */,
82844E082673992200578DD4 /* Preview Assets.xcassets in Resources */,
82A006C3267973D30009BD71 /* SampleArtist.json in Resources */,
826C19C726B8895500D37488 /* Secrets.example.xcconfig in Resources */,
82312FDA26C0065300C58793 /* commitlint.config.js in Resources */,
82844E052673992200578DD4 /* Assets.xcassets in Resources */,
82312FD826C0065300C58793 /* LICENSE in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
3 changes: 2 additions & 1 deletion firstfm/Models/Spotify/SpotifyImage.swift
Expand Up @@ -10,7 +10,7 @@ struct SpotifyImage: Codable {

static func findImage(type: String, name: String, completion: @escaping (String?) -> Void) {

// Init cache handler
// MARK: Memoization handling START
let diskConfig = DiskConfig(name: "firstfm.spotify.images")
let memoryConfig = MemoryConfig()

Expand All @@ -25,6 +25,7 @@ struct SpotifyImage: Codable {
completion(image.url)
return
}
// MARK: Memoization handling END

if let encodedName = name.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
let queryURLString = "https://api.spotify.com/v1/search?q=\(encodedName)&type=\(type)&limit=1"
Expand Down

0 comments on commit 77e867f

Please sign in to comment.