Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ Additionally, by selecting "Include album data", the following fields will be ad
- Label
- Copyrights

The last column is always the Playlist URI, the same on every line, after any of the additional fields above.

Note that the more data being exported, the longer the export will take.

#### Saved Albums
Expand Down
13 changes: 11 additions & 2 deletions src/components/PlaylistExporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Track } from "../spotify"
const baseHeaders = [
"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",
"Track Preview URL", "Explicit", "Popularity", "ISRC", "Added By", "Added At", "Playlist URI",
]

const playlist = buildPlaylist({ id: 'p1', name: 'Mixtape', tracks: { total: 1 } })
Expand Down Expand Up @@ -43,14 +43,23 @@ describe("PlaylistExporter", () => {

const csv = await new PlaylistExporter(playlist, config).csvData()

expect(csvHeaders(csv).slice(baseHeaders.length)).toEqual([
expect(csvHeaders(csv).slice(baseHeaders.length - 1)).toEqual([
"Artist Genres",
"Danceability", "Energy", "Key", "Loudness", "Mode", "Speechiness", "Acousticness", "Instrumentalness", "Liveness",
"Valence", "Tempo", "Time Signature",
"Album Genres", "Label", "Copyrights",
"Playlist URI",
])
})

test("fills the playlist URI on every line", async () => {
serveTracks(buildTrack({ id: 't1' }), buildTrack({ id: 't2' }))

const csv = await new PlaylistExporter(playlist, noExtraData).csvData()

expect(csvRecords(csv).map(record => record["Playlist URI"])).toEqual([playlist.uri, playlist.uri])
})

test("quotes every field so commas, quotes and newlines survive", async () => {
serveTracks(buildTrack({ id: 't1', name: 'Say "Hi",\nthen leave', artists: [buildArtist({ name: 'A, B' })] }))

Expand Down
9 changes: 9 additions & 0 deletions src/components/PlaylistExporter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class TracksCsvFile {
})
}

// Adds a column with the same value on every line
addColumn(columnName: string, value: CsvValue) {
this.columnNames.push(columnName)
this.lineTrackData.forEach((lineTrackData) => lineTrackData.push(value))
}

content(): string {
let csvContent = ''

Expand Down Expand Up @@ -109,6 +115,9 @@ class PlaylistExporter {
await tracksCsvFile.addData(new TracksAlbumData(tracks))
}

// Playlist URI goes last so earlier columns keep their positions in existing exports
tracksCsvFile.addColumn(i18n.t("track.playlist_uri"), this.playlist.uri)

return tracksCsvFile.content()
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/PlaylistTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import liveSavedAlbums from "../test/fixtures/spotify/live/me-albums-limit-50.js
vi.mock('@bugsnag/js')

const ghostpoetPlaylist = "Ghostpoet – Peanut Butter Blues and Melancholy Jam"
const ghostpoetPlaylistUri = "spotify:playlist:4XOGDpHMrVoH33uJEwHWU5"
const ghostpoetFileName = "ghostpoet_–_peanut_butter_blues_and_melancholy_jam.csv"

const likedRequests = [
Expand Down Expand Up @@ -52,6 +53,7 @@ const crying = {
"ISRC": "UK4UP1300002",
"Added By": "",
"Added At": "2020-07-19T09:24:39Z",
"Playlist URI": "spotify:user:watsonbox:saved",
}

const ghostpoetTrack = {
Expand All @@ -67,6 +69,7 @@ const ghostpoetTrack = {
"Explicit": "false",
"Added By": "spotify:user:watsonbox",
"Added At": "2020-11-03T15:19:04Z",
"Playlist URI": ghostpoetPlaylistUri,
}

const oneTwos = {
Expand Down Expand Up @@ -111,6 +114,7 @@ const localTrack = (name: string, artist: string, durationMs: number) => ({
"ISRC": "",
"Added By": "spotify:user:u8ins5esg43wtxk4h66o5d1nb",
"Added At": "2021-02-24T06:12:40Z",
"Playlist URI": ghostpoetPlaylistUri,
})

const requestedUrls = () => handlerCalled.mock.calls.map(([url]) => url)
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/ar/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"is_playable": "قابل للتشغيل",
"added_by": "أضيف بواسطة",
"added_at": "أضيف في",
"playlist_uri": "رابط قائمة التشغيل (URI)",
"album": {
"album_genres": "أنواع الألبوم",
"label": "العلامة التجارية",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "Ist abspielbar",
"added_by": "Hinzugefügt von",
"added_at": "Hinzugefügt am",
"playlist_uri": "Playlist-URI",
"album": {
"album_genres": "Album-Genres",
"label": "Label",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/el/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "Αναπαράγεται",
"added_by": "Προστέθηκε από",
"added_at": "Προστέθηκε στις",
"playlist_uri": "URI λίστας αναπαραγωγής",
"album": {
"album_genres": "Είδη άλμπουμ",
"label": "Εταιρεία",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"is_playable": "Is Playable",
"added_by": "Added By",
"added_at": "Added At",
"playlist_uri": "Playlist URI",
"album": {
"album_genres": "Album Genres",
"label": "Label",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "Es reproducible",
"added_by": "Añadido por",
"added_at": "Añadido en",
"playlist_uri": "URI de la playlist",
"album": {
"album_genres": "Géneros del álbum",
"label": "Sello",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "Est jouable",
"added_by": "Ajouté par",
"added_at": "Ajouté le",
"playlist_uri": "URI de la playlist",
"album": {
"album_genres": "Genres de l'album",
"label": "Label",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "È riproducibile",
"added_by": "Aggiunto da",
"added_at": "Aggiunto il",
"playlist_uri": "URI della playlist",
"album": {
"album_genres": "Generi dell'album",
"label": "Etichetta",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"is_playable": "再生可能",
"added_by": "追加者",
"added_at": "追加日時",
"playlist_uri": "プレイリストURI",
"album": {
"album_genres": "アルバムジャンル",
"label": "レーベル",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "Speelbaar",
"added_by": "Toegevoegd door",
"added_at": "Toegevoegd op",
"playlist_uri": "Afspeellijst-URI",
"album": {
"album_genres": "Genres van het album",
"label": "Label",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "É reproduzível",
"added_by": "Adicionado por",
"added_at": "Adicionado em",
"playlist_uri": "URI da playlist",
"album": {
"album_genres": "Gêneros do álbum",
"label": "Gravadora",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/sv/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "Är spelbar",
"added_by": "Tillagd av",
"added_at": "Tillagd vid",
"playlist_uri": "Spellistans URI",
"album": {
"album_genres": "Albumets genrer",
"label": "Skivbolag",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/tr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"is_playable": "Çalınabilir mi?",
"added_by": "Ekleyen",
"added_at": "Eklenme Tarihi",
"playlist_uri": "Çalma Listesi URI",
"album": {
"album_genres": "Albüm Türleri",
"label": "Plak Şirketi",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/yue-Hant-HK/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"is_playable": "播得到",
"added_by": "加入者",
"added_at": "加入時間",
"playlist_uri": "播放清單 Link",
"album": {
"album_genres": "專輯曲風",
"label": "唱片公司",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/zh-Hans/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"is_playable": "可播放",
"added_by": "添加者",
"added_at": "添加时间",
"playlist_uri": "播放列表 URI",
"album": {
"album_genres": "专辑流派",
"label": "唱片公司",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/zh-Hant/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"is_playable": "可播放",
"added_by": "新增者",
"added_at": "新增時間",
"playlist_uri": "播放清單 URI",
"album": {
"album_genres": "專輯曲風",
"label": "唱片公司",
Expand Down