Advertisement
matzl

Untitled

Feb 10th, 2023
1,333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.40 KB | None | 0 0
  1.     func fetchAlbumSongs(albumID: String, completion: @escaping ([SongData]) -> Void) {
  2.         // Fetch the recommended album's songs and add them to the song queue.
  3.        
  4.         var songs: [SongData] = []
  5.        
  6.        
  7.         let param = ["": ""]
  8.         APIClient.sharedInstance.MakeAPICallWithAuthHeaderGet(Constants.APIServices.GET_DISCOVER_ALBUMS_SONG.rawValue + albumID + "/tracks", parameters: param) { (response, error, statusCode) in
  9.  
  10.             if error == nil {
  11.                 if statusCode == 200 {
  12.                     if let response = response {
  13.                        
  14.                         if let arrData = response.value(forKey: "data") as? NSArray {
  15.                             for album in arrData {
  16.                                 let discovery = DiscoveryModel(fromDictionary: (album as? NSDictionary)!)
  17.                                
  18.                                 print("fetchAlbumSongs in Autoplay: \(discovery.relationships.tracksData.tracks)")
  19.                                 songs.append(contentsOf: discovery.relationships.tracksData.tracks)
  20.                             }
  21.                             completion(songs);
  22.                         }
  23.                     }
  24.                 }
  25.             }
  26.             else {
  27.                 print("Autoplay: Error fetchAlbumSongs: \(error?.localizedDescription)")
  28.             }
  29.         }
  30.         completion([]);
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement