src/api.js
// Get the number of tracks and runtime of an album or playlist.
Get the number of tracks and runtime of an album or playlist.
Get the number of tracks and runtime of an album or playlist .
function extractTrackDetails({ total_tracks, tracks }) {
  if (!total_tracks) {
    return {
      total_tracks: tracks.total
    };
  }
  const total_ms = tracks.items.reduce((acc, item) => acc + item.duration_ms, 0);
  const total_time = Math.round(total_ms / (60 * 1000));
  return {
    total_tracks,
    total_time
  };
}
function extractTrackDetails ( { total_tracks , tracks } ) { if ( ! total_tracks ) { return { total_tracks : tracks . total } ; } const total_ms = tracks . items . reduce ( ( acc , item ) => acc + item . duration_ms , 0 ) ; const total_time = Math . round ( total_ms / ( 60 * 1000 ) ) ; return { total_tracks , total_time } ; }
Get the number of tracks and runtime of an album or playlist.
Get the number of tracks and runtime of an album or playlist .
// Playlists have a different API.