MCPcopy Index your code
hub / github.com/watsonbox/exportify / getPlaylistItems

Method getPlaylistItems

src/components/data/TracksBaseData.ts:72–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70 // Memoization supporting multiple calls
71 private playlistItems: any[] = []
72 private async getPlaylistItems() {
73 if (this.playlistItems.length > 0) {
74 return this.playlistItems
75 }
76
77 var requests = []
78 var limit = this.playlist.tracks.limit ? 50 : 100
79
80 for (var offset = 0; offset < this.playlist.tracks.total; offset = offset + limit) {
81 requests.push(`${this.playlist.tracks.href.split('?')[0]}?offset=${offset}&limit=${limit}`)
82 }
83
84 const trackPromises = requests.map(request => { return apiCall(request, this.accessToken) })
85 const trackResponses = await Promise.all(trackPromises)
86
87 this.playlistItems = trackResponses.flatMap(response => {
88 return response.data.items.filter((i: any) => i.track) // Exclude null track attributes
89 })
90 }
91}
92
93export default TracksBaseData

Callers 2

trackItemsMethod · 0.95
dataMethod · 0.95

Calls 1

allMethod · 0.80

Tested by

no test coverage detected