Skip to content

Commit

Permalink
feat!: 💥 Use playlist groups as sources instead of single playlists (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
javsalgar authored Oct 23, 2022
1 parent d8c2e3f commit 116bbef
Show file tree
Hide file tree
Showing 14 changed files with 321 additions and 81 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
node_modules
93 changes: 93 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"extends": [
"airbnb-base",
"plugin:chai-friendly/recommended",
"plugin:mocha/recommended"
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "script"
},
"env": {
"es6": true,
"mocha": true,
"node": true,
"browser": false
},
"rules": {
"import/extensions": 0,
"import/no-cycle": 0,
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0,
"mocha/no-setup-in-describe": 0,
"mocha/no-exports": 0,
"mocha/no-skipped-tests": 0,
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore"
}
],
"quotes": [
2,
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"no-unneeded-ternary": 0,
"func-names": 0,
"prefer-rest-params": 0,
"prefer-arrow-callback": 0,
"arrow-body-style": 0,
"space-before-function-paren": [
2,
"never"
],
"newline-per-chained-call": [
"error",
{
"ignoreChainWithDepth": 2
}
],
"object-curly-spacing": [
2,
"never"
],
"object-shorthand": 0,
"no-param-reassign": 0,
"no-underscore-dangle": 0,
"quote-props": [
"error",
"consistent-as-needed"
],
"no-console": 0,
"max-len": [
2,
{
"code": 120
}
],
"class-methods-use-this": 0,
"import/no-dynamic-require": 0,
"prefer-destructuring": 0,
"no-cond-assign": [
"error",
"except-parens"
],
"strict": [
"error",
"global"
],
"max-classes-per-file": [
"error",
5
],
"prefer-object-spread": 0
}
}
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ Session maker for Spotify works with session definitions, which are `JSON` files
"sources": [ <-- Here goes the source playlists you want to use
{
"name": "<Internal identifier of playlist>",
"spotifyID": "<Spotify ID of the Playlist>"
"spotifyIDs": ["<Spotify ID of one or more Playlists>"]
},
{
"name": "<Internal identifier of playlist>",
"spotifyID": "<Spotify ID of the Playlist>"
"spotifyIDs": ["<Spotify ID of one or more Playlists>"]
},
...
],
"pattern": [
"<Playlist Identifier>",
"<Playlist Identifier>",
"<Playlist Identifier>",
"<Source Identifier>",
"<Source Identifier>",
"<Source Identifier>",
]
}
```
Expand Down Expand Up @@ -103,15 +103,15 @@ The session definition would look like this:
"sources": [
{
"name": "Salsa",
"spotifyID": "2OsWOxpOhmPUqISvPo8Cph"
"spotifyIDs": ["2OsWOxpOhmPUqISvPo8Cph"]
},
{
"name": "Bachata",
"spotifyID": "7LsJLGdokIxHxcmGMlXB3m"
"spotifyIDs": ["7LsJLGdokIxHxcmGMlXB3m"]
},
{
"name": "Kizomba",
"spotifyID": "2godpxQkfAuR9JRJ7tU5ws"
"spotifyIDs": ["2godpxQkfAuR9JRJ7tU5ws"]
}
],
"pattern": [
Expand Down
9 changes: 7 additions & 2 deletions cmd/create-playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ const fs = require('fs');
const https = require('https');
const {createPlaylist, parseSession} = require('../lib');

async function cmdCreatePlaylist({session, accessToken}) {
const definition = parseSession(fs.readFileSync(session), {encoding: 'utf-8'});
/**
* Command for creating the playlist in Spotify
* @param {string} input.sessionPath Path to the session file
* @param {string} input.accessToken Spotify API token for performing operations
*/
async function cmdCreatePlaylist({session: sessionPath, accessToken}) {
const definition = parseSession(fs.readFileSync(sessionPath), {encoding: 'utf-8'});

console.info('Verifying access token');
let user;
Expand Down
4 changes: 3 additions & 1 deletion cmd/get-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
const fs = require('fs');
const http = require('http');
const path = require('path');

/**
* Command for obtaining the API token in Spotify
*/
async function cmdGetToken() {
// We will create an embedded server for the callback
const serverPort = process.env.TOKEN_SERVER_PORT ? process.env.TOKEN_SERVER_PORT : 30008;
Expand Down
13 changes: 9 additions & 4 deletions examples/sbk_session.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
"sources": [
{
"name": "Salsa",
"spotifyID": "2OsWOxpOhmPUqISvPo8Cph"
"spotifyIDs": [
"2OsWOxpOhmPUqISvPo8Cph"
]
},
{
"name": "Bachata",
"spotifyID": "7LsJLGdokIxHxcmGMlXB3m"
"spotifyIDs": [
"7LsJLGdokIxHxcmGMlXB3m"
]
},
{
"name": "Kizomba",
"spotifyID": "2godpxQkfAuR9JRJ7tU5ws"
"spotifyIDs": [
"2godpxQkfAuR9JRJ7tU5ws"
]
}
],
"pattern": [
Expand All @@ -24,4 +30,3 @@
"Kizomba"
]
}

56 changes: 56 additions & 0 deletions examples/swing_session.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"title": "Swing session by BPMs and 10% Blues",
"description": "Built with spotify-session-maker",
"maxSongs": 200,
"sources": [
{
"name": "100-120",
"spotifyIDs": [
"7ivzWZParGOFfg6WLurw8E"
]
},
{
"name": "120-140",
"spotifyIDs": [
"57TmdQaIAxm142Kec2xFrX"
]
},
{
"name": "140-160",
"spotifyIDs": [
"0V1aG0b9ye5B4MPId1Znj7"
]
},
{
"name": "160-180",
"spotifyIDs": [
"0Ky3d8TBOOe4VYd0AodaTL"
]
},
{
"name": "Over180",
"spotifyIDs": [
"3IO3m6mfuDLvBrkpllHlJ6",
"1nDCfIMWHQDpChhitrI0sk"
]
},
{
"name": "Blues",
"spotifyIDs": [
"7kwIt9o0BTtszsl3VVtHPT"
]
}
],
"pattern": [
"100-120",
"120-140",
"140-160",
"160-180",
"Over180",
"100-120",
"120-140",
"140-160",
"160-180",
"Blues"
]
}
Loading

0 comments on commit 116bbef

Please sign in to comment.