Skip to content

Commit

Permalink
discovered spotify's web api endpoint for user playlists is returning…
Browse files Browse the repository at this point in the history
… bad public flag info, so nixed that column and the collaborative column for good measure
  • Loading branch information
pavelkomarov committed Aug 29, 2024
1 parent 3a0fb9e commit e071008
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions exportify.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PlaylistTable extends React.Component {
// fake a playlist-like structure for the liked songs, so it plays well with the rest of the code
let liked_songs = {name: "Liked Songs", external_urls: {spotify: "https://open.spotify.com/collection/tracks"},
images:[{url: "liked_songs.jpeg"}], owner: {id: user.id, external_urls: {spotify: user.external_urls.spotify}},
tracks: {total: library.total, href: "https://api.spotify.com/v1/me/tracks"}, public: false, collaborative: false}
tracks: {total: library.total, href: "https://api.spotify.com/v1/me/tracks"}}
let playlists = [[liked_songs]] // double list so .flat() flattens everything right later

// Retrieve the list of all the user's playlists by querying the playlists endpoint.
Expand Down Expand Up @@ -107,27 +107,19 @@ class PlaylistTable extends React.Component {
React.createElement("i", { className: "fa fa-fw fa-sort", style: { color: '#C0C0C0' }, id: "sortByOwner", onClick: () => this.sortRows("Owner")} )),
React.createElement("th", {style: {minWidth: "100px"}}, "Tracks",
React.createElement("i", { className: "fa fa-fw fa-sort", style: { color: '#C0C0C0' }, id: "sortByTracks", onClick: () => this.sortRows("Tracks")} )),
React.createElement("th", null, "Public?"),
React.createElement("th", null, "Collaborative?"),
React.createElement("th", { className: "text-right"},
React.createElement("button", { className: "btn btn-default btn-xs", type: "submit", id: "exportAll",
onClick: () => PlaylistExporter.exportAll(this.props.access_token, this.state.playlists) },
React.createElement("i", { className: "fa fa-file-archive-o"}), " Export All")))),
//table body
React.createElement("tbody", null,
this.state.playlists.map((playlist, i) =>
this.state.playlists.map((playlist, i) =>
React.createElement("tr", null, // tr = table row
React.createElement("td", null, // td = table data
React.createElement("img", { src: playlist.images?.length > 0 ? playlist.images[0].url : "https://placehold.co/30?text=blank", style: { width: "30px", height: "30px" }})),
React.createElement("td", null, React.createElement("a", { href: playlist.external_urls.spotify }, playlist.name)),
React.createElement("td", null, React.createElement("a", { href: playlist.owner.external_urls.spotify }, playlist.owner.id)),
React.createElement("td", null, playlist.tracks.total),
React.createElement("td", null, playlist.public ?
React.createElement("i", { className: "fa fa-lg fa-check-circle-o" }) :
React.createElement("i", { className: "fa fa-lg fa-times-circle-o", style: { color: '#ECEBE8' } })),
React.createElement("td", null, playlist.collaborative ?
React.createElement("i", { className: "fa fa-lg fa-check-circle-o" }) :
React.createElement("i", { className: "fa fa-lg fa-times-circle-o", style: { color: '#ECEBE8' } })),
React.createElement("td", { className: "text-right" },
React.createElement("button", { className: "btn btn-default btn-xs btn-success", id: "export" + i, onClick: () => PlaylistExporter.export(this.props.access_token, this.state.playlists[i], i) },
React.createElement("i", { className: "fa fa-download" }) /* download icon */, " Export")))))))
Expand Down

0 comments on commit e071008

Please sign in to comment.