Skip to content

Commit

Permalink
Revert 9b0f396 due to #181
Browse files Browse the repository at this point in the history
  • Loading branch information
watsonbox committed Sep 7, 2024
1 parent 00023a6 commit bbe2841
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 50 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Track data is exported in [UTF-8](https://en.wikipedia.org/wiki/UTF-8) encoded [
- Explicit?
- Popularity
- ISRC ([International Standard Recording Code](https://isrc.ifpi.org/en/))
- Is Playable - whether the track is playable in the [user's market](https://developer.spotify.com/documentation/web-api/concepts/track-relinking)
- Added By
- Added At

Expand Down
30 changes: 15 additions & 15 deletions src/components/PlaylistTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ afterEach(() => {
server.resetHandlers()
})

const baseTrackHeaders = '"Track URI","Track Name","Artist URI(s)","Artist Name(s)","Album URI","Album Name","Album Artist URI(s)","Album Artist Name(s)","Album Release Date","Album Image URL","Disc Number","Track Number","Track Duration (ms)","Track Preview URL","Explicit","Popularity","ISRC","Is Playable","Added By","Added At"'
const baseTrackDataCrying = '"spotify:track:1GrLfs4TEvAZ86HVzXHchS","Crying","spotify:artist:4TXdHyuAOl3rAOFmZ6MeKz","Six by Seven","spotify:album:4iwv7b8gDPKztLkKCbWyhi","Best of Six By Seven","spotify:artist:4TXdHyuAOl3rAOFmZ6MeKz","Six by Seven","2017-02-17","https://i.scdn.co/image/ab67616d0000b273f485821b346237acbbca07ea","1","3","198093","https://p.scdn.co/mp3-preview/daf08df57a49c215c8c53dc5fe88dec5461f15c9?cid=9950ac751e34487dbbe027c4fd7f8e99","false","2","UK4UP1300002","true","","2020-07-19T09:24:39Z"'
const baseTrackHeaders = '"Track URI","Track Name","Artist URI(s)","Artist Name(s)","Album URI","Album Name","Album Artist URI(s)","Album Artist Name(s)","Album Release Date","Album Image URL","Disc Number","Track Number","Track Duration (ms)","Track Preview URL","Explicit","Popularity","ISRC","Added By","Added At"'
const baseTrackDataCrying = '"spotify:track:1GrLfs4TEvAZ86HVzXHchS","Crying","spotify:artist:4TXdHyuAOl3rAOFmZ6MeKz","Six by Seven","spotify:album:4iwv7b8gDPKztLkKCbWyhi","Best of Six By Seven","spotify:artist:4TXdHyuAOl3rAOFmZ6MeKz","Six by Seven","2017-02-17","https://i.scdn.co/image/ab67616d0000b273f485821b346237acbbca07ea","1","3","198093","https://p.scdn.co/mp3-preview/daf08df57a49c215c8c53dc5fe88dec5461f15c9?cid=9950ac751e34487dbbe027c4fd7f8e99","false","2","UK4UP1300002","","2020-07-19T09:24:39Z"'

// Use a snapshot test to ensure exact component rendering
test("playlist loading", async () => {
Expand Down Expand Up @@ -112,7 +112,7 @@ describe("single playlist exporting", () => {
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50&market=from_token']
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50']
])
})

Expand Down Expand Up @@ -164,7 +164,7 @@ describe("single playlist exporting", () => {
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50&market=from_token'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50'],
['https://api.spotify.com/v1/artists?ids=4TXdHyuAOl3rAOFmZ6MeKz']
])
})
Expand Down Expand Up @@ -217,7 +217,7 @@ describe("single playlist exporting", () => {
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50&market=from_token'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50'],
['https://api.spotify.com/v1/audio-features?ids=1GrLfs4TEvAZ86HVzXHchS']
])
})
Expand Down Expand Up @@ -270,7 +270,7 @@ describe("single playlist exporting", () => {
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50&market=from_token'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50'],
['https://api.spotify.com/v1/albums?ids=4iwv7b8gDPKztLkKCbWyhi']
])
})
Expand Down Expand Up @@ -325,7 +325,7 @@ describe("single playlist exporting", () => {
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50&market=from_token'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50'],
['https://api.spotify.com/v1/albums?ids=4iwv7b8gDPKztLkKCbWyhi']
])
})
Expand Down Expand Up @@ -403,8 +403,8 @@ describe("single playlist exporting", () => {
{
content: [
`${baseTrackHeaders}\n` +
'"spotify:local:The+Waymores:Heart+of+Stone:Heart+of+Stone:128","Heart of Stone","","The Waymores","","Heart of Stone","","","","","0","0","128000","","false","0","","true","spotify:user:u8ins5esg43wtxk4h66o5d1nb","2021-02-24T06:12:40Z"\n' +
'"spotify:local:Charlie+Marie:Heard+It+Through+The+Red+Wine:Heard+It+Through+The+Red+Wine:227","Heard It Through The Red Wine","","Charlie Marie","","Heard It Through The Red Wine","","","","","0","0","227000","","false","0","","true","spotify:user:u8ins5esg43wtxk4h66o5d1nb","2021-02-24T06:12:40Z"\n'
'"spotify:local:The+Waymores:Heart+of+Stone:Heart+of+Stone:128","Heart of Stone","","The Waymores","","Heart of Stone","","","","","0","0","128000","","false","0","","spotify:user:u8ins5esg43wtxk4h66o5d1nb","2021-02-24T06:12:40Z"\n' +
'"spotify:local:Charlie+Marie:Heard+It+Through+The+Red+Wine:Heard+It+Through+The+Red+Wine:227","Heard It Through The Red Wine","","Charlie Marie","","Heard It Through The Red Wine","","","","","0","0","227000","","false","0","","spotify:user:u8ins5esg43wtxk4h66o5d1nb","2021-02-24T06:12:40Z"\n'
],
options: { type: 'text/csv;charset=utf-8' }
},
Expand Down Expand Up @@ -437,8 +437,8 @@ describe("single playlist exporting", () => {
{
content: [
`${baseTrackHeaders}\n` +
'"spotify:track:7ATyvp3TmYBmGW7YuC8DJ3","One Twos / Run Run Run","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","1","241346","https://p.scdn.co/mp3-preview/137d431ad0cf987b147dccea6304aca756e923c1?cid=9950ac751e34487dbbe027c4fd7f8e99","false","22","GBMEF1100339","true","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n' +
'"spotify:track:7ATyvp3TmYBmGW7YuC8DJ3","One Twos / Run Run Run","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","1","241346","https://p.scdn.co/mp3-preview/137d431ad0cf987b147dccea6304aca756e923c1?cid=9950ac751e34487dbbe027c4fd7f8e99","false","22","GBMEF1100339","true","spotify:user:watsonbox","2020-11-20T15:19:04Z"\n'
'"spotify:track:7ATyvp3TmYBmGW7YuC8DJ3","One Twos / Run Run Run","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","1","241346","https://p.scdn.co/mp3-preview/137d431ad0cf987b147dccea6304aca756e923c1?cid=9950ac751e34487dbbe027c4fd7f8e99","false","22","GBMEF1100339","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n' +
'"spotify:track:7ATyvp3TmYBmGW7YuC8DJ3","One Twos / Run Run Run","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","1","241346","https://p.scdn.co/mp3-preview/137d431ad0cf987b147dccea6304aca756e923c1?cid=9950ac751e34487dbbe027c4fd7f8e99","false","22","GBMEF1100339","spotify:user:watsonbox","2020-11-20T15:19:04Z"\n'
],
options: { type: 'text/csv;charset=utf-8' }
},
Expand Down Expand Up @@ -571,8 +571,8 @@ test("exporting of all playlists", async () => {
expect(jsZipFileMock).toHaveBeenCalledWith(
"ghostpoet_–_peanut_butter_blues_and_melancholy_jam.csv",
`${baseTrackHeaders}\n` +
'"spotify:track:7ATyvp3TmYBmGW7YuC8DJ3","One Twos / Run Run Run","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","1","241346","https://p.scdn.co/mp3-preview/137d431ad0cf987b147dccea6304aca756e923c1?cid=9950ac751e34487dbbe027c4fd7f8e99","false","22","GBMEF1100339","true","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n' +
'"spotify:track:0FNanBLvmFEDyD75Whjj52","Us Against Whatever Ever","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","2","269346","https://p.scdn.co/mp3-preview/e5e39be10697be8755532d02c52319ffa6d58688?cid=9950ac751e34487dbbe027c4fd7f8e99","false","36","GBMEF1000270","true","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n'
'"spotify:track:7ATyvp3TmYBmGW7YuC8DJ3","One Twos / Run Run Run","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","1","241346","https://p.scdn.co/mp3-preview/137d431ad0cf987b147dccea6304aca756e923c1?cid=9950ac751e34487dbbe027c4fd7f8e99","false","22","GBMEF1100339","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n' +
'"spotify:track:0FNanBLvmFEDyD75Whjj52","Us Against Whatever Ever","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","2","269346","https://p.scdn.co/mp3-preview/e5e39be10697be8755532d02c52319ffa6d58688?cid=9950ac751e34487dbbe027c4fd7f8e99","false","36","GBMEF1000270","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n'
)

await waitFor(() => {
Expand Down Expand Up @@ -611,8 +611,8 @@ test("exporting of search results", async () => {
expect(jsZipFileMock).toHaveBeenCalledWith(
"ghostpoet_–_peanut_butter_blues_and_melancholy_jam.csv",
`${baseTrackHeaders}\n` +
'"spotify:track:7ATyvp3TmYBmGW7YuC8DJ3","One Twos / Run Run Run","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","1","241346","https://p.scdn.co/mp3-preview/137d431ad0cf987b147dccea6304aca756e923c1?cid=9950ac751e34487dbbe027c4fd7f8e99","false","22","GBMEF1100339","true","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n' +
'"spotify:track:0FNanBLvmFEDyD75Whjj52","Us Against Whatever Ever","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","2","269346","https://p.scdn.co/mp3-preview/e5e39be10697be8755532d02c52319ffa6d58688?cid=9950ac751e34487dbbe027c4fd7f8e99","false","36","GBMEF1000270","true","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n'
'"spotify:track:7ATyvp3TmYBmGW7YuC8DJ3","One Twos / Run Run Run","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","1","241346","https://p.scdn.co/mp3-preview/137d431ad0cf987b147dccea6304aca756e923c1?cid=9950ac751e34487dbbe027c4fd7f8e99","false","22","GBMEF1100339","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n' +
'"spotify:track:0FNanBLvmFEDyD75Whjj52","Us Against Whatever Ever","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","spotify:album:6jiLkuSnhzDvzsHJlweoGh","Peanut Butter Blues and Melancholy Jam","spotify:artist:69lEbRQRe29JdyLrewNAvD","Ghostpoet","2011","https://i.scdn.co/image/ab67616d0000b273306e7640be17c5b3468e6e80","1","2","269346","https://p.scdn.co/mp3-preview/e5e39be10697be8755532d02c52319ffa6d58688?cid=9950ac751e34487dbbe027c4fd7f8e99","false","36","GBMEF1000270","spotify:user:watsonbox","2020-11-03T15:19:04Z"\n'
)

await waitFor(() => {
Expand Down
8 changes: 3 additions & 5 deletions src/components/data/TracksBaseData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class TracksBaseData extends TracksData {
i18n.t("track.track_preview_url"),
i18n.t("track.explicit"),
i18n.t("track.popularity"),
i18n.t("track.isrc"),
i18n.t("track.is_playable")
i18n.t("track.isrc")
]
}

Expand Down Expand Up @@ -62,8 +61,7 @@ class TracksBaseData extends TracksData {
item.track.preview_url == null ? '' : item.track.preview_url,
item.track.explicit,
item.track.popularity,
item.track.external_ids.isrc == null ? '' : item.track.external_ids.isrc,
item.track.is_playable
item.track.external_ids.isrc == null ? '' : item.track.external_ids.isrc
]
]
}))
Expand All @@ -80,7 +78,7 @@ class TracksBaseData extends TracksData {
var limit = this.playlist.tracks.limit ? 50 : 100

for (var offset = 0; offset < this.playlist.tracks.total; offset = offset + limit) {
requests.push(`${this.playlist.tracks.href.split('?')[0]}?offset=${offset}&limit=${limit}&market=from_token`)
requests.push(`${this.playlist.tracks.href.split('?')[0]}?offset=${offset}&limit=${limit}`)
}

const trackPromises = requests.map(request => { return apiCall(request, this.accessToken) })
Expand Down
Loading

0 comments on commit bbe2841

Please sign in to comment.