This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: npm run productionstart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//app.js in your ROOT directory | |
const express = require("express"); | |
const path = require("path"); | |
const app = express(); | |
// Serve static files from the React app | |
app.use(express.static(path.join(__dirname, "build"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "oldschoolshuffle", | |
"version": "0.1.0", | |
"private": true, | |
"engines": { | |
"node": "7.10.0" | |
}, | |
"dependencies": { | |
"@material-ui/core": "^3.0.1", | |
"cosmicjs": "^3.2.12", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//spotifyFunctions.js | |
//waiting for the API to be fixed so can't use spotify-web-api-js library | |
//for playlist stuff. Creating this global variable to hold the accessToken | |
//and use it manually for our temporary playlist function. Once the JMPerez library | |
//is fixed then can go back to just using it. | |
//Playlist API issues: https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/ | |
let globalAccessToken = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function createPlaylist(simplifiedTrackArray, playlistName, addRelatedDiscography) { | |
//have to get userId, create a playlist in spotify with the name, and then add the tracks to it | |
//options is whether to addDiscography | |
//Note that Spotify is very picky about what counts as an 'active device' so likely don't have permission to press | |
//play. Also only works if the user has premium. Also spotify will only let you add 100 tracks | |
//per addTracksToPlaylist request, so need to split the trackUris up if more than 100 tracks | |
const maxTracksToAddInEachRequest = 100; | |
const userInfoResponse = await spotifyApi.getMe(); | |
const name = `${playlistName} - Album Shuffled - ${addRelatedDiscography === "true" ? 'with related discography' : ''}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//FeaturedPost.js | |
import React, { Component } from 'react'; | |
import './FeaturedPost.css'; | |
import Typography from '@material-ui/core/Typography'; | |
import Paper from '@material-ui/core/Paper'; | |
import Author from './Author'; | |
import * as SpotifyFunctions from '../spotifyFunctions.js' | |
class FeaturedPost extends Component { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function playArtistDiscography(artistId, artistName){ | |
//receives this.state from playlistChooser and extract what you need | |
try { | |
const albumIds = await identifyAlbumsByArtistId(artistId, false); | |
const shuffledAlbums = shuffleArray(albumIds); | |
const promiseArrayOfTracksFromAlbum = shuffledAlbums.map(async (albumObject) => { | |
const response = await getSimpleAlbumTracks(albumObject.albumId, albumObject.albumName, albumObject.albumUri) | |
return response | |
}) | |
const tracksByAlbum = await Promise.all(promiseArrayOfTracksFromAlbum); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const promiseArrayOfTracksFromAlbum = shuffledAlbums.map(async (albumObject) => { | |
const response = await getSimpleAlbumTracks(albumObject.albumId, albumObject.albumName, albumObject.albumUri) | |
return response | |
}) | |
const tracksByAlbum = await Promise.all(promiseArrayOfTracksFromAlbum); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function byAlbumWithDiscography(state){ | |
//receives this.state from playlistChooser and extract what you need | |
const {chosenPlaylistId: playlistId, chosenPlaylistName:playlistName} = state; | |
try { | |
let tracks = await getSimplePlaylistTracks(playlistId); | |
const albumIds = identifyAlbumsInPlaylist(tracks, false); | |
const shuffledAlbums = shuffleArray(albumIds); | |
//forget the playlist now that we know the albums - start fresh | |
const promiseArrayOfTracksFromAlbum = shuffledAlbums.map(async (albumObject) => { | |
const response = await getSimpleAlbumTracks(albumObject.albumId, albumObject.albumName, albumObject.albumUri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function byAlbumNoDiscography(state){ | |
//receives this.state from playlistChooser and extract what you need | |
const {chosenPlaylistId: playlistId, chosenPlaylistName:playlistName} = state; | |
try { | |
let tracks = await getSimplePlaylistTracks(playlistId); | |
const albumIds = identifyAlbumsInPlaylist(tracks); | |
const playlistObject = convertPlaylistToObjectByProperty(tracks, 'albumId'); | |
let tracksByAlbum = albumIds.map((albumId) => { | |
return playlistObject[albumId] | |
}); |
NewerOlder