From 62cfef696ea97d75254ed37a94fe7808ec8b684d Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Fri, 10 Jan 2020 06:15:37 +0100 Subject: [PATCH 1/7] Fix for the hash error on song download (issue 121) --- src/actions/queueActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/queueActions.js b/src/actions/queueActions.js index c53b8e8..79705b3 100644 --- a/src/actions/queueActions.js +++ b/src/actions/queueActions.js @@ -62,7 +62,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { } }) let req = request.get({ - url: `http://www.beatsaver.com${song.downloadURL}`, + url: `http://beatsaver.com${song.downloadURL}`, encoding: null }, (err, r, data) => { try { From 21f8c3ef50fdf0859ad3ce39c878686df6e607e7 Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Fri, 10 Jan 2020 06:27:06 +0100 Subject: [PATCH 2/7] https also works --- src/actions/queueActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/queueActions.js b/src/actions/queueActions.js index 79705b3..abf8d90 100644 --- a/src/actions/queueActions.js +++ b/src/actions/queueActions.js @@ -62,7 +62,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { } }) let req = request.get({ - url: `http://beatsaver.com${song.downloadURL}`, + url: `https://beatsaver.com${song.downloadURL}`, encoding: null }, (err, r, data) => { try { From 8100573e28e8a86cd017dc335dcd2c50b9d452e2 Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Sun, 12 Jan 2020 03:09:26 +0100 Subject: [PATCH 3/7] Fix https on action files --- src/actions/detailsActions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions/detailsActions.js b/src/actions/detailsActions.js index 8ca0ac3..71fcc49 100644 --- a/src/actions/detailsActions.js +++ b/src/actions/detailsActions.js @@ -74,7 +74,7 @@ export const loadDetailsFromKey = key => dispatch => { }) .then(res => res.json()) .then(details => { - fetch(`http://beatsaver.com${details.downloadURL}`) + fetch(`https://beatsaver.com${details.downloadURL}`) .then(res => res.arrayBuffer()) .then(data => { let zip = new AdmZip(new Buffer(data)) @@ -139,4 +139,4 @@ export const loadDetailsFromKey = key => dispatch => { } }) } -} \ No newline at end of file +} From 138ca7d0d49440d2244f458e3ab1edf9819e84bc Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Sun, 12 Jan 2020 05:14:11 +0100 Subject: [PATCH 4/7] Remove www prefix on betsaver URL --- src/actions/queueActions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions/queueActions.js b/src/actions/queueActions.js index abf8d90..60af7a5 100644 --- a/src/actions/queueActions.js +++ b/src/actions/queueActions.js @@ -56,7 +56,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { payload: { utc, hash: song.hash, - image: `https://www.beatsaver.com${ song.coverURL }`, + image: `https://beatsaver.com${ song.coverURL }`, title: song.metadata.songName, author: song.metadata.songAuthorName } @@ -253,7 +253,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { payload: { utc, hash: song.hash, - image: `https://www.beatsaver.com${ song.coverURL }`, + image: `https://beatsaver.com${ song.coverURL }`, title: song.metadata.songName, author: song.metadata.songAuthorName } From 18805e5599e940c168cfc46c7669e925b8033a7e Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Sun, 12 Jan 2020 05:53:08 +0100 Subject: [PATCH 5/7] Refactor hardcoded URI with constants --- package-lock.json | 157 +++++++++++++++++++------------- package.json | 2 +- src/actions/detailsActions.js | 7 +- src/actions/modActions.js | 23 ++--- src/actions/playlistsActions.js | 7 +- src/actions/queueActions.js | 15 +-- src/actions/searchActions.js | 5 +- src/actions/songListActions.js | 21 +++-- src/constants/urls.js | 3 + 9 files changed, 141 insertions(+), 99 deletions(-) create mode 100644 src/constants/urls.js diff --git a/package-lock.json b/package-lock.json index 77ce2d0..4cd4535 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "beatdrop", - "version": "2.5.9-beta", + "version": "2.5.9", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1533,9 +1533,9 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -3138,7 +3138,8 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -3162,13 +3163,15 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3185,19 +3188,22 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3328,7 +3334,8 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3342,6 +3349,7 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3358,6 +3366,7 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3366,13 +3375,15 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": false, "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3393,6 +3404,7 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3481,7 +3493,8 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3495,6 +3508,7 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3590,7 +3604,8 @@ "version": "5.1.2", "resolved": false, "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -3632,6 +3647,7 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3653,6 +3669,7 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3701,13 +3718,15 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": false, "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, @@ -7113,7 +7132,8 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -7137,13 +7157,15 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7160,19 +7182,22 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7303,7 +7328,8 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7317,6 +7343,7 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7333,6 +7360,7 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7341,13 +7369,15 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7368,6 +7398,7 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7456,7 +7487,8 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7470,6 +7502,7 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -7565,7 +7598,8 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -7607,6 +7641,7 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7628,6 +7663,7 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7676,20 +7712,22 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "resolved": false, "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true + "dev": true, + "optional": true } } }, "fstream": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", - "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", + "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", "requires": { "graceful-fs": "^4.1.2", "inherits": "~2.0.0", @@ -7942,9 +7980,9 @@ } }, "globule": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.1.tgz", - "integrity": "sha512-g7QtgWF4uYSL5/dn71WxubOrS7JVGCnFPEnoeChJmBnyR9Mw8nGoEwOgJL/RC2Te0WhbsEUCejfH8SZNJ+adYQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.0.tgz", + "integrity": "sha512-YlD4kdMqRCQHrhVdonet4TdRtv1/sZKepvoxNT4Nrhrp5HI8XFfc8kFlGlBn2myBo80aGp8Eft259mbcUJhgSg==", "requires": { "glob": "~7.1.1", "lodash": "~4.17.10", @@ -9473,11 +9511,6 @@ "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", "dev": true }, - "lodash.assign": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", - "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=" - }, "lodash.assignin": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz", @@ -9494,11 +9527,6 @@ "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", "dev": true }, - "lodash.clonedeep": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" - }, "lodash.compact": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash.compact/-/lodash.compact-3.0.1.tgz", @@ -9551,11 +9579,6 @@ "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==" }, - "lodash.mergewith": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz", - "integrity": "sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==" - }, "lodash.pick": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", @@ -10174,7 +10197,9 @@ "nan": { "version": "2.12.1", "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz", - "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==" + "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==", + "dev": true, + "optional": true }, "nanomatch": { "version": "1.2.13", @@ -10408,9 +10433,9 @@ } }, "node-sass": { - "version": "4.11.0", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.11.0.tgz", - "integrity": "sha512-bHUdHTphgQJZaF1LASx0kAviPH7sGlcyNhWade4eVIpFp6tsn7SV8xNMTbsQFpEV9VXpnwTTnNYlfsZXgGgmkA==", + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.13.0.tgz", + "integrity": "sha512-W1XBrvoJ1dy7VsvTAS5q1V45lREbTlZQqFbiHb3R3OTTCma0XBtuG6xZ6Z4506nR4lmHPTqVRwxT6KgtWC97CA==", "requires": { "async-foreach": "^0.1.3", "chalk": "^1.1.1", @@ -10419,12 +10444,10 @@ "get-stdin": "^4.0.1", "glob": "^7.0.3", "in-publish": "^2.0.0", - "lodash.assign": "^4.2.0", - "lodash.clonedeep": "^4.3.2", - "lodash.mergewith": "^4.6.0", + "lodash": "^4.17.15", "meow": "^3.7.0", "mkdirp": "^0.5.1", - "nan": "^2.10.0", + "nan": "^2.13.2", "node-gyp": "^3.8.0", "npmlog": "^4.0.0", "request": "^2.88.0", @@ -10472,6 +10495,16 @@ "ansi-regex": "^2.0.0" } }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -16987,9 +17020,9 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -17455,12 +17488,12 @@ "dev": true }, "tar": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", - "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", + "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==", "requires": { "block-stream": "*", - "fstream": "^1.0.2", + "fstream": "^1.0.12", "inherits": "2" } }, diff --git a/package.json b/package.json index 9e71e8d..9bf83e6 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "electron-updater": "4.0.5", "get-image-colors": "^1.8.1", "md5": "^2.2.1", - "node-sass": "^4.11.0", + "node-sass": "^4.13.0", "original-fs": "^1.0.0", "react": "16.4.0", "react-contextmenu": "^2.10.0", diff --git a/src/actions/detailsActions.js b/src/actions/detailsActions.js index 71fcc49..5471f43 100644 --- a/src/actions/detailsActions.js +++ b/src/actions/detailsActions.js @@ -1,5 +1,6 @@ import { LOAD_DETAILS, CLEAR_DETAILS, SET_DETAILS_LOADING, DISPLAY_WARNING } from './types' import { SONG_DETAILS } from '../constants/views' +import { BEATSAVER_BASE_URL, BSABER_BASE_URL } from '../constants/urls' import AdmZip from 'adm-zip' import { hashAndWriteToMetadata } from './queueActions' @@ -60,7 +61,7 @@ export const loadDetailsFromKey = key => dispatch => { }) setView(SONG_DETAILS)(dispatch) if((/^[a-f0-9]+$/).test(key)) { - fetch(`https://beatsaver.com/api/maps/detail/${key}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/${key}`) .then(res => { if(res.status === 404){ dispatch({ @@ -74,7 +75,7 @@ export const loadDetailsFromKey = key => dispatch => { }) .then(res => res.json()) .then(details => { - fetch(`https://beatsaver.com${details.downloadURL}`) + fetch(`${BEATSAVER_BASE_URL}${details.downloadURL}`) .then(res => res.arrayBuffer()) .then(data => { let zip = new AdmZip(new Buffer(data)) @@ -105,7 +106,7 @@ export const loadDetailsFromKey = key => dispatch => { } }) }) - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ diff --git a/src/actions/modActions.js b/src/actions/modActions.js index 5df931a..8703565 100644 --- a/src/actions/modActions.js +++ b/src/actions/modActions.js @@ -1,5 +1,6 @@ import { SET_MOD_LIST, SET_RESOURCE, SET_LOADING, LOAD_MOD_DETAILS, INSTALL_MOD, SET_SCANNING_FOR_MODS, SET_INSTALLED_MODS, DISPLAY_WARNING, UNINSTALL_MOD, CLEAR_MODS, ADD_TO_QUEUE, UPDATE_PROGRESS, ADD_DEPENDENT, SET_MOD_ACTIVE, ADD_PENDING_MOD, SET_PATCHING } from './types' import { MODS_VIEW, MOD_DETAILS } from '../constants/views' +import { BEATMODS_BASE_URL } from '../constants/urls' import { BEATMODS, LIBRARY } from '../constants/resources' @@ -27,7 +28,7 @@ export const fetchApprovedMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod?status=approved&gameVersion=${getState().settings.gameVersion}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -54,7 +55,7 @@ export const fetchRecommendedMods = () => (dispatch, getState) => { let recommendedMods = ['CameraPlus', 'YUR Fit Calorie Tracker', 'SyncSaber', 'Custom Sabers', 'Custom Platforms', 'Custom Avatars', 'BeatSaberTweaks', 'PracticePlugin', 'Counters+'] let mods = [] for(let i = 0; i < recommendedMods.length; i++) { - fetch(`https://beatmods.com/api/v1/mod?name=${encodeURIComponent(recommendedMods[i])}&gameVersion=${getState().settings.gameVersion}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?name=${encodeURIComponent(recommendedMods[i])}&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length === 0) { recommendedMods.splice(i, 1); return } @@ -99,7 +100,7 @@ export const fetchModCategory = category => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod?category=${ category }&status=approved&gameVersion=${getState().settings.gameVersion}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?category=${ category }&status=approved&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -123,7 +124,7 @@ export const fetchLocalMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod?status=approved&status=inactive`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&status=inactive`) .then(res => res.json()) .then(beatModsResponse => { let installedMods = getState().mods.installedMods @@ -162,7 +163,7 @@ export const fetchActivatedMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod?status=approved&status=inactive`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&status=inactive`) .then(res => res.json()) .then(beatModsResponse => { let activatedMods = getState().mods.installedMods.filter(mod => mod.active === true) @@ -197,7 +198,7 @@ export const loadModDetails = modId => dispatch => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -240,7 +241,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge return } console.log(`Fetching ${modName} from BeatMods...`) - fetch(`https://beatmods.com/api/v1/mod?status=approved&name=${ encodeURIComponent(modName) }&gameVersion=${ getState().settings.gameVersion }`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&name=${ encodeURIComponent(modName) }&gameVersion=${ getState().settings.gameVersion }`) .then(res => res.json()) .then(beatModsResponse => { console.log(`Got the BeatMods response for ${ modName }`) @@ -284,7 +285,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge // Install Mod console.log(`Installing ${ modName }...`) if(mod.downloads.some(version => version.type === 'universal')) { - req = request.get({ url: `https://beatmods.com${mod.downloads.filter(version => version.type === 'universal')[0].url}`, encoding: null }, (err, r, data) => { + req = request.get({ url: `${BEATMODS_BASE_URL}${mod.downloads.filter(version => version.type === 'universal')[0].url}`, encoding: null }, (err, r, data) => { if(r) if(err || (r.hasOwnProperty('statusCode') && r.statusCode !== 200)) { dispatch({ type: DISPLAY_WARNING, @@ -331,7 +332,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge } else { let installationType = getState().settings.installationType if(mod.downloads.some(version => version.type === installationType)) { - req = request.get({ url: `https://beatmods.com${mod.downloads.filter(version => version.type === installationType)[0].url}`, encoding: null }, (err, r, data) => { + req = request.get({ url: `${BEATMODS_BASE_URL}${mod.downloads.filter(version => version.type === installationType)[0].url}`, encoding: null }, (err, r, data) => { if(r) if(err || r.statusCode !== 200) { dispatch({ type: DISPLAY_WARNING, @@ -525,7 +526,7 @@ export const checkInstalledMods = () => (dispatch, getState) => { let md5sum = crypto.createHash('md5') md5sum.update(data) let hash = md5sum.digest('hex') - fetch(`https://beatmods.com/api/v1/mod?hash=${hash}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?hash=${hash}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length > 0) { @@ -581,7 +582,7 @@ export const checkInstalledMods = () => (dispatch, getState) => { let md5sum = crypto.createHash('md5') md5sum.update(data) let hash = md5sum.digest('hex') - fetch(`https://beatmods.com/api/v1/mod?hash=${hash}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?hash=${hash}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length > 0) { diff --git a/src/actions/playlistsActions.js b/src/actions/playlistsActions.js index 01a3fe2..c9c6e06 100644 --- a/src/actions/playlistsActions.js +++ b/src/actions/playlistsActions.js @@ -1,5 +1,6 @@ import { FETCH_LOCAL_PLAYLISTS, LOAD_NEW_PLAYLIST_IMAGE, SET_NEW_PLAYLIST_OPEN, SET_PLAYLIST_PICKER_OPEN, CLEAR_PLAYLIST_DIALOG, LOAD_PLAYLIST_DETAILS, LOAD_PLAYLIST_SONGS, CLEAR_PLAYLIST_DETAILS, SET_PLAYLIST_EDITING, SET_LOADING, DISPLAY_WARNING } from './types' import { PLAYLIST_LIST, PLAYLIST_DETAILS } from '../constants/views' +import { BEATSAVER_BASE_URL } from '../constants/urls' import { defaultPlaylistIcon } from '../b64Assets' import { hashAndWriteToMetadata } from './queueActions' import { setView } from './viewActions' @@ -196,7 +197,7 @@ export const loadPlaylistDetails = playlistFile => (dispatch, getState) => { }) }) } else { - fetch(`https://beatsaver.com/api/maps/by-hash/${playlist.songs[i].hash}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${playlist.songs[i].hash}`) .then(res => res.json()) .then(song => { song.coverURL = `https://beatsaver.com/${song.coverURL}` @@ -213,10 +214,10 @@ export const loadPlaylistDetails = playlistFile => (dispatch, getState) => { }) } } else { - fetch(`https://beatsaver.com/api/maps/detail/${playlist.songs[i].key}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/${playlist.songs[i].key}`) .then(res => res.json()) .then(details => { - details.coverURL = `https://beatsaver.com/${details.coverURL}` + details.coverURL = `${BEATSAVER_BASE_URL}/${details.coverURL}` if(state.songs.downloadedSongs.some(song => song.hash === details.hash)) { let file = state.songs.downloadedSongs[state.songs.downloadedSongs.findIndex(song => song.hash === details.hash)].file fs.readFile(file, 'UTF8', (err, data) => { diff --git a/src/actions/queueActions.js b/src/actions/queueActions.js index 60af7a5..baa9a73 100644 --- a/src/actions/queueActions.js +++ b/src/actions/queueActions.js @@ -1,5 +1,6 @@ import { SET_QUEUE_OPEN, ADD_TO_QUEUE, CLEAR_QUEUE, UPDATE_PROGRESS, SET_DOWNLOADED_SONGS, SET_DOWNLOADING_COUNT, SET_WAIT_LIST, DISPLAY_WARNING, SET_SCANNING_FOR_SONGS, SET_DISCOVERED_FILES, SET_PROCESSED_FILES } from './types' import { SONG_LIST } from '../constants/views' +import { BEATSAVER_BASE_URL } from '../constants/urls' import { isModInstalled, installEssentialMods } from './modActions' import { setView } from './viewActions' @@ -26,7 +27,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { if(!isModInstalled('SongLoader')(dispatch, getState)) installEssentialMods()(dispatch, getState) let hash = identity if(identity) { - fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { hash = song.hash @@ -46,7 +47,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { setTimeout(() => { document.getElementById('queue-button').classList.remove('notify') }, 1000) - fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { let utc = Date.now() @@ -56,13 +57,13 @@ export const downloadSong = (identity) => (dispatch, getState) => { payload: { utc, hash: song.hash, - image: `https://beatsaver.com${ song.coverURL }`, + image: `${BEATSAVER_BASE_URL}${ song.coverURL }`, title: song.metadata.songName, author: song.metadata.songAuthorName } }) let req = request.get({ - url: `https://beatsaver.com${song.downloadURL}`, + url: `${BEATSAVER_BASE_URL}${song.downloadURL}`, encoding: null }, (err, r, data) => { try { @@ -244,7 +245,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { setTimeout(() => { document.getElementById('queue-button').classList.remove('notify') }, 1000) - fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { let utc = Date.now() @@ -253,13 +254,13 @@ export const downloadSong = (identity) => (dispatch, getState) => { payload: { utc, hash: song.hash, - image: `https://beatsaver.com${ song.coverURL }`, + image: `${BEATSAVER_BASE_URL}${ song.coverURL }`, title: song.metadata.songName, author: song.metadata.songAuthorName } }) let req = request.get({ - url: `https://beatsaver.com/${ song.downloadURL }`, + url: `${BEATSAVER_BASE_URL}/${ song.downloadURL }`, encoding: null }, (err, r, data) => { try { diff --git a/src/actions/searchActions.js b/src/actions/searchActions.js index 8bd408c..e375587 100644 --- a/src/actions/searchActions.js +++ b/src/actions/searchActions.js @@ -1,4 +1,5 @@ import { SET_SEARCH_SOURCES, SUBMIT_SEARCH, SET_LOADING } from './types' +import { BEATSAVER_BASE_URL } from '../constants/urls' const { remote } = window.require('electron') const fs = remote.require('fs') @@ -48,7 +49,7 @@ export const submitSearch = keywords => (dispatch, getState) => { localResultsReady = true // BeatSaver Search - fetch('https://beatsaver.com/api/search/text/all?q=' + encodeURIComponent(keywords.replace('/', '\\'))) + fetch(`${BEATSAVER_BASE_URL}/api/search/text/all?q=` + encodeURIComponent(keywords.replace('/', '\\'))) .then(res => res.json()) .then(data => { beatSaverSongs = data.docs @@ -68,7 +69,7 @@ export const submitSearch = keywords => (dispatch, getState) => { // BeatSaver ID Search if(isId) { - fetch('https://beatsaver.com/api/maps/detail/' + keywords) + fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/` + keywords) .then(res => { if(res.status !== 200) { beatSaverIdResultsReady = true; return } return res.json() }) .then(data => { if(!data) { beatSaverIdResultsReady = true; return } diff --git a/src/actions/songListActions.js b/src/actions/songListActions.js index 36d409a..2227aa2 100644 --- a/src/actions/songListActions.js +++ b/src/actions/songListActions.js @@ -1,6 +1,7 @@ import { FETCH_NEW, FETCH_TOP_DOWNLOADS, FETCH_TOP_FINISHED, FETCH_LOCAL_SONGS, ADD_BSABER_RATING, SET_SCROLLTOP, SET_LOADING, SET_LOADING_MORE, LOAD_MORE, SET_RESOURCE, DISPLAY_WARNING } from './types' import { SONG_LIST } from '../constants/views' import { BEATSAVER, LIBRARY } from '../constants/resources' +import { BEATSAVER_BASE_URL, BSABER_BASE_URL } from '../constants/urls' import { hashAndWriteToMetadata } from './queueActions' import { setView } from './viewActions' @@ -9,9 +10,9 @@ const fs = remote.require('fs') const path = remote.require('path') const resourceUrl = { - 'BEATSAVER_NEW_SONGS': 'https://beatsaver.com/api/maps/latest', - 'BEATSAVER_TOP_DOWNLOADED_SONGS': 'https://beatsaver.com/api/maps/downloads', - 'BEATSAVER_TOP_FINISHED_SONGS': 'https://beatsaver.com/api/maps/plays' + 'BEATSAVER_NEW_SONGS': `${BEATSAVER_BASE_URL}/api/maps/latest`, + 'BEATSAVER_TOP_DOWNLOADED_SONGS': `${BEATSAVER_BASE_URL}/api/maps/downloads`, + 'BEATSAVER_TOP_FINISHED_SONGS': `${BEATSAVER_BASE_URL}/api/maps/plays` } export const fetchNew = () => dispatch => { @@ -28,7 +29,7 @@ export const fetchNew = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.NEW_SONGS }) - fetch('https://beatsaver.com/api/maps/latest') + fetch(`${BEATSAVER_BASE_URL}api/maps/latest`) .then(res => res.json()) .then(data => { console.log(data) @@ -42,7 +43,7 @@ export const fetchNew = () => dispatch => { }) console.log(data); for(let i = 0; i < data.docs.length; i++) { - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -74,7 +75,7 @@ export const fetchTopDownloads = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.TOP_DOWNLOADED_SONGS }) - fetch('https://beatsaver.com/api/maps/downloads') + fetch(`${BEATSAVER_BASE_URL}/api/maps/downloads`) .then(res => res.json()) .then(data => { dispatch({ @@ -86,7 +87,7 @@ export const fetchTopDownloads = () => dispatch => { payload: false }) for(let i = 0; i < data.songs.length; i++) { - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -118,7 +119,7 @@ export const fetchTopFinished = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.TOP_FINISHED_SONGS }) - fetch('https://beatsaver.com/api/maps/plays') + fetch(`${BEATSAVER_BASE_URL}/api/maps/plays`) .then(res => res.json()) .then(data => { dispatch({ @@ -130,7 +131,7 @@ export const fetchTopFinished = () => dispatch => { payload: false }) for(let i = 0; i < data.docs.length; i++) { - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -230,7 +231,7 @@ export const loadMore = () => (dispatch, getState) => { }) console.log(data) for(let i = state.songs.songs.length; i < state.songs.songs.length + data.docs.length; i++) { - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i - state.songs.songs.length].key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i - state.songs.songs.length].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ diff --git a/src/constants/urls.js b/src/constants/urls.js new file mode 100644 index 0000000..b687c90 --- /dev/null +++ b/src/constants/urls.js @@ -0,0 +1,3 @@ +export const BEATSAVER_BASE_URL = 'https://beatsaver.com' +export const BSABER_BASE_URL = 'https://bsaber.com' +export const BEATMODS_BASE_URL = 'https://beatmods.com' \ No newline at end of file From 3048206dee2218f7023603714b19411d80b53c69 Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Sun, 12 Jan 2020 05:55:31 +0100 Subject: [PATCH 6/7] Revert "Refactor hardcoded URI with constants" This reverts commit 18805e5599e940c168cfc46c7669e925b8033a7e. --- package-lock.json | 157 +++++++++++++------------------- package.json | 2 +- src/actions/detailsActions.js | 7 +- src/actions/modActions.js | 23 +++-- src/actions/playlistsActions.js | 7 +- src/actions/queueActions.js | 15 ++- src/actions/searchActions.js | 5 +- src/actions/songListActions.js | 21 ++--- src/constants/urls.js | 3 - 9 files changed, 99 insertions(+), 141 deletions(-) delete mode 100644 src/constants/urls.js diff --git a/package-lock.json b/package-lock.json index 4cd4535..77ce2d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "beatdrop", - "version": "2.5.9", + "version": "2.5.9-beta", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1533,9 +1533,9 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -3138,8 +3138,7 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3163,15 +3162,13 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3188,22 +3185,19 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3334,8 +3328,7 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3349,7 +3342,6 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3366,7 +3358,6 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3375,15 +3366,13 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "resolved": false, "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3404,7 +3393,6 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3493,8 +3481,7 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3508,7 +3495,6 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3604,8 +3590,7 @@ "version": "5.1.2", "resolved": false, "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3647,7 +3632,6 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3669,7 +3653,6 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3718,15 +3701,13 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "resolved": false, "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true, - "optional": true + "dev": true } } }, @@ -7132,8 +7113,7 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -7157,15 +7137,13 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7182,22 +7160,19 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -7328,8 +7303,7 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -7343,7 +7317,6 @@ "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7360,7 +7333,6 @@ "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7369,15 +7341,13 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7398,7 +7368,6 @@ "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -7487,8 +7456,7 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -7502,7 +7470,6 @@ "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -7598,8 +7565,7 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -7641,7 +7607,6 @@ "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7663,7 +7628,6 @@ "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7712,22 +7676,20 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "resolved": false, "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true, - "optional": true + "dev": true } } }, "fstream": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", - "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", + "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "requires": { "graceful-fs": "^4.1.2", "inherits": "~2.0.0", @@ -7980,9 +7942,9 @@ } }, "globule": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.0.tgz", - "integrity": "sha512-YlD4kdMqRCQHrhVdonet4TdRtv1/sZKepvoxNT4Nrhrp5HI8XFfc8kFlGlBn2myBo80aGp8Eft259mbcUJhgSg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.1.tgz", + "integrity": "sha512-g7QtgWF4uYSL5/dn71WxubOrS7JVGCnFPEnoeChJmBnyR9Mw8nGoEwOgJL/RC2Te0WhbsEUCejfH8SZNJ+adYQ==", "requires": { "glob": "~7.1.1", "lodash": "~4.17.10", @@ -9511,6 +9473,11 @@ "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", "dev": true }, + "lodash.assign": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", + "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=" + }, "lodash.assignin": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz", @@ -9527,6 +9494,11 @@ "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", "dev": true }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" + }, "lodash.compact": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash.compact/-/lodash.compact-3.0.1.tgz", @@ -9579,6 +9551,11 @@ "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==" }, + "lodash.mergewith": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz", + "integrity": "sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==" + }, "lodash.pick": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", @@ -10197,9 +10174,7 @@ "nan": { "version": "2.12.1", "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz", - "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==", - "dev": true, - "optional": true + "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==" }, "nanomatch": { "version": "1.2.13", @@ -10433,9 +10408,9 @@ } }, "node-sass": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.13.0.tgz", - "integrity": "sha512-W1XBrvoJ1dy7VsvTAS5q1V45lREbTlZQqFbiHb3R3OTTCma0XBtuG6xZ6Z4506nR4lmHPTqVRwxT6KgtWC97CA==", + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.11.0.tgz", + "integrity": "sha512-bHUdHTphgQJZaF1LASx0kAviPH7sGlcyNhWade4eVIpFp6tsn7SV8xNMTbsQFpEV9VXpnwTTnNYlfsZXgGgmkA==", "requires": { "async-foreach": "^0.1.3", "chalk": "^1.1.1", @@ -10444,10 +10419,12 @@ "get-stdin": "^4.0.1", "glob": "^7.0.3", "in-publish": "^2.0.0", - "lodash": "^4.17.15", + "lodash.assign": "^4.2.0", + "lodash.clonedeep": "^4.3.2", + "lodash.mergewith": "^4.6.0", "meow": "^3.7.0", "mkdirp": "^0.5.1", - "nan": "^2.13.2", + "nan": "^2.10.0", "node-gyp": "^3.8.0", "npmlog": "^4.0.0", "request": "^2.88.0", @@ -10495,16 +10472,6 @@ "ansi-regex": "^2.0.0" } }, - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" - }, - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -17020,9 +16987,9 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -17488,12 +17455,12 @@ "dev": true }, "tar": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", - "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "requires": { "block-stream": "*", - "fstream": "^1.0.12", + "fstream": "^1.0.2", "inherits": "2" } }, diff --git a/package.json b/package.json index 9bf83e6..9e71e8d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "electron-updater": "4.0.5", "get-image-colors": "^1.8.1", "md5": "^2.2.1", - "node-sass": "^4.13.0", + "node-sass": "^4.11.0", "original-fs": "^1.0.0", "react": "16.4.0", "react-contextmenu": "^2.10.0", diff --git a/src/actions/detailsActions.js b/src/actions/detailsActions.js index 5471f43..71fcc49 100644 --- a/src/actions/detailsActions.js +++ b/src/actions/detailsActions.js @@ -1,6 +1,5 @@ import { LOAD_DETAILS, CLEAR_DETAILS, SET_DETAILS_LOADING, DISPLAY_WARNING } from './types' import { SONG_DETAILS } from '../constants/views' -import { BEATSAVER_BASE_URL, BSABER_BASE_URL } from '../constants/urls' import AdmZip from 'adm-zip' import { hashAndWriteToMetadata } from './queueActions' @@ -61,7 +60,7 @@ export const loadDetailsFromKey = key => dispatch => { }) setView(SONG_DETAILS)(dispatch) if((/^[a-f0-9]+$/).test(key)) { - fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/${key}`) + fetch(`https://beatsaver.com/api/maps/detail/${key}`) .then(res => { if(res.status === 404){ dispatch({ @@ -75,7 +74,7 @@ export const loadDetailsFromKey = key => dispatch => { }) .then(res => res.json()) .then(details => { - fetch(`${BEATSAVER_BASE_URL}${details.downloadURL}`) + fetch(`https://beatsaver.com${details.downloadURL}`) .then(res => res.arrayBuffer()) .then(data => { let zip = new AdmZip(new Buffer(data)) @@ -106,7 +105,7 @@ export const loadDetailsFromKey = key => dispatch => { } }) }) - fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${key}/ratings`) + fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ diff --git a/src/actions/modActions.js b/src/actions/modActions.js index 8703565..5df931a 100644 --- a/src/actions/modActions.js +++ b/src/actions/modActions.js @@ -1,6 +1,5 @@ import { SET_MOD_LIST, SET_RESOURCE, SET_LOADING, LOAD_MOD_DETAILS, INSTALL_MOD, SET_SCANNING_FOR_MODS, SET_INSTALLED_MODS, DISPLAY_WARNING, UNINSTALL_MOD, CLEAR_MODS, ADD_TO_QUEUE, UPDATE_PROGRESS, ADD_DEPENDENT, SET_MOD_ACTIVE, ADD_PENDING_MOD, SET_PATCHING } from './types' import { MODS_VIEW, MOD_DETAILS } from '../constants/views' -import { BEATMODS_BASE_URL } from '../constants/urls' import { BEATMODS, LIBRARY } from '../constants/resources' @@ -28,7 +27,7 @@ export const fetchApprovedMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&gameVersion=${getState().settings.gameVersion}`) + fetch(`https://beatmods.com/api/v1/mod?status=approved&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -55,7 +54,7 @@ export const fetchRecommendedMods = () => (dispatch, getState) => { let recommendedMods = ['CameraPlus', 'YUR Fit Calorie Tracker', 'SyncSaber', 'Custom Sabers', 'Custom Platforms', 'Custom Avatars', 'BeatSaberTweaks', 'PracticePlugin', 'Counters+'] let mods = [] for(let i = 0; i < recommendedMods.length; i++) { - fetch(`${BEATMODS_BASE_URL}/api/v1/mod?name=${encodeURIComponent(recommendedMods[i])}&gameVersion=${getState().settings.gameVersion}`) + fetch(`https://beatmods.com/api/v1/mod?name=${encodeURIComponent(recommendedMods[i])}&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length === 0) { recommendedMods.splice(i, 1); return } @@ -100,7 +99,7 @@ export const fetchModCategory = category => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`${BEATMODS_BASE_URL}/api/v1/mod?category=${ category }&status=approved&gameVersion=${getState().settings.gameVersion}`) + fetch(`https://beatmods.com/api/v1/mod?category=${ category }&status=approved&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -124,7 +123,7 @@ export const fetchLocalMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&status=inactive`) + fetch(`https://beatmods.com/api/v1/mod?status=approved&status=inactive`) .then(res => res.json()) .then(beatModsResponse => { let installedMods = getState().mods.installedMods @@ -163,7 +162,7 @@ export const fetchActivatedMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&status=inactive`) + fetch(`https://beatmods.com/api/v1/mod?status=approved&status=inactive`) .then(res => res.json()) .then(beatModsResponse => { let activatedMods = getState().mods.installedMods.filter(mod => mod.active === true) @@ -198,7 +197,7 @@ export const loadModDetails = modId => dispatch => { type: SET_LOADING, payload: true }) - fetch(`${BEATMODS_BASE_URL}/api/v1/mod`) + fetch(`https://beatmods.com/api/v1/mod`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -241,7 +240,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge return } console.log(`Fetching ${modName} from BeatMods...`) - fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&name=${ encodeURIComponent(modName) }&gameVersion=${ getState().settings.gameVersion }`) + fetch(`https://beatmods.com/api/v1/mod?status=approved&name=${ encodeURIComponent(modName) }&gameVersion=${ getState().settings.gameVersion }`) .then(res => res.json()) .then(beatModsResponse => { console.log(`Got the BeatMods response for ${ modName }`) @@ -285,7 +284,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge // Install Mod console.log(`Installing ${ modName }...`) if(mod.downloads.some(version => version.type === 'universal')) { - req = request.get({ url: `${BEATMODS_BASE_URL}${mod.downloads.filter(version => version.type === 'universal')[0].url}`, encoding: null }, (err, r, data) => { + req = request.get({ url: `https://beatmods.com${mod.downloads.filter(version => version.type === 'universal')[0].url}`, encoding: null }, (err, r, data) => { if(r) if(err || (r.hasOwnProperty('statusCode') && r.statusCode !== 200)) { dispatch({ type: DISPLAY_WARNING, @@ -332,7 +331,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge } else { let installationType = getState().settings.installationType if(mod.downloads.some(version => version.type === installationType)) { - req = request.get({ url: `${BEATMODS_BASE_URL}${mod.downloads.filter(version => version.type === installationType)[0].url}`, encoding: null }, (err, r, data) => { + req = request.get({ url: `https://beatmods.com${mod.downloads.filter(version => version.type === installationType)[0].url}`, encoding: null }, (err, r, data) => { if(r) if(err || r.statusCode !== 200) { dispatch({ type: DISPLAY_WARNING, @@ -526,7 +525,7 @@ export const checkInstalledMods = () => (dispatch, getState) => { let md5sum = crypto.createHash('md5') md5sum.update(data) let hash = md5sum.digest('hex') - fetch(`${BEATMODS_BASE_URL}/api/v1/mod?hash=${hash}`) + fetch(`https://beatmods.com/api/v1/mod?hash=${hash}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length > 0) { @@ -582,7 +581,7 @@ export const checkInstalledMods = () => (dispatch, getState) => { let md5sum = crypto.createHash('md5') md5sum.update(data) let hash = md5sum.digest('hex') - fetch(`${BEATMODS_BASE_URL}/api/v1/mod?hash=${hash}`) + fetch(`https://beatmods.com/api/v1/mod?hash=${hash}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length > 0) { diff --git a/src/actions/playlistsActions.js b/src/actions/playlistsActions.js index c9c6e06..01a3fe2 100644 --- a/src/actions/playlistsActions.js +++ b/src/actions/playlistsActions.js @@ -1,6 +1,5 @@ import { FETCH_LOCAL_PLAYLISTS, LOAD_NEW_PLAYLIST_IMAGE, SET_NEW_PLAYLIST_OPEN, SET_PLAYLIST_PICKER_OPEN, CLEAR_PLAYLIST_DIALOG, LOAD_PLAYLIST_DETAILS, LOAD_PLAYLIST_SONGS, CLEAR_PLAYLIST_DETAILS, SET_PLAYLIST_EDITING, SET_LOADING, DISPLAY_WARNING } from './types' import { PLAYLIST_LIST, PLAYLIST_DETAILS } from '../constants/views' -import { BEATSAVER_BASE_URL } from '../constants/urls' import { defaultPlaylistIcon } from '../b64Assets' import { hashAndWriteToMetadata } from './queueActions' import { setView } from './viewActions' @@ -197,7 +196,7 @@ export const loadPlaylistDetails = playlistFile => (dispatch, getState) => { }) }) } else { - fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${playlist.songs[i].hash}`) + fetch(`https://beatsaver.com/api/maps/by-hash/${playlist.songs[i].hash}`) .then(res => res.json()) .then(song => { song.coverURL = `https://beatsaver.com/${song.coverURL}` @@ -214,10 +213,10 @@ export const loadPlaylistDetails = playlistFile => (dispatch, getState) => { }) } } else { - fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/${playlist.songs[i].key}`) + fetch(`https://beatsaver.com/api/maps/detail/${playlist.songs[i].key}`) .then(res => res.json()) .then(details => { - details.coverURL = `${BEATSAVER_BASE_URL}/${details.coverURL}` + details.coverURL = `https://beatsaver.com/${details.coverURL}` if(state.songs.downloadedSongs.some(song => song.hash === details.hash)) { let file = state.songs.downloadedSongs[state.songs.downloadedSongs.findIndex(song => song.hash === details.hash)].file fs.readFile(file, 'UTF8', (err, data) => { diff --git a/src/actions/queueActions.js b/src/actions/queueActions.js index baa9a73..60af7a5 100644 --- a/src/actions/queueActions.js +++ b/src/actions/queueActions.js @@ -1,6 +1,5 @@ import { SET_QUEUE_OPEN, ADD_TO_QUEUE, CLEAR_QUEUE, UPDATE_PROGRESS, SET_DOWNLOADED_SONGS, SET_DOWNLOADING_COUNT, SET_WAIT_LIST, DISPLAY_WARNING, SET_SCANNING_FOR_SONGS, SET_DISCOVERED_FILES, SET_PROCESSED_FILES } from './types' import { SONG_LIST } from '../constants/views' -import { BEATSAVER_BASE_URL } from '../constants/urls' import { isModInstalled, installEssentialMods } from './modActions' import { setView } from './viewActions' @@ -27,7 +26,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { if(!isModInstalled('SongLoader')(dispatch, getState)) installEssentialMods()(dispatch, getState) let hash = identity if(identity) { - fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) + fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { hash = song.hash @@ -47,7 +46,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { setTimeout(() => { document.getElementById('queue-button').classList.remove('notify') }, 1000) - fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) + fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { let utc = Date.now() @@ -57,13 +56,13 @@ export const downloadSong = (identity) => (dispatch, getState) => { payload: { utc, hash: song.hash, - image: `${BEATSAVER_BASE_URL}${ song.coverURL }`, + image: `https://beatsaver.com${ song.coverURL }`, title: song.metadata.songName, author: song.metadata.songAuthorName } }) let req = request.get({ - url: `${BEATSAVER_BASE_URL}${song.downloadURL}`, + url: `https://beatsaver.com${song.downloadURL}`, encoding: null }, (err, r, data) => { try { @@ -245,7 +244,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { setTimeout(() => { document.getElementById('queue-button').classList.remove('notify') }, 1000) - fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) + fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { let utc = Date.now() @@ -254,13 +253,13 @@ export const downloadSong = (identity) => (dispatch, getState) => { payload: { utc, hash: song.hash, - image: `${BEATSAVER_BASE_URL}${ song.coverURL }`, + image: `https://beatsaver.com${ song.coverURL }`, title: song.metadata.songName, author: song.metadata.songAuthorName } }) let req = request.get({ - url: `${BEATSAVER_BASE_URL}/${ song.downloadURL }`, + url: `https://beatsaver.com/${ song.downloadURL }`, encoding: null }, (err, r, data) => { try { diff --git a/src/actions/searchActions.js b/src/actions/searchActions.js index e375587..8bd408c 100644 --- a/src/actions/searchActions.js +++ b/src/actions/searchActions.js @@ -1,5 +1,4 @@ import { SET_SEARCH_SOURCES, SUBMIT_SEARCH, SET_LOADING } from './types' -import { BEATSAVER_BASE_URL } from '../constants/urls' const { remote } = window.require('electron') const fs = remote.require('fs') @@ -49,7 +48,7 @@ export const submitSearch = keywords => (dispatch, getState) => { localResultsReady = true // BeatSaver Search - fetch(`${BEATSAVER_BASE_URL}/api/search/text/all?q=` + encodeURIComponent(keywords.replace('/', '\\'))) + fetch('https://beatsaver.com/api/search/text/all?q=' + encodeURIComponent(keywords.replace('/', '\\'))) .then(res => res.json()) .then(data => { beatSaverSongs = data.docs @@ -69,7 +68,7 @@ export const submitSearch = keywords => (dispatch, getState) => { // BeatSaver ID Search if(isId) { - fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/` + keywords) + fetch('https://beatsaver.com/api/maps/detail/' + keywords) .then(res => { if(res.status !== 200) { beatSaverIdResultsReady = true; return } return res.json() }) .then(data => { if(!data) { beatSaverIdResultsReady = true; return } diff --git a/src/actions/songListActions.js b/src/actions/songListActions.js index 2227aa2..36d409a 100644 --- a/src/actions/songListActions.js +++ b/src/actions/songListActions.js @@ -1,7 +1,6 @@ import { FETCH_NEW, FETCH_TOP_DOWNLOADS, FETCH_TOP_FINISHED, FETCH_LOCAL_SONGS, ADD_BSABER_RATING, SET_SCROLLTOP, SET_LOADING, SET_LOADING_MORE, LOAD_MORE, SET_RESOURCE, DISPLAY_WARNING } from './types' import { SONG_LIST } from '../constants/views' import { BEATSAVER, LIBRARY } from '../constants/resources' -import { BEATSAVER_BASE_URL, BSABER_BASE_URL } from '../constants/urls' import { hashAndWriteToMetadata } from './queueActions' import { setView } from './viewActions' @@ -10,9 +9,9 @@ const fs = remote.require('fs') const path = remote.require('path') const resourceUrl = { - 'BEATSAVER_NEW_SONGS': `${BEATSAVER_BASE_URL}/api/maps/latest`, - 'BEATSAVER_TOP_DOWNLOADED_SONGS': `${BEATSAVER_BASE_URL}/api/maps/downloads`, - 'BEATSAVER_TOP_FINISHED_SONGS': `${BEATSAVER_BASE_URL}/api/maps/plays` + 'BEATSAVER_NEW_SONGS': 'https://beatsaver.com/api/maps/latest', + 'BEATSAVER_TOP_DOWNLOADED_SONGS': 'https://beatsaver.com/api/maps/downloads', + 'BEATSAVER_TOP_FINISHED_SONGS': 'https://beatsaver.com/api/maps/plays' } export const fetchNew = () => dispatch => { @@ -29,7 +28,7 @@ export const fetchNew = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.NEW_SONGS }) - fetch(`${BEATSAVER_BASE_URL}api/maps/latest`) + fetch('https://beatsaver.com/api/maps/latest') .then(res => res.json()) .then(data => { console.log(data) @@ -43,7 +42,7 @@ export const fetchNew = () => dispatch => { }) console.log(data); for(let i = 0; i < data.docs.length; i++) { - fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -75,7 +74,7 @@ export const fetchTopDownloads = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.TOP_DOWNLOADED_SONGS }) - fetch(`${BEATSAVER_BASE_URL}/api/maps/downloads`) + fetch('https://beatsaver.com/api/maps/downloads') .then(res => res.json()) .then(data => { dispatch({ @@ -87,7 +86,7 @@ export const fetchTopDownloads = () => dispatch => { payload: false }) for(let i = 0; i < data.songs.length; i++) { - fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -119,7 +118,7 @@ export const fetchTopFinished = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.TOP_FINISHED_SONGS }) - fetch(`${BEATSAVER_BASE_URL}/api/maps/plays`) + fetch('https://beatsaver.com/api/maps/plays') .then(res => res.json()) .then(data => { dispatch({ @@ -131,7 +130,7 @@ export const fetchTopFinished = () => dispatch => { payload: false }) for(let i = 0; i < data.docs.length; i++) { - fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -231,7 +230,7 @@ export const loadMore = () => (dispatch, getState) => { }) console.log(data) for(let i = state.songs.songs.length; i < state.songs.songs.length + data.docs.length; i++) { - fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i - state.songs.songs.length].key}/ratings`) + fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i - state.songs.songs.length].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ diff --git a/src/constants/urls.js b/src/constants/urls.js deleted file mode 100644 index b687c90..0000000 --- a/src/constants/urls.js +++ /dev/null @@ -1,3 +0,0 @@ -export const BEATSAVER_BASE_URL = 'https://beatsaver.com' -export const BSABER_BASE_URL = 'https://bsaber.com' -export const BEATMODS_BASE_URL = 'https://beatmods.com' \ No newline at end of file From e2d1648106df37c59bba31c68c2218c30ba3562b Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Sun, 12 Jan 2020 06:07:22 +0100 Subject: [PATCH 7/7] Refactor hardcoded URI with constants --- src/actions/detailsActions.js | 7 ++++--- src/actions/modActions.js | 23 ++++++++++++----------- src/actions/playlistsActions.js | 7 ++++--- src/actions/queueActions.js | 15 ++++++++------- src/actions/searchActions.js | 5 +++-- src/actions/songListActions.js | 21 +++++++++++---------- src/constants/urls.js | 3 +++ 7 files changed, 45 insertions(+), 36 deletions(-) create mode 100644 src/constants/urls.js diff --git a/src/actions/detailsActions.js b/src/actions/detailsActions.js index 71fcc49..5471f43 100644 --- a/src/actions/detailsActions.js +++ b/src/actions/detailsActions.js @@ -1,5 +1,6 @@ import { LOAD_DETAILS, CLEAR_DETAILS, SET_DETAILS_LOADING, DISPLAY_WARNING } from './types' import { SONG_DETAILS } from '../constants/views' +import { BEATSAVER_BASE_URL, BSABER_BASE_URL } from '../constants/urls' import AdmZip from 'adm-zip' import { hashAndWriteToMetadata } from './queueActions' @@ -60,7 +61,7 @@ export const loadDetailsFromKey = key => dispatch => { }) setView(SONG_DETAILS)(dispatch) if((/^[a-f0-9]+$/).test(key)) { - fetch(`https://beatsaver.com/api/maps/detail/${key}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/${key}`) .then(res => { if(res.status === 404){ dispatch({ @@ -74,7 +75,7 @@ export const loadDetailsFromKey = key => dispatch => { }) .then(res => res.json()) .then(details => { - fetch(`https://beatsaver.com${details.downloadURL}`) + fetch(`${BEATSAVER_BASE_URL}${details.downloadURL}`) .then(res => res.arrayBuffer()) .then(data => { let zip = new AdmZip(new Buffer(data)) @@ -105,7 +106,7 @@ export const loadDetailsFromKey = key => dispatch => { } }) }) - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ diff --git a/src/actions/modActions.js b/src/actions/modActions.js index 5df931a..8703565 100644 --- a/src/actions/modActions.js +++ b/src/actions/modActions.js @@ -1,5 +1,6 @@ import { SET_MOD_LIST, SET_RESOURCE, SET_LOADING, LOAD_MOD_DETAILS, INSTALL_MOD, SET_SCANNING_FOR_MODS, SET_INSTALLED_MODS, DISPLAY_WARNING, UNINSTALL_MOD, CLEAR_MODS, ADD_TO_QUEUE, UPDATE_PROGRESS, ADD_DEPENDENT, SET_MOD_ACTIVE, ADD_PENDING_MOD, SET_PATCHING } from './types' import { MODS_VIEW, MOD_DETAILS } from '../constants/views' +import { BEATMODS_BASE_URL } from '../constants/urls' import { BEATMODS, LIBRARY } from '../constants/resources' @@ -27,7 +28,7 @@ export const fetchApprovedMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod?status=approved&gameVersion=${getState().settings.gameVersion}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -54,7 +55,7 @@ export const fetchRecommendedMods = () => (dispatch, getState) => { let recommendedMods = ['CameraPlus', 'YUR Fit Calorie Tracker', 'SyncSaber', 'Custom Sabers', 'Custom Platforms', 'Custom Avatars', 'BeatSaberTweaks', 'PracticePlugin', 'Counters+'] let mods = [] for(let i = 0; i < recommendedMods.length; i++) { - fetch(`https://beatmods.com/api/v1/mod?name=${encodeURIComponent(recommendedMods[i])}&gameVersion=${getState().settings.gameVersion}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?name=${encodeURIComponent(recommendedMods[i])}&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length === 0) { recommendedMods.splice(i, 1); return } @@ -99,7 +100,7 @@ export const fetchModCategory = category => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod?category=${ category }&status=approved&gameVersion=${getState().settings.gameVersion}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?category=${ category }&status=approved&gameVersion=${getState().settings.gameVersion}`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -123,7 +124,7 @@ export const fetchLocalMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod?status=approved&status=inactive`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&status=inactive`) .then(res => res.json()) .then(beatModsResponse => { let installedMods = getState().mods.installedMods @@ -162,7 +163,7 @@ export const fetchActivatedMods = () => (dispatch, getState) => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod?status=approved&status=inactive`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&status=inactive`) .then(res => res.json()) .then(beatModsResponse => { let activatedMods = getState().mods.installedMods.filter(mod => mod.active === true) @@ -197,7 +198,7 @@ export const loadModDetails = modId => dispatch => { type: SET_LOADING, payload: true }) - fetch(`https://beatmods.com/api/v1/mod`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod`) .then(res => res.json()) .then(beatModsResponse => { dispatch({ @@ -240,7 +241,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge return } console.log(`Fetching ${modName} from BeatMods...`) - fetch(`https://beatmods.com/api/v1/mod?status=approved&name=${ encodeURIComponent(modName) }&gameVersion=${ getState().settings.gameVersion }`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?status=approved&name=${ encodeURIComponent(modName) }&gameVersion=${ getState().settings.gameVersion }`) .then(res => res.json()) .then(beatModsResponse => { console.log(`Got the BeatMods response for ${ modName }`) @@ -284,7 +285,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge // Install Mod console.log(`Installing ${ modName }...`) if(mod.downloads.some(version => version.type === 'universal')) { - req = request.get({ url: `https://beatmods.com${mod.downloads.filter(version => version.type === 'universal')[0].url}`, encoding: null }, (err, r, data) => { + req = request.get({ url: `${BEATMODS_BASE_URL}${mod.downloads.filter(version => version.type === 'universal')[0].url}`, encoding: null }, (err, r, data) => { if(r) if(err || (r.hasOwnProperty('statusCode') && r.statusCode !== 200)) { dispatch({ type: DISPLAY_WARNING, @@ -331,7 +332,7 @@ export const installMod = (modName, version, dependencyOf = '') => (dispatch, ge } else { let installationType = getState().settings.installationType if(mod.downloads.some(version => version.type === installationType)) { - req = request.get({ url: `https://beatmods.com${mod.downloads.filter(version => version.type === installationType)[0].url}`, encoding: null }, (err, r, data) => { + req = request.get({ url: `${BEATMODS_BASE_URL}${mod.downloads.filter(version => version.type === installationType)[0].url}`, encoding: null }, (err, r, data) => { if(r) if(err || r.statusCode !== 200) { dispatch({ type: DISPLAY_WARNING, @@ -525,7 +526,7 @@ export const checkInstalledMods = () => (dispatch, getState) => { let md5sum = crypto.createHash('md5') md5sum.update(data) let hash = md5sum.digest('hex') - fetch(`https://beatmods.com/api/v1/mod?hash=${hash}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?hash=${hash}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length > 0) { @@ -581,7 +582,7 @@ export const checkInstalledMods = () => (dispatch, getState) => { let md5sum = crypto.createHash('md5') md5sum.update(data) let hash = md5sum.digest('hex') - fetch(`https://beatmods.com/api/v1/mod?hash=${hash}`) + fetch(`${BEATMODS_BASE_URL}/api/v1/mod?hash=${hash}`) .then(res => res.json()) .then(beatModsResponse => { if(beatModsResponse.length > 0) { diff --git a/src/actions/playlistsActions.js b/src/actions/playlistsActions.js index 01a3fe2..c9c6e06 100644 --- a/src/actions/playlistsActions.js +++ b/src/actions/playlistsActions.js @@ -1,5 +1,6 @@ import { FETCH_LOCAL_PLAYLISTS, LOAD_NEW_PLAYLIST_IMAGE, SET_NEW_PLAYLIST_OPEN, SET_PLAYLIST_PICKER_OPEN, CLEAR_PLAYLIST_DIALOG, LOAD_PLAYLIST_DETAILS, LOAD_PLAYLIST_SONGS, CLEAR_PLAYLIST_DETAILS, SET_PLAYLIST_EDITING, SET_LOADING, DISPLAY_WARNING } from './types' import { PLAYLIST_LIST, PLAYLIST_DETAILS } from '../constants/views' +import { BEATSAVER_BASE_URL } from '../constants/urls' import { defaultPlaylistIcon } from '../b64Assets' import { hashAndWriteToMetadata } from './queueActions' import { setView } from './viewActions' @@ -196,7 +197,7 @@ export const loadPlaylistDetails = playlistFile => (dispatch, getState) => { }) }) } else { - fetch(`https://beatsaver.com/api/maps/by-hash/${playlist.songs[i].hash}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${playlist.songs[i].hash}`) .then(res => res.json()) .then(song => { song.coverURL = `https://beatsaver.com/${song.coverURL}` @@ -213,10 +214,10 @@ export const loadPlaylistDetails = playlistFile => (dispatch, getState) => { }) } } else { - fetch(`https://beatsaver.com/api/maps/detail/${playlist.songs[i].key}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/${playlist.songs[i].key}`) .then(res => res.json()) .then(details => { - details.coverURL = `https://beatsaver.com/${details.coverURL}` + details.coverURL = `${BEATSAVER_BASE_URL}/${details.coverURL}` if(state.songs.downloadedSongs.some(song => song.hash === details.hash)) { let file = state.songs.downloadedSongs[state.songs.downloadedSongs.findIndex(song => song.hash === details.hash)].file fs.readFile(file, 'UTF8', (err, data) => { diff --git a/src/actions/queueActions.js b/src/actions/queueActions.js index 60af7a5..baa9a73 100644 --- a/src/actions/queueActions.js +++ b/src/actions/queueActions.js @@ -1,5 +1,6 @@ import { SET_QUEUE_OPEN, ADD_TO_QUEUE, CLEAR_QUEUE, UPDATE_PROGRESS, SET_DOWNLOADED_SONGS, SET_DOWNLOADING_COUNT, SET_WAIT_LIST, DISPLAY_WARNING, SET_SCANNING_FOR_SONGS, SET_DISCOVERED_FILES, SET_PROCESSED_FILES } from './types' import { SONG_LIST } from '../constants/views' +import { BEATSAVER_BASE_URL } from '../constants/urls' import { isModInstalled, installEssentialMods } from './modActions' import { setView } from './viewActions' @@ -26,7 +27,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { if(!isModInstalled('SongLoader')(dispatch, getState)) installEssentialMods()(dispatch, getState) let hash = identity if(identity) { - fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { hash = song.hash @@ -46,7 +47,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { setTimeout(() => { document.getElementById('queue-button').classList.remove('notify') }, 1000) - fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { let utc = Date.now() @@ -56,13 +57,13 @@ export const downloadSong = (identity) => (dispatch, getState) => { payload: { utc, hash: song.hash, - image: `https://beatsaver.com${ song.coverURL }`, + image: `${BEATSAVER_BASE_URL}${ song.coverURL }`, title: song.metadata.songName, author: song.metadata.songAuthorName } }) let req = request.get({ - url: `https://beatsaver.com${song.downloadURL}`, + url: `${BEATSAVER_BASE_URL}${song.downloadURL}`, encoding: null }, (err, r, data) => { try { @@ -244,7 +245,7 @@ export const downloadSong = (identity) => (dispatch, getState) => { setTimeout(() => { document.getElementById('queue-button').classList.remove('notify') }, 1000) - fetch(`https://beatsaver.com/api/maps/by-hash/${hash}`) + fetch(`${BEATSAVER_BASE_URL}/api/maps/by-hash/${hash}`) .then(res => res.json()) .then(song => { let utc = Date.now() @@ -253,13 +254,13 @@ export const downloadSong = (identity) => (dispatch, getState) => { payload: { utc, hash: song.hash, - image: `https://beatsaver.com${ song.coverURL }`, + image: `${BEATSAVER_BASE_URL}${ song.coverURL }`, title: song.metadata.songName, author: song.metadata.songAuthorName } }) let req = request.get({ - url: `https://beatsaver.com/${ song.downloadURL }`, + url: `${BEATSAVER_BASE_URL}/${ song.downloadURL }`, encoding: null }, (err, r, data) => { try { diff --git a/src/actions/searchActions.js b/src/actions/searchActions.js index 8bd408c..e375587 100644 --- a/src/actions/searchActions.js +++ b/src/actions/searchActions.js @@ -1,4 +1,5 @@ import { SET_SEARCH_SOURCES, SUBMIT_SEARCH, SET_LOADING } from './types' +import { BEATSAVER_BASE_URL } from '../constants/urls' const { remote } = window.require('electron') const fs = remote.require('fs') @@ -48,7 +49,7 @@ export const submitSearch = keywords => (dispatch, getState) => { localResultsReady = true // BeatSaver Search - fetch('https://beatsaver.com/api/search/text/all?q=' + encodeURIComponent(keywords.replace('/', '\\'))) + fetch(`${BEATSAVER_BASE_URL}/api/search/text/all?q=` + encodeURIComponent(keywords.replace('/', '\\'))) .then(res => res.json()) .then(data => { beatSaverSongs = data.docs @@ -68,7 +69,7 @@ export const submitSearch = keywords => (dispatch, getState) => { // BeatSaver ID Search if(isId) { - fetch('https://beatsaver.com/api/maps/detail/' + keywords) + fetch(`${BEATSAVER_BASE_URL}/api/maps/detail/` + keywords) .then(res => { if(res.status !== 200) { beatSaverIdResultsReady = true; return } return res.json() }) .then(data => { if(!data) { beatSaverIdResultsReady = true; return } diff --git a/src/actions/songListActions.js b/src/actions/songListActions.js index 36d409a..2227aa2 100644 --- a/src/actions/songListActions.js +++ b/src/actions/songListActions.js @@ -1,6 +1,7 @@ import { FETCH_NEW, FETCH_TOP_DOWNLOADS, FETCH_TOP_FINISHED, FETCH_LOCAL_SONGS, ADD_BSABER_RATING, SET_SCROLLTOP, SET_LOADING, SET_LOADING_MORE, LOAD_MORE, SET_RESOURCE, DISPLAY_WARNING } from './types' import { SONG_LIST } from '../constants/views' import { BEATSAVER, LIBRARY } from '../constants/resources' +import { BEATSAVER_BASE_URL, BSABER_BASE_URL } from '../constants/urls' import { hashAndWriteToMetadata } from './queueActions' import { setView } from './viewActions' @@ -9,9 +10,9 @@ const fs = remote.require('fs') const path = remote.require('path') const resourceUrl = { - 'BEATSAVER_NEW_SONGS': 'https://beatsaver.com/api/maps/latest', - 'BEATSAVER_TOP_DOWNLOADED_SONGS': 'https://beatsaver.com/api/maps/downloads', - 'BEATSAVER_TOP_FINISHED_SONGS': 'https://beatsaver.com/api/maps/plays' + 'BEATSAVER_NEW_SONGS': `${BEATSAVER_BASE_URL}/api/maps/latest`, + 'BEATSAVER_TOP_DOWNLOADED_SONGS': `${BEATSAVER_BASE_URL}/api/maps/downloads`, + 'BEATSAVER_TOP_FINISHED_SONGS': `${BEATSAVER_BASE_URL}/api/maps/plays` } export const fetchNew = () => dispatch => { @@ -28,7 +29,7 @@ export const fetchNew = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.NEW_SONGS }) - fetch('https://beatsaver.com/api/maps/latest') + fetch(`${BEATSAVER_BASE_URL}api/maps/latest`) .then(res => res.json()) .then(data => { console.log(data) @@ -42,7 +43,7 @@ export const fetchNew = () => dispatch => { }) console.log(data); for(let i = 0; i < data.docs.length; i++) { - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -74,7 +75,7 @@ export const fetchTopDownloads = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.TOP_DOWNLOADED_SONGS }) - fetch('https://beatsaver.com/api/maps/downloads') + fetch(`${BEATSAVER_BASE_URL}/api/maps/downloads`) .then(res => res.json()) .then(data => { dispatch({ @@ -86,7 +87,7 @@ export const fetchTopDownloads = () => dispatch => { payload: false }) for(let i = 0; i < data.songs.length; i++) { - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -118,7 +119,7 @@ export const fetchTopFinished = () => dispatch => { type: SET_RESOURCE, payload: BEATSAVER.TOP_FINISHED_SONGS }) - fetch('https://beatsaver.com/api/maps/plays') + fetch(`${BEATSAVER_BASE_URL}/api/maps/plays`) .then(res => res.json()) .then(data => { dispatch({ @@ -130,7 +131,7 @@ export const fetchTopFinished = () => dispatch => { payload: false }) for(let i = 0; i < data.docs.length; i++) { - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ @@ -230,7 +231,7 @@ export const loadMore = () => (dispatch, getState) => { }) console.log(data) for(let i = state.songs.songs.length; i < state.songs.songs.length + data.docs.length; i++) { - fetch(`https://bsaber.com/wp-json/bsaber-api/songs/${data.docs[i - state.songs.songs.length].key}/ratings`) + fetch(`${BSABER_BASE_URL}/wp-json/bsaber-api/songs/${data.docs[i - state.songs.songs.length].key}/ratings`) .then(res => res.json()) .then(bsaberData => { dispatch({ diff --git a/src/constants/urls.js b/src/constants/urls.js new file mode 100644 index 0000000..b687c90 --- /dev/null +++ b/src/constants/urls.js @@ -0,0 +1,3 @@ +export const BEATSAVER_BASE_URL = 'https://beatsaver.com' +export const BSABER_BASE_URL = 'https://bsaber.com' +export const BEATMODS_BASE_URL = 'https://beatmods.com' \ No newline at end of file