Skip to content

Commit

Permalink
Merge pull request #12 from rrk0804/Recs-By-Metrics
Browse files Browse the repository at this point in the history
Recommendations By Selected Metrics
  • Loading branch information
rrk0804 authored Oct 1, 2024
2 parents cd4c879 + 1632d6c commit 05c8f67
Show file tree
Hide file tree
Showing 10 changed files with 365 additions and 82 deletions.
179 changes: 172 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"devDependencies": {
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"@types/react-modal": "^3.16.3",
"spicetify-creator": "^1.0.17"
},
"dependencies": {
"@spotify/web-api-ts-sdk": "^1.2.0",
"@types/jquery": "^3.5.31",
"jquery": "^3.7.1",
"react-circular-progressbar": "^2.1.0"
"react-circular-progressbar": "^2.1.0",
"react-modal": "^3.16.1"
}
}
20 changes: 2 additions & 18 deletions src/components/DynamicRecommendations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import getRecommendations from "../services/dynamicRecommendationsService";
import { GetRecommendationsInput, GetRecommendationsResponse } from "../types/spotify-web-api.d";
import getID from './../services/common';
import RecommendedTrack from "./RecommendedTrack";
import { RecommendationsRender } from "../services/enhancifyInternalService";

class DynamicRecommendations extends React.Component<{recTargetProp : string}, {songQueue: Array<string>, artistQueue: Array<string>, recTarget: string, recommendations: GetRecommendationsResponse | {}}> {

Expand Down Expand Up @@ -153,24 +154,7 @@ class DynamicRecommendations extends React.Component<{recTargetProp : string}, {
<div className={styles.recommendationTarget}>{this.props.recTargetProp}</div>
</div>
<div className={styles.recommendationsBlock}>
{function(recommendations : GetRecommendationsResponse | {}) {
if (Object.keys(recommendations).length == 0) {
return;
}
let recs = (recommendations as GetRecommendationsResponse)["tracks"];
let recommendedTracksHTML = [];
for (let i = 0; i < 6; i++) {
let recommendedSong = <RecommendedTrack songCover={recs[i].album.images[0].url}
songAlbum={recs[i].album.name}
songName={recs[i].name}
songArtists={recs[i].artists.map((artist) => artist.name)}
songURI={recs[i].uri}
key={i}>
</RecommendedTrack>;
recommendedTracksHTML.push(recommendedSong);
}
return recommendedTracksHTML;
}(this.state.recommendations)}
{RecommendationsRender(this.state.recommendations)}
</div>
</div>
</>
Expand Down
Loading

0 comments on commit 05c8f67

Please sign in to comment.