vdj 1.1.6 → 1.4.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/default_implementations/youtube/song.d.ts +1 -1
- package/dist/default_implementations/youtube/song.js +9 -14
- package/dist/default_implementations/youtubedl/service.js +2 -2
- package/dist/default_implementations/youtubedl/song.js +8 -3
- package/package.json +3 -3
- package/src/default_implementations/youtube/service.ts +10 -10
- package/src/default_implementations/youtube/song.ts +15 -16
- package/src/default_implementations/youtubedl/service.ts +6 -6
- package/src/default_implementations/youtubedl/song.ts +14 -3
- package/test/test.js +107 -94
|
@@ -17,5 +17,5 @@ export default class YouTubeSong extends Song {
|
|
|
17
17
|
constructor(service: YouTubeService, video: Video, playlistID?: string, logger?: Logger, seek?: number);
|
|
18
18
|
getSongInfo(): Promise<SongInfo>;
|
|
19
19
|
static extractSeek(url: string): number;
|
|
20
|
-
stream(): ReadableStream;
|
|
20
|
+
stream(): ReadableStream | null;
|
|
21
21
|
}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const youtube_dl_exec_1 = require("youtube-dl-exec");
|
|
13
13
|
const core_1 = require("../../core");
|
|
14
14
|
class YouTubeSong extends core_1.Song {
|
|
15
15
|
constructor(service, video, playlistID, logger, seek = 0) {
|
|
@@ -60,19 +60,14 @@ class YouTubeSong extends core_1.Song {
|
|
|
60
60
|
return 0;
|
|
61
61
|
}
|
|
62
62
|
stream() {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
if (typeof (this.logger) == 'function')
|
|
74
|
-
this.logger(`[${this.type}] Fetching stream url for ${this.URL}.`);
|
|
75
|
-
return ytdl(this.trackID, options);
|
|
63
|
+
const stream = youtube_dl_exec_1.exec(this.streamURL, {
|
|
64
|
+
output: '-',
|
|
65
|
+
format: 'bestaudio[ext=webm+acodec=opus+tbr>100]/bestaudio[ext=webm+acodec=opus]/bestaudio/best',
|
|
66
|
+
limitRate: '1M',
|
|
67
|
+
rmCacheDir: true,
|
|
68
|
+
verbose: true,
|
|
69
|
+
}, { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
70
|
+
return stream.stdout;
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
73
|
exports.default = YouTubeSong;
|
|
@@ -31,13 +31,13 @@ class YoutubedlService {
|
|
|
31
31
|
}
|
|
32
32
|
canFetch(target, logger) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
var res = yield youtube_dl_exec_1.default(target, {
|
|
34
|
+
var res = yield youtube_dl_exec_1.default(target, { dumpJson: true }, {});
|
|
35
35
|
return !!res;
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
getSongInfo(url, logger) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
var res = yield youtube_dl_exec_1.default(url, {
|
|
40
|
+
var res = yield youtube_dl_exec_1.default(url, { dumpJson: true, noCheckCertificate: true, addMetadata: true }, {});
|
|
41
41
|
return {
|
|
42
42
|
full: true,
|
|
43
43
|
metadataType: "youtubedl",
|
|
@@ -33,9 +33,14 @@ class YoutubedlSong extends core_1.Song {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
stream() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const stream = youtube_dl_exec_1.exec(this.streamURL, {
|
|
37
|
+
output: '-',
|
|
38
|
+
format: 'bestaudio[ext=webm+acodec=opus+tbr>100]/bestaudio[ext=webm+acodec=opus]/bestaudio/best',
|
|
39
|
+
limitRate: '1M',
|
|
40
|
+
rmCacheDir: true,
|
|
41
|
+
verbose: true,
|
|
42
|
+
}, { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
43
|
+
return stream.stdout;
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
exports.default = YoutubedlSong;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vdj",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@types/node": "^12.19.2",
|
|
20
20
|
"got": "^11.8.0",
|
|
21
21
|
"simple-youtube-api": "^5.2.1",
|
|
22
|
-
"youtube-dl-exec": "^1.
|
|
23
|
-
"ytdl-core": "^4.11.
|
|
22
|
+
"youtube-dl-exec": "^2.1.5",
|
|
23
|
+
"ytdl-core": "^4.11.2"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -19,13 +19,13 @@ export default class YouTubeService implements IService {
|
|
|
19
19
|
for (const target of targets) {
|
|
20
20
|
var parsed = API.util.parseURL(target);
|
|
21
21
|
if (parsed.video) {
|
|
22
|
-
typeof(logger) == 'function' && logger(`[${this.type}] Fetching video from target ${target}.`);
|
|
22
|
+
typeof (logger) == 'function' && logger(`[${this.type}] Fetching video from target ${target}.`);
|
|
23
23
|
|
|
24
24
|
const video = await this.api.getVideoByID(parsed.video);
|
|
25
25
|
const seek = YouTubeSong.extractSeek(target);
|
|
26
26
|
if (video) fetched.push(new YouTubeSong(this, video, undefined, logger, seek));
|
|
27
27
|
} else if (parsed.playlist) {
|
|
28
|
-
typeof(logger) == 'function' && logger(`[${this.type}] Fetching playlist from target ${target}.`);
|
|
28
|
+
typeof (logger) == 'function' && logger(`[${this.type}] Fetching playlist from target ${target}.`);
|
|
29
29
|
|
|
30
30
|
const playlist = await this.api.getPlaylistByID(parsed.playlist);
|
|
31
31
|
if (!playlist) continue;
|
|
@@ -43,8 +43,8 @@ export default class YouTubeService implements IService {
|
|
|
43
43
|
if (!this.canSearch) return fetched;
|
|
44
44
|
for (const query of queries) {
|
|
45
45
|
if (searchType === 'playlist') {
|
|
46
|
-
typeof(logger) == 'function' && logger(`[${this.type}] Searching for a playlist with the input ${query}.`);
|
|
47
|
-
|
|
46
|
+
typeof (logger) == 'function' && logger(`[${this.type}] Searching for a playlist with the input ${query}.`);
|
|
47
|
+
|
|
48
48
|
const results = await this.api.searchPlaylists(query, 1);
|
|
49
49
|
if (results.length) {
|
|
50
50
|
const list = results[0];
|
|
@@ -52,13 +52,13 @@ export default class YouTubeService implements IService {
|
|
|
52
52
|
fetched.push(...videos.map((v) => new YouTubeSong(this, v, list.id, logger)));
|
|
53
53
|
}
|
|
54
54
|
} else {
|
|
55
|
-
typeof(logger) == 'function' && logger(`[${this.type}] Searching for a song with the input ${query}.`);
|
|
56
|
-
|
|
55
|
+
typeof (logger) == 'function' && logger(`[${this.type}] Searching for a song with the input ${query}.`);
|
|
56
|
+
|
|
57
57
|
const results = await this.api.searchVideos(query, 1);
|
|
58
58
|
if (results.length) fetched.push(new YouTubeSong(this, results[0], undefined, logger));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
return fetched;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -73,7 +73,7 @@ export default class YouTubeService implements IService {
|
|
|
73
73
|
return {
|
|
74
74
|
full: true,
|
|
75
75
|
metadataType: "youtube",
|
|
76
|
-
imgURL: result.player_response.videoDetails.thumbnail.thumbnails[0].url,
|
|
76
|
+
imgURL: ((result.player_response.videoDetails as any).thumbnail as ytdl.VideoDetails).thumbnails[0].url,
|
|
77
77
|
title: result.videoDetails.title,
|
|
78
78
|
duration: Number(result.videoDetails.lengthSeconds),
|
|
79
79
|
url: result.videoDetails.video_url,
|
|
@@ -81,8 +81,8 @@ export default class YouTubeService implements IService {
|
|
|
81
81
|
date: new Date(result.videoDetails.publishDate),
|
|
82
82
|
custom: result
|
|
83
83
|
};
|
|
84
|
-
} catch(e) {
|
|
85
|
-
typeof(logger) == 'function' && logger(`Failed to get song info for url '${url}', error ${e}`);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
typeof (logger) == 'function' && logger(`Failed to get song info for url '${url}', error ${e}`);
|
|
86
86
|
return {
|
|
87
87
|
full: true,
|
|
88
88
|
metadataType: "youtube",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable as ReadableStream } from 'stream';
|
|
2
2
|
import { Video } from 'simple-youtube-api';
|
|
3
|
-
import
|
|
3
|
+
import { exec as ytdlexec } from 'youtube-dl-exec';
|
|
4
4
|
|
|
5
5
|
import { Song, SongInfo, Logger } from '../../core';
|
|
6
6
|
import YouTubeService from './service';
|
|
@@ -62,20 +62,19 @@ export default class YouTubeSong extends Song {
|
|
|
62
62
|
return 0;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
public stream(): ReadableStream {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return ytdl(this.trackID, options);
|
|
65
|
+
public stream(): ReadableStream | null {
|
|
66
|
+
const stream = ytdlexec(
|
|
67
|
+
this.streamURL,
|
|
68
|
+
{
|
|
69
|
+
output: '-',
|
|
70
|
+
format:
|
|
71
|
+
'bestaudio[ext=webm+acodec=opus+tbr>100]/bestaudio[ext=webm+acodec=opus]/bestaudio/best',
|
|
72
|
+
limitRate: '1M',
|
|
73
|
+
rmCacheDir: true,
|
|
74
|
+
verbose: true,
|
|
75
|
+
},
|
|
76
|
+
{ stdio: ['ignore', 'pipe', 'ignore'] }
|
|
77
|
+
);
|
|
78
|
+
return stream.stdout;
|
|
80
79
|
}
|
|
81
80
|
}
|
|
@@ -15,12 +15,12 @@ export default class YoutubedlService implements IService {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
public async canFetch(target: string, logger?: Logger): Promise<boolean> {
|
|
18
|
-
var res = await youtubedl(target, {
|
|
18
|
+
var res = await youtubedl(target, { dumpJson: true }, {});
|
|
19
19
|
return !!res;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
public async getSongInfo(url: string, logger?: Logger): Promise<SongInfo> {
|
|
23
|
-
var res = await youtubedl(url, {
|
|
23
|
+
var res = await youtubedl(url, { dumpJson: true, noCheckCertificate: true, addMetadata: true }, {});
|
|
24
24
|
return {
|
|
25
25
|
full: true,
|
|
26
26
|
metadataType: "youtubedl",
|
|
@@ -38,10 +38,10 @@ export default class YoutubedlService implements IService {
|
|
|
38
38
|
if (!dateString) {
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
|
41
|
-
const year = dateString.slice(0,4);
|
|
42
|
-
const month = dateString.slice(4,6);
|
|
43
|
-
const day = dateString.slice(6,8);
|
|
44
|
-
|
|
41
|
+
const year = dateString.slice(0, 4);
|
|
42
|
+
const month = dateString.slice(4, 6);
|
|
43
|
+
const day = dateString.slice(6, 8);
|
|
44
|
+
|
|
45
45
|
return new Date(`${year} ${month} ${day}`)
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable as ReadableStream } from 'stream';
|
|
2
2
|
import { Song, SongInfo, Logger } from '../../core';
|
|
3
|
-
import {
|
|
3
|
+
import { exec as ytdlexec } from 'youtube-dl-exec';
|
|
4
4
|
import YoutubedlService from './service';
|
|
5
5
|
|
|
6
6
|
export default class YoutubedlSong extends Song {
|
|
@@ -30,7 +30,18 @@ export default class YoutubedlSong extends Song {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
public stream(): ReadableStream | null {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const stream = ytdlexec(
|
|
34
|
+
this.streamURL,
|
|
35
|
+
{
|
|
36
|
+
output: '-',
|
|
37
|
+
format:
|
|
38
|
+
'bestaudio[ext=webm+acodec=opus+tbr>100]/bestaudio[ext=webm+acodec=opus]/bestaudio/best',
|
|
39
|
+
limitRate: '1M',
|
|
40
|
+
rmCacheDir: true,
|
|
41
|
+
verbose: true,
|
|
42
|
+
},
|
|
43
|
+
{ stdio: ['ignore', 'pipe', 'ignore'] }
|
|
44
|
+
);
|
|
45
|
+
return stream.stdout;
|
|
35
46
|
}
|
|
36
47
|
}
|
package/test/test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require(
|
|
2
|
-
const assert = require(
|
|
3
|
-
const vdj = require(
|
|
1
|
+
require("dotenv").config({ path: "./test/.env" });
|
|
2
|
+
const assert = require("chai").assert;
|
|
3
|
+
const vdj = require("../dist");
|
|
4
4
|
|
|
5
5
|
var playlist,
|
|
6
6
|
youtubeService = new vdj.YouTubeService(process.env.GOOGLE_API_KEY),
|
|
@@ -15,166 +15,179 @@ function sortOfDeepEqual(actual, expected) {
|
|
|
15
15
|
return assert.deepEqual(strippedActual, expected);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
describe(
|
|
18
|
+
describe("Playlist", function () {
|
|
19
19
|
before(function () {
|
|
20
20
|
playlist = new vdj.Playlist({
|
|
21
|
-
services: []
|
|
21
|
+
services: [],
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
describe(
|
|
26
|
-
it(
|
|
27
|
-
const input = [
|
|
25
|
+
describe("#add", function () {
|
|
26
|
+
it("should return the not found targets", async function () {
|
|
27
|
+
const input = ["first", "second"];
|
|
28
28
|
const result = await playlist.add(input);
|
|
29
29
|
assert.deepEqual(result.notFound, input);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
describe(
|
|
33
|
+
describe("Youtube", function () {
|
|
34
34
|
before(function () {
|
|
35
35
|
playlist = new vdj.Playlist({
|
|
36
|
-
services: [youtubeService]
|
|
37
|
-
|
|
36
|
+
services: [youtubeService],
|
|
38
37
|
});
|
|
39
38
|
});
|
|
40
39
|
|
|
41
|
-
describe(
|
|
42
|
-
it(
|
|
43
|
-
const input = [
|
|
40
|
+
describe("#add", function () {
|
|
41
|
+
it("should return a YouTubeSong from working youtube video link", async function () {
|
|
42
|
+
const input = ["https://www.youtube.com/watch?v=FtsefkeIE7k"];
|
|
44
43
|
const expected = {
|
|
45
|
-
|
|
44
|
+
added: [
|
|
46
45
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
URL: input[0],
|
|
47
|
+
info: {
|
|
48
|
+
duration: 282,
|
|
49
|
+
full: false,
|
|
50
|
+
metadataType: "youtube",
|
|
51
|
+
title: "楽園ベイベー - RIP SLYME(Cover) / KMNZ",
|
|
52
|
+
url: input[0],
|
|
54
53
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
54
|
+
live: false,
|
|
55
|
+
logger: undefined,
|
|
56
|
+
loop: false,
|
|
57
|
+
playlistID: undefined,
|
|
58
|
+
seek: 0,
|
|
59
|
+
service: playlist.services[0],
|
|
60
|
+
streamURL: input[0],
|
|
61
|
+
title: "楽園ベイベー - RIP SLYME(Cover) / KMNZ",
|
|
62
|
+
trackID: "FtsefkeIE7k",
|
|
63
|
+
type: "youtube",
|
|
64
|
+
},
|
|
66
65
|
],
|
|
67
|
-
|
|
66
|
+
notFound: [],
|
|
68
67
|
};
|
|
69
68
|
const result = await playlist.add(input);
|
|
70
69
|
assert.deepEqual(result, expected);
|
|
71
70
|
});
|
|
72
|
-
it(
|
|
73
|
-
const input = [
|
|
71
|
+
it("should return multiple YouTubeSongs from multiple working youtube video links", async function () {
|
|
72
|
+
const input = [
|
|
73
|
+
"https://www.youtube.com/watch?v=fmrA-gxJxgQ",
|
|
74
|
+
"https://www.youtube.com/watch?v=DDjcqu9uvUE",
|
|
75
|
+
"https://www.youtube.com/watch?v=lBnAY4VH9T4",
|
|
76
|
+
];
|
|
74
77
|
const expected = input.length;
|
|
75
78
|
const result = (await playlist.add(input)).added.length;
|
|
76
79
|
assert.equal(result, expected);
|
|
77
80
|
});
|
|
78
|
-
it(
|
|
79
|
-
const input = [
|
|
81
|
+
it("should return a YouTubeSong from working shortened youtube video link", async function () {
|
|
82
|
+
const input = ["https://youtu.be/LoK17z6xDwI"];
|
|
80
83
|
const expected = "https://www.youtube.com/watch?v=LoK17z6xDwI";
|
|
81
84
|
const result = (await playlist.add(input)).added[0].URL;
|
|
82
85
|
assert.deepEqual(result, expected);
|
|
83
86
|
});
|
|
84
|
-
it(
|
|
85
|
-
const input = [
|
|
87
|
+
it("should return a YouTubeSong from live youtube video link", async function () {
|
|
88
|
+
const input = ["https://www.youtube.com/watch?v=jfKfPfyJRdk"];
|
|
86
89
|
const result = (await playlist.add(input)).added[0].live;
|
|
87
90
|
assert.isTrue(result);
|
|
88
91
|
});
|
|
89
|
-
it(
|
|
90
|
-
const input = [
|
|
92
|
+
it("should return a YouTubeSong with seek from working youtube video link with timestamp parameter", async function () {
|
|
93
|
+
const input = ["https://www.youtube.com/watch?v=tMKrECxEpq8&t=64"];
|
|
91
94
|
const expected = 64;
|
|
92
95
|
const result = (await playlist.add(input)).added[0].seek;
|
|
93
96
|
assert.equal(result, expected);
|
|
94
97
|
});
|
|
95
|
-
it(
|
|
96
|
-
const input = [
|
|
98
|
+
it("should return multiple YouTubeSongs from youtube playlist link", async function () {
|
|
99
|
+
const input = ["https://www.youtube.com/playlist?list=PLD80CC3FEBE323161"];
|
|
100
|
+
const expected = 21;
|
|
97
101
|
const result = (await playlist.add(input)).added.length;
|
|
98
|
-
assert.
|
|
102
|
+
assert.equal(result, expected);
|
|
99
103
|
});
|
|
100
|
-
it(
|
|
101
|
-
const input = [
|
|
104
|
+
it("should return one YouTubeSong from youtube video link with playlist parameter", async function () {
|
|
105
|
+
const input = ["https://www.youtube.com/watch?v=wSCEC0lYTzk&list=PLFJU3fqbXA2e1_wAqOn7IoRB02nCfsAVh&index=67"];
|
|
102
106
|
const expected = 1;
|
|
103
107
|
const result = (await playlist.add(input)).added.length;
|
|
104
108
|
assert.equal(result, expected);
|
|
105
109
|
});
|
|
106
|
-
it(
|
|
107
|
-
const input = [
|
|
110
|
+
it("should return YouTubeSongs from search queries", async function () {
|
|
111
|
+
const input = ["globglogabgalab", "yooooooooo"];
|
|
108
112
|
const expected = 2;
|
|
109
|
-
const result = (
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
const result = (
|
|
114
|
+
await playlist.add(input, {
|
|
115
|
+
playlistAddType: "searches",
|
|
116
|
+
})
|
|
117
|
+
).added.length;
|
|
112
118
|
assert.equal(result, expected);
|
|
113
119
|
});
|
|
114
120
|
});
|
|
121
|
+
describe("#getSongInfo", function () {
|
|
122
|
+
it("should return a lot more information from working youtube video link", async function () {
|
|
123
|
+
const input = "https://www.youtube.com/watch?v=FtsefkeIE7k";
|
|
124
|
+
const expected = {
|
|
125
|
+
full: true,
|
|
126
|
+
metadataType: "youtube",
|
|
127
|
+
url: input,
|
|
128
|
+
title: "楽園ベイベー - RIP SLYME(Cover) / KMNZ",
|
|
129
|
+
duration: 282,
|
|
130
|
+
artist: ["KMNZ LITA"],
|
|
131
|
+
date: new Date(1566950400000),
|
|
132
|
+
};
|
|
133
|
+
const result = await youtubeService.getSongInfo(input, console.log);
|
|
134
|
+
sortOfDeepEqual(result, expected);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
115
137
|
});
|
|
116
|
-
describe(
|
|
138
|
+
describe("Youtubedl", function () {
|
|
117
139
|
before(function () {
|
|
118
140
|
playlist = new vdj.Playlist({
|
|
119
|
-
services: [youtubedlService]
|
|
141
|
+
services: [youtubedlService],
|
|
120
142
|
});
|
|
121
143
|
});
|
|
122
|
-
describe(
|
|
144
|
+
describe("#add", function () {
|
|
123
145
|
this.timeout(5000);
|
|
124
|
-
it(
|
|
125
|
-
const input = [
|
|
146
|
+
it("should return a YoutubedlSong from working ogg link", async function () {
|
|
147
|
+
const input = ["https://upload.wikimedia.org/wikipedia/commons/d/de/Lorem_ipsum.ogg"];
|
|
126
148
|
const expected = {
|
|
127
|
-
|
|
149
|
+
added: [
|
|
128
150
|
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
URL: input[0],
|
|
152
|
+
info: {
|
|
153
|
+
full: false,
|
|
154
|
+
metadataType: "youtubedl",
|
|
155
|
+
url: input[0],
|
|
134
156
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
157
|
+
logger: undefined,
|
|
158
|
+
loop: false,
|
|
159
|
+
service: playlist.services[0],
|
|
160
|
+
streamURL: input[0],
|
|
161
|
+
type: "youtubedl",
|
|
162
|
+
},
|
|
141
163
|
],
|
|
142
|
-
|
|
164
|
+
notFound: [],
|
|
143
165
|
};
|
|
144
166
|
const result = await playlist.add(input);
|
|
145
167
|
assert.deepEqual(result, expected);
|
|
146
168
|
});
|
|
147
169
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
describe('Service', function () {
|
|
153
|
-
describe('Youtube', function () {
|
|
154
|
-
describe('#getSongInfo', function () {
|
|
155
|
-
it('should return a lot more information from working youtube video link', async function () {
|
|
156
|
-
const input = 'https://www.youtube.com/watch?v=FtsefkeIE7k';
|
|
170
|
+
describe("#getSongInfo", function () {
|
|
171
|
+
this.timeout(5000);
|
|
172
|
+
it("should return a lot more information from working youtube link", async function () {
|
|
173
|
+
const input = "https://www.youtube.com/watch?v=232fF5ECnGo";
|
|
157
174
|
const expected = {
|
|
158
175
|
full: true,
|
|
159
|
-
metadataType: "
|
|
176
|
+
metadataType: "youtubedl",
|
|
160
177
|
url: input,
|
|
161
|
-
title: "
|
|
162
|
-
duration:
|
|
163
|
-
artist: [
|
|
164
|
-
|
|
165
|
-
],
|
|
166
|
-
date: new Date(1566950400000)
|
|
178
|
+
title: "Rap God in the style of @Linkin Park (Feat. @Jonathan Young)",
|
|
179
|
+
duration: 371,
|
|
180
|
+
artist: [],
|
|
181
|
+
date: new Date(1660773600000),
|
|
167
182
|
};
|
|
168
|
-
const result = await
|
|
183
|
+
const result = await youtubedlService.getSongInfo(input, console.log);
|
|
169
184
|
sortOfDeepEqual(result, expected);
|
|
170
185
|
});
|
|
171
186
|
});
|
|
172
|
-
|
|
173
|
-
describe('Youtubedl', function () {
|
|
174
|
-
describe('#getSongInfo', function () {
|
|
187
|
+
describe("#getSongInfo", function () {
|
|
175
188
|
this.timeout(5000);
|
|
176
|
-
it(
|
|
177
|
-
const input =
|
|
189
|
+
it("should return a lot more information from working soundcloud link", async function () {
|
|
190
|
+
const input = "https://soundcloud.com/bionicelcor/wakusei-abnormal";
|
|
178
191
|
const expected = {
|
|
179
192
|
full: true,
|
|
180
193
|
metadataType: "youtubedl",
|
|
@@ -182,7 +195,7 @@ describe('Service', function () {
|
|
|
182
195
|
title: "ふこうぶつ -- Wakusei Abnormal",
|
|
183
196
|
duration: 164.638,
|
|
184
197
|
artist: [],
|
|
185
|
-
date: new Date(1512946800000)
|
|
198
|
+
date: new Date(1512946800000),
|
|
186
199
|
};
|
|
187
200
|
const result = await youtubedlService.getSongInfo(input, console.log);
|
|
188
201
|
sortOfDeepEqual(result, expected);
|
|
@@ -208,4 +221,4 @@ describe('Service', function () {
|
|
|
208
221
|
});
|
|
209
222
|
*/
|
|
210
223
|
});
|
|
211
|
-
});
|
|
224
|
+
});
|