vdj 1.5.0 → 1.6.0
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/core/song.d.ts +0 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/default_implementations/youtube/service.d.ts +0 -1
- package/dist/default_implementations/youtube/service.js +1 -1
- package/dist/default_implementations/youtube/song.d.ts +0 -2
- package/dist/default_implementations/youtubedl/service.js +13 -0
- package/dist/default_implementations/youtubedl/song.d.ts +0 -1
- package/package.json +4 -4
- package/src/default_implementations/youtube/service.ts +1 -1
- package/src/default_implementations/youtubedl/service.ts +14 -1
- package/test/test.js +12 -19
package/dist/core/song.d.ts
CHANGED
package/dist/core/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const API = require("simple-youtube-api");
|
|
16
|
-
const ytdl = require("ytdl-core");
|
|
16
|
+
const ytdl = require("@distube/ytdl-core");
|
|
17
17
|
const song_1 = __importDefault(require("./song"));
|
|
18
18
|
class YouTubeService {
|
|
19
19
|
constructor(key) {
|
|
@@ -38,6 +38,19 @@ class YoutubedlService {
|
|
|
38
38
|
getSongInfo(url, logger) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
var res = yield (0, youtube_dl_exec_1.default)(url, { dumpSingleJson: true, noCheckCertificates: true, addMetadata: true }, {});
|
|
41
|
+
if (typeof res === 'string') {
|
|
42
|
+
return {
|
|
43
|
+
full: false,
|
|
44
|
+
metadataType: "youtubedl",
|
|
45
|
+
imgURL: undefined,
|
|
46
|
+
title: url,
|
|
47
|
+
duration: undefined,
|
|
48
|
+
url: url,
|
|
49
|
+
artist: [],
|
|
50
|
+
date: undefined,
|
|
51
|
+
custom: {}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
41
54
|
return {
|
|
42
55
|
full: true,
|
|
43
56
|
metadataType: "youtubedl",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vdj",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"chai": "^4.2.0",
|
|
14
14
|
"dotenv": "^8.2.0",
|
|
15
|
-
"typescript": "^
|
|
15
|
+
"typescript": "^5.7.3"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@distube/ytdl-core": "^4.16.4",
|
|
18
19
|
"@types/node": "^12.19.2",
|
|
19
20
|
"got": "^13.0.0",
|
|
20
21
|
"mocha": "^10.7.3",
|
|
21
22
|
"simple-youtube-api": "^5.2.1",
|
|
22
|
-
"youtube-dl-exec": "^3.0.
|
|
23
|
-
"ytdl-core": "^4.11.5"
|
|
23
|
+
"youtube-dl-exec": "^3.0.15"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -20,7 +20,20 @@ export default class YoutubedlService implements IService {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
public async getSongInfo(url: string, logger?: Logger): Promise<SongInfo> {
|
|
23
|
-
var res = await youtubedl(url, { dumpSingleJson: true, noCheckCertificates: true, addMetadata: true }, {});
|
|
23
|
+
var res = await youtubedl(url, { dumpSingleJson: true, noCheckCertificates: true, addMetadata: true }, {});
|
|
24
|
+
if(typeof res === 'string') {
|
|
25
|
+
return {
|
|
26
|
+
full: true,
|
|
27
|
+
metadataType: "youtubedl",
|
|
28
|
+
imgURL: "",
|
|
29
|
+
title: url,
|
|
30
|
+
duration: 0,
|
|
31
|
+
url: url,
|
|
32
|
+
artist: [],
|
|
33
|
+
date: new Date(),
|
|
34
|
+
custom: {}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
24
37
|
return {
|
|
25
38
|
full: true,
|
|
26
39
|
metadataType: "youtubedl",
|
package/test/test.js
CHANGED
|
@@ -171,26 +171,19 @@ describe("Playlist", function () {
|
|
|
171
171
|
});
|
|
172
172
|
describe("#getSongInfo", function () {
|
|
173
173
|
this.timeout(5000);
|
|
174
|
-
console.log("hey");
|
|
175
174
|
it("should return a lot more information from working youtube link", async function () {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const result = await tes.getSongInfo(input, console.log);
|
|
189
|
-
sortOfDeepEqual(result, expected);
|
|
190
|
-
}
|
|
191
|
-
catch (e) {
|
|
192
|
-
console.log(e);
|
|
193
|
-
}
|
|
175
|
+
const input = "https://www.youtube.com/watch?v=232fF5ECnGo";
|
|
176
|
+
const expected = {
|
|
177
|
+
full: true,
|
|
178
|
+
metadataType: "youtubedl",
|
|
179
|
+
url: input,
|
|
180
|
+
title: "Rap God in the style of @LinkinPark (Feat. @jonathanymusic)",
|
|
181
|
+
duration: 371,
|
|
182
|
+
artist: [],
|
|
183
|
+
date: new Date(1660773600000),
|
|
184
|
+
};
|
|
185
|
+
const result = await youtubedlService.getSongInfo(input, console.log);
|
|
186
|
+
sortOfDeepEqual(result, expected);
|
|
194
187
|
});
|
|
195
188
|
});
|
|
196
189
|
describe("#getSongInfo", function () {
|