MCPcopy
hub / github.com/watsonbox/exportify / data

Method data

src/components/data/TracksAlbumData.ts:23–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 }
22
23 async data() {
24 const albumIds = Array.from(new Set(this.tracks.filter((track: any) => track.album.id).map((track: any) => track.album.id)))
25
26 let requests = []
27
28 for (var offset = 0; offset < albumIds.length; offset = offset + this.ALBUM_LIMIT) {
29 requests.push(`https://api.spotify.com/v1/albums?ids=${albumIds.slice(offset, offset + this.ALBUM_LIMIT)}`)
30 }
31
32 const albumPromises = requests.map((request) => apiCall(request, this.accessToken))
33 const albumResponses = await Promise.all(albumPromises)
34
35 const albumDataById = new Map<string, string[]>(
36 albumResponses.flatMap((response) => response.data.albums.map((album: any) => {
37 return [
38 album == null ? "" : album.id,
39 [
40 album == null ? "" : album.genres.join(", "),
41 album == null ? "" : album.label,
42 album == null ? "" : album.copyrights.map((c: any) => `${c.type} ${c.text}`).join(", ")
43 ]
44 ]
45 }))
46 )
47
48 return new Map<string, string[]>(
49 this.tracks.map((track: any) => [track.uri, albumDataById.get(track.album.id) || ["", "", ""]])
50 )
51 }
52}
53
54export default TracksAlbumData

Callers

nothing calls this directly

Calls 2

sliceMethod · 0.80
allMethod · 0.80

Tested by

no test coverage detected