comty.js 0.60.3 → 0.60.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/handleAfterRequest.js +0 -0
- package/dist/helpers/handleBeforeRequest.js +0 -0
- package/dist/helpers/withSettings.js +0 -0
- package/dist/helpers/withStorage.js +0 -0
- package/dist/hooks/useRequest/index.js +0 -0
- package/dist/index.js +0 -0
- package/dist/models/api/index.js +78 -0
- package/dist/models/auth/index.js +0 -0
- package/dist/models/feed/index.js +0 -0
- package/dist/models/follows/index.js +0 -0
- package/dist/models/index.js +0 -0
- package/dist/models/music/index.js +35 -310
- package/dist/models/music/setters/deleteRelease.js +11 -0
- package/dist/models/music/setters/index.js +36 -0
- package/dist/models/music/setters/putRelease.js +12 -0
- package/dist/models/music/setters/putTrack.js +12 -0
- package/dist/models/nfc/index.js +16 -3
- package/dist/models/payments/index.js +17 -0
- package/dist/models/post/index.js +11 -3
- package/dist/models/search/index.js +0 -0
- package/dist/models/session/index.js +9 -7
- package/dist/models/spectrum/index.js +96 -0
- package/dist/models/sync/index.js +0 -0
- package/dist/models/sync/services/spotify.js +0 -0
- package/dist/models/sync/services/tidal.js +0 -0
- package/dist/models/user/index.js +0 -0
- package/dist/remote.js +5 -1
- package/package.json +2 -2
- package/dist/handlers/measurePing.js +0 -58
- package/dist/handlers/request.js +0 -51
- package/dist/helpers/handleRegenerationEvent.js +0 -43
- package/dist/models/livestream/index.js +0 -84
- package/dist/models/playlists/index.js +0 -124
- package/dist/models/sync/cores/spotifyCore.js +0 -87
- package/dist/models/sync/services/vrc.js +0 -121
- package/dist/models/widget/index.js +0 -18
- package/dist/remotes.js +0 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _jwtdecode = require('jwt-decode');
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _jwtdecode = require('jwt-decode');
|
|
2
2
|
var _request = require('../../request'); var _request2 = _interopRequireDefault(_request);
|
|
3
3
|
var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _interopRequireDefault(_withStorage);
|
|
4
4
|
|
|
@@ -79,7 +79,7 @@ var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _in
|
|
|
79
79
|
static getDecodedToken() {
|
|
80
80
|
const token = this.token
|
|
81
81
|
|
|
82
|
-
return token &&
|
|
82
|
+
return token && _jwtdecode.jwtDecode.call(void 0, token)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
@@ -124,14 +124,16 @@ var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _in
|
|
|
124
124
|
*
|
|
125
125
|
* @return {Promise<Object>} The token validation data.
|
|
126
126
|
*/
|
|
127
|
-
static async
|
|
128
|
-
|
|
127
|
+
static async authToken(token) {
|
|
128
|
+
if (!token) {
|
|
129
|
+
token = await Session.token
|
|
130
|
+
}
|
|
129
131
|
|
|
130
132
|
const response = await _request2.default.call(void 0, {
|
|
131
|
-
method: "
|
|
132
|
-
url: "/
|
|
133
|
+
method: "POST",
|
|
134
|
+
url: "/auth/token",
|
|
133
135
|
data: {
|
|
134
|
-
|
|
136
|
+
token: token
|
|
135
137
|
}
|
|
136
138
|
})
|
|
137
139
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
|
|
2
|
+
var _session = require('../session'); var _session2 = _interopRequireDefault(_session);
|
|
3
|
+
|
|
4
|
+
class Streaming {
|
|
5
|
+
static __initStatic() {this.apiHostname = process.env.NODE_ENV === "production" ? "https://live.ragestudio.net" : "https://fr01.ragestudio.net:8035"}
|
|
6
|
+
|
|
7
|
+
static get base() {
|
|
8
|
+
const baseInstance = _axios2.default.create({
|
|
9
|
+
baseURL: Streaming.apiHostname,
|
|
10
|
+
headers: {
|
|
11
|
+
"Accept": "application/json",
|
|
12
|
+
"ngrok-skip-browser-warning":"any"
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
if (_session2.default.token) {
|
|
17
|
+
baseInstance.defaults.headers.common["Authorization"] = `Bearer ${_session2.default.token}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return baseInstance
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static async serverInfo() {
|
|
24
|
+
const { data } = await Streaming.base({
|
|
25
|
+
method: "get",
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
...data,
|
|
30
|
+
hostname: Streaming.apiHostname
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static async getOwnProfiles() {
|
|
35
|
+
const { data } = await Streaming.base({
|
|
36
|
+
method: "get",
|
|
37
|
+
url: "/streaming/profiles/self",
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
return data
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static async getProfile({ profile_id }) {
|
|
44
|
+
if (!profile_id) {
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { data } = await Streaming.base({
|
|
49
|
+
method: "get",
|
|
50
|
+
url: `/streaming/profiles/${profile_id}`,
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return data
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static async getStream({ profile_id }) {
|
|
57
|
+
if (!profile_id) {
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { data } = await Streaming.base({
|
|
62
|
+
method: "get",
|
|
63
|
+
url: `/streaming/${profile_id}`,
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
return data
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static async deleteProfile({ profile_id }) {
|
|
70
|
+
if (!profile_id) {
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const { data } = await Streaming.base({
|
|
75
|
+
method: "delete",
|
|
76
|
+
url: `/streaming/profiles/${profile_id}`,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
return data
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static async createOrUpdateStream(update) {
|
|
83
|
+
const { data } = await Streaming.base({
|
|
84
|
+
method: "put",
|
|
85
|
+
url: `/streaming/profiles/self`,
|
|
86
|
+
data: update,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
return data
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static async getConnectionStatus({ profile_id }) {
|
|
93
|
+
console.warn("getConnectionStatus() | Not implemented")
|
|
94
|
+
return false
|
|
95
|
+
}
|
|
96
|
+
} Streaming.__initStatic(); exports.default = Streaming;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/remote.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comty.js",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "RageStudio <support@ragestudio.net>",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"axios": "^1.4.0",
|
|
18
18
|
"js-cookie": "^3.0.5",
|
|
19
19
|
"jsonwebtoken": "^9.0.0",
|
|
20
|
-
"jwt-decode": "^
|
|
20
|
+
"jwt-decode": "^4.0.0",
|
|
21
21
|
"luxon": "^3.3.0",
|
|
22
22
|
"socket.io-client": "^4.6.1"
|
|
23
23
|
},
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('./request'); var _request2 = _interopRequireDefault(_request);
|
|
2
|
-
|
|
3
|
-
exports. default = async () => {
|
|
4
|
-
const timings = {}
|
|
5
|
-
|
|
6
|
-
const promises = [
|
|
7
|
-
new Promise(async (resolve) => {
|
|
8
|
-
const start = Date.now()
|
|
9
|
-
|
|
10
|
-
const failTimeout = setTimeout(() => {
|
|
11
|
-
timings.http = "failed"
|
|
12
|
-
|
|
13
|
-
resolve()
|
|
14
|
-
}, 10000)
|
|
15
|
-
|
|
16
|
-
_request2.default.call(void 0, {
|
|
17
|
-
method: "GET",
|
|
18
|
-
url: "/ping",
|
|
19
|
-
})
|
|
20
|
-
.then(() => {
|
|
21
|
-
// set http timing in ms
|
|
22
|
-
timings.http = Date.now() - start
|
|
23
|
-
|
|
24
|
-
failTimeout && clearTimeout(failTimeout)
|
|
25
|
-
|
|
26
|
-
resolve()
|
|
27
|
-
})
|
|
28
|
-
.catch(() => {
|
|
29
|
-
timings.http = "failed"
|
|
30
|
-
|
|
31
|
-
resolve()
|
|
32
|
-
})
|
|
33
|
-
}),
|
|
34
|
-
new Promise((resolve) => {
|
|
35
|
-
const start = Date.now()
|
|
36
|
-
|
|
37
|
-
const failTimeout = setTimeout(() => {
|
|
38
|
-
timings.ws = "failed"
|
|
39
|
-
|
|
40
|
-
resolve()
|
|
41
|
-
}, 10000)
|
|
42
|
-
|
|
43
|
-
__comty_shared_state.wsInstances["default"].on("pong", () => {
|
|
44
|
-
timings.ws = Date.now() - start
|
|
45
|
-
|
|
46
|
-
failTimeout && clearTimeout(failTimeout)
|
|
47
|
-
|
|
48
|
-
resolve()
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
__comty_shared_state.wsInstances["default"].emit("ping")
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
|
|
55
|
-
await Promise.all(promises)
|
|
56
|
-
|
|
57
|
-
return timings
|
|
58
|
-
}
|
package/dist/handlers/request.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _handleBeforeRequest = require('../helpers/handleBeforeRequest'); var _handleBeforeRequest2 = _interopRequireDefault(_handleBeforeRequest);
|
|
2
|
-
var _handleAfterRequest = require('../helpers/handleAfterRequest'); var _handleAfterRequest2 = _interopRequireDefault(_handleAfterRequest);
|
|
3
|
-
|
|
4
|
-
exports. default = async (
|
|
5
|
-
request = {
|
|
6
|
-
method: "GET",
|
|
7
|
-
},
|
|
8
|
-
...args
|
|
9
|
-
) => {
|
|
10
|
-
const instance = _nullishCoalesce(request.instance, () => ( __comty_shared_state.instances.default))
|
|
11
|
-
|
|
12
|
-
if (!instance) {
|
|
13
|
-
throw new Error("No instance provided")
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// handle before request
|
|
17
|
-
await _handleBeforeRequest2.default.call(void 0, request)
|
|
18
|
-
|
|
19
|
-
if (typeof request === "string") {
|
|
20
|
-
request = {
|
|
21
|
-
url: request,
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (typeof request.headers !== "object") {
|
|
26
|
-
request.headers = {}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let result = null
|
|
30
|
-
|
|
31
|
-
const makeRequest = async () => {
|
|
32
|
-
const _result = await instance(request, ...args)
|
|
33
|
-
.catch((error) => {
|
|
34
|
-
return error
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
result = _result
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
await makeRequest()
|
|
41
|
-
|
|
42
|
-
// handle after request
|
|
43
|
-
await _handleAfterRequest2.default.call(void 0, result, makeRequest)
|
|
44
|
-
|
|
45
|
-
// if error, throw it
|
|
46
|
-
if (result instanceof Error) {
|
|
47
|
-
throw result
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return result
|
|
51
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _session = require('../models/session'); var _session2 = _interopRequireDefault(_session);
|
|
2
|
-
var _request = require('../handlers/request'); var _request2 = _interopRequireDefault(_request);
|
|
3
|
-
var _ = require('../');
|
|
4
|
-
|
|
5
|
-
exports. default = async (refreshToken) => {
|
|
6
|
-
__comty_shared_state.eventBus.emit("session.expiredExceptionEvent", refreshToken)
|
|
7
|
-
|
|
8
|
-
__comty_shared_state.onExpiredExceptionEvent = true
|
|
9
|
-
|
|
10
|
-
const expiredToken = await _session2.default.token
|
|
11
|
-
|
|
12
|
-
// send request to regenerate token
|
|
13
|
-
const response = await _request2.default.call(void 0, {
|
|
14
|
-
method: "POST",
|
|
15
|
-
url: "/session/regenerate",
|
|
16
|
-
data: {
|
|
17
|
-
expiredToken: expiredToken,
|
|
18
|
-
refreshToken,
|
|
19
|
-
}
|
|
20
|
-
}).catch((error) => {
|
|
21
|
-
console.error(`Failed to regenerate token: ${error.message}`)
|
|
22
|
-
return false
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
if (!response) {
|
|
26
|
-
return __comty_shared_state.eventBus.emit("session.invalid", "Failed to regenerate token")
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!_optionalChain([response, 'access', _3 => _3.data, 'optionalAccess', _4 => _4.token])) {
|
|
30
|
-
return __comty_shared_state.eventBus.emit("session.invalid", "Failed to regenerate token, invalid server response.")
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// set new token
|
|
34
|
-
_session2.default.token = response.data.token
|
|
35
|
-
|
|
36
|
-
__comty_shared_state.onExpiredExceptionEvent = false
|
|
37
|
-
|
|
38
|
-
// emit event
|
|
39
|
-
__comty_shared_state.eventBus.emit("session.regenerated")
|
|
40
|
-
|
|
41
|
-
// reconnect websockets
|
|
42
|
-
_.reconnectWebsockets.call(void 0, )
|
|
43
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
|
|
2
|
-
|
|
3
|
-
class Livestream {
|
|
4
|
-
static __initStatic() {this.deleteProfile = async (profile_id) => {
|
|
5
|
-
const response = await _request2.default.call(void 0, {
|
|
6
|
-
method: "DELETE",
|
|
7
|
-
url: `/tv/streaming/profile`,
|
|
8
|
-
data: {
|
|
9
|
-
profile_id
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
return response.data
|
|
14
|
-
}}
|
|
15
|
-
|
|
16
|
-
static __initStatic2() {this.postProfile = async (payload) => {
|
|
17
|
-
const response = await _request2.default.call(void 0, {
|
|
18
|
-
method: "POST",
|
|
19
|
-
url: `/tv/streaming/profile`,
|
|
20
|
-
data: payload,
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
return response.data
|
|
24
|
-
}}
|
|
25
|
-
|
|
26
|
-
static __initStatic3() {this.getProfiles = async () => {
|
|
27
|
-
const response = await _request2.default.call(void 0, {
|
|
28
|
-
method: "GET",
|
|
29
|
-
url: `/tv/streaming/profiles`,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
return response.data
|
|
33
|
-
}}
|
|
34
|
-
|
|
35
|
-
static __initStatic4() {this.regenerateStreamingKey = async (profile_id) => {
|
|
36
|
-
const response = await _request2.default.call(void 0, {
|
|
37
|
-
method: "POST",
|
|
38
|
-
url: `/tv/streaming/regenerate_key`,
|
|
39
|
-
data: {
|
|
40
|
-
profile_id
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
return response.data
|
|
45
|
-
}}
|
|
46
|
-
|
|
47
|
-
static __initStatic5() {this.getCategories = async (key) => {
|
|
48
|
-
const response = await _request2.default.call(void 0, {
|
|
49
|
-
method: "GET",
|
|
50
|
-
url: `/tv/streaming/categories`,
|
|
51
|
-
params: {
|
|
52
|
-
key,
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
return response.data
|
|
57
|
-
}}
|
|
58
|
-
|
|
59
|
-
static __initStatic6() {this.getLivestream = async (payload = {}) => {
|
|
60
|
-
if (!payload.username) {
|
|
61
|
-
throw new Error("Username is required")
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let response = await _request2.default.call(void 0, {
|
|
65
|
-
method: "GET",
|
|
66
|
-
url: `/tv/streams`,
|
|
67
|
-
params: {
|
|
68
|
-
username: payload.username,
|
|
69
|
-
profile_id: payload.profile_id,
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
return response.data
|
|
74
|
-
}}
|
|
75
|
-
|
|
76
|
-
static __initStatic7() {this.getLivestreams = async () => {
|
|
77
|
-
const response = await _request2.default.call(void 0, {
|
|
78
|
-
method: "GET",
|
|
79
|
-
url: `/tv/streams`,
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
return response.data
|
|
83
|
-
}}
|
|
84
|
-
} Livestream.__initStatic(); Livestream.__initStatic2(); Livestream.__initStatic3(); Livestream.__initStatic4(); Livestream.__initStatic5(); Livestream.__initStatic6(); Livestream.__initStatic7(); exports.default = Livestream;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
|
|
2
|
-
|
|
3
|
-
class PlaylistsModel {
|
|
4
|
-
static get api_instance() {
|
|
5
|
-
return globalThis.__comty_shared_state.instances["music"]
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
static __initStatic() {this.refreshTrackCache = async (track_id) => {
|
|
9
|
-
if (!track_id) {
|
|
10
|
-
throw new Error("Track ID is required")
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const { data } = await _request2.default.call(void 0, {
|
|
14
|
-
instance: PlaylistsModel.api_instance,
|
|
15
|
-
method: "POST",
|
|
16
|
-
url: `/tracks/${track_id}/refresh-cache`,
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
return data
|
|
20
|
-
}}
|
|
21
|
-
|
|
22
|
-
static __initStatic2() {this.putPlaylist = async (payload) => {
|
|
23
|
-
if (!payload) {
|
|
24
|
-
throw new Error("Payload is required")
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const { data } = await _request2.default.call(void 0, {
|
|
28
|
-
instance: PlaylistsModel.api_instance,
|
|
29
|
-
method: "PUT",
|
|
30
|
-
url: `/playlists/playlist`,
|
|
31
|
-
data: payload,
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
return data
|
|
35
|
-
}}
|
|
36
|
-
|
|
37
|
-
static __initStatic3() {this.deletePlaylist = async (id, options = {}) => {
|
|
38
|
-
if (!id) {
|
|
39
|
-
throw new Error("ID is required")
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const { data } = await _request2.default.call(void 0, {
|
|
43
|
-
instance: PlaylistsModel.api_instance,
|
|
44
|
-
method: "DELETE",
|
|
45
|
-
url: `/playlists/${id}`,
|
|
46
|
-
params: options,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
return data
|
|
50
|
-
}}
|
|
51
|
-
|
|
52
|
-
static __initStatic4() {this.getTrack = async (id) => {
|
|
53
|
-
const { data } = await _request2.default.call(void 0, {
|
|
54
|
-
instance: PlaylistsModel.api_instance,
|
|
55
|
-
method: "GET",
|
|
56
|
-
url: `/tracks/${id}/data`,
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
return data
|
|
60
|
-
}}
|
|
61
|
-
|
|
62
|
-
static __initStatic5() {this.getTracks = async (ids) => {
|
|
63
|
-
const { data } = await _request2.default.call(void 0, {
|
|
64
|
-
instance: PlaylistsModel.api_instance,
|
|
65
|
-
method: "GET",
|
|
66
|
-
url: `/tracks/many`,
|
|
67
|
-
params: {
|
|
68
|
-
ids,
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
return data
|
|
73
|
-
}}
|
|
74
|
-
|
|
75
|
-
static __initStatic6() {this.getPlaylist = async (id) => {
|
|
76
|
-
const { data } = await _request2.default.call(void 0, {
|
|
77
|
-
instance: PlaylistsModel.api_instance,
|
|
78
|
-
method: "GET",
|
|
79
|
-
url: `/playlists/${id}/data`,
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
return data
|
|
83
|
-
}}
|
|
84
|
-
|
|
85
|
-
static __initStatic7() {this.search = async (keywords) => {
|
|
86
|
-
const { data } = await _request2.default.call(void 0, {
|
|
87
|
-
instance: PlaylistsModel.api_instance,
|
|
88
|
-
method: "GET",
|
|
89
|
-
url: `/playlists/search`,
|
|
90
|
-
params: {
|
|
91
|
-
keywords,
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
return data
|
|
96
|
-
}}
|
|
97
|
-
|
|
98
|
-
static __initStatic8() {this.getMyReleases = async (keywords) => {
|
|
99
|
-
const { data } = await _request2.default.call(void 0, {
|
|
100
|
-
instance: PlaylistsModel.api_instance,
|
|
101
|
-
method: "GET",
|
|
102
|
-
url: `/playlists/self`,
|
|
103
|
-
params: {
|
|
104
|
-
keywords,
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
return data
|
|
109
|
-
}}
|
|
110
|
-
|
|
111
|
-
static __initStatic9() {this.toggleTrackLike = async (track_id) => {
|
|
112
|
-
if (!track_id) {
|
|
113
|
-
throw new Error("Track ID is required")
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const { data } = await _request2.default.call(void 0, {
|
|
117
|
-
instance: PlaylistsModel.api_instance,
|
|
118
|
-
method: "POST",
|
|
119
|
-
url: `/tracks/${track_id}/toggle-like`,
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
return data
|
|
123
|
-
}}
|
|
124
|
-
} PlaylistsModel.__initStatic(); PlaylistsModel.__initStatic2(); PlaylistsModel.__initStatic3(); PlaylistsModel.__initStatic4(); PlaylistsModel.__initStatic5(); PlaylistsModel.__initStatic6(); PlaylistsModel.__initStatic7(); PlaylistsModel.__initStatic8(); PlaylistsModel.__initStatic9(); exports.default = PlaylistsModel;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); class SpotifySyncModel {
|
|
2
|
-
static get spotify_redirect_uri() {
|
|
3
|
-
return window.location.origin + "/callbacks/sync/spotify"
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static get spotify_authorize_endpoint() {
|
|
7
|
-
return "https://accounts.spotify.com/authorize?response_type=code&client_id={{client_id}}&scope={{scope}}&redirect_uri={{redirect_uri}}&response_type=code"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static async authorizeAccount() {
|
|
11
|
-
const scopes = [
|
|
12
|
-
"user-read-private",
|
|
13
|
-
"user-modify-playback-state",
|
|
14
|
-
"user-read-currently-playing",
|
|
15
|
-
"user-read-playback-state",
|
|
16
|
-
"streaming",
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
const { client_id } = await SpotifySyncModel.get_client_id()
|
|
20
|
-
|
|
21
|
-
const parsedUrl = SpotifySyncModel.spotify_authorize_endpoint
|
|
22
|
-
.replace("{{client_id}}", client_id)
|
|
23
|
-
.replace("{{scope}}", scopes.join(" "))
|
|
24
|
-
.replace("{{redirect_uri}}", SpotifySyncModel.spotify_redirect_uri)
|
|
25
|
-
|
|
26
|
-
// open on a new tab
|
|
27
|
-
window.open(parsedUrl, "_blank")
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static async get_client_id() {
|
|
31
|
-
const { data } = await app.cores.api.customRequest( {
|
|
32
|
-
method: "GET",
|
|
33
|
-
url: `/sync/spotify/client_id`,
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
return data
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static async syncAuthCode(code) {
|
|
40
|
-
const { data } = await app.cores.api.customRequest( {
|
|
41
|
-
method: "POST",
|
|
42
|
-
url: `/sync/spotify/auth`,
|
|
43
|
-
data: {
|
|
44
|
-
redirect_uri: SpotifySyncModel.spotify_redirect_uri,
|
|
45
|
-
code,
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
return data
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static async unlinkAccount() {
|
|
53
|
-
const { data } = await app.cores.api.customRequest( {
|
|
54
|
-
method: "POST",
|
|
55
|
-
url: `/sync/spotify/unlink`,
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
return data
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
static async isAuthorized() {
|
|
62
|
-
const { data } = await app.cores.api.customRequest( {
|
|
63
|
-
method: "GET",
|
|
64
|
-
url: `/sync/spotify/is_authorized`,
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
return data
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static async getData() {
|
|
71
|
-
const { data } = await app.cores.api.customRequest( {
|
|
72
|
-
method: "GET",
|
|
73
|
-
url: `/sync/spotify/data`,
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
return data
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static async getCurrentPlaying() {
|
|
80
|
-
const { data } = await app.cores.api.customRequest( {
|
|
81
|
-
method: "GET",
|
|
82
|
-
url: `/sync/spotify/currently_playing`,
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
return data
|
|
86
|
-
}
|
|
87
|
-
} exports.default = SpotifySyncModel;
|