vdj 1.1.5 → 1.3.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/package.json +2 -2
- package/src/default_implementations/youtube/service.ts +10 -10
- package/test/test.js +107 -94
- package/dist/default_implementations/direct/service.d.ts +0 -10
- package/dist/default_implementations/direct/service.js +0 -54
- package/dist/default_implementations/direct/song.d.ts +0 -14
- package/dist/default_implementations/direct/song.js +0 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vdj",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
"got": "^11.8.0",
|
|
21
21
|
"simple-youtube-api": "^5.2.1",
|
|
22
22
|
"youtube-dl-exec": "^1.2.13",
|
|
23
|
-
"ytdl-core": "^4.11.
|
|
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",
|
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
|
+
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IService, SongInfo, Logger } from '../../core/';
|
|
2
|
-
import YoutubedlSong from './song';
|
|
3
|
-
export default class YoutubedlService implements IService {
|
|
4
|
-
canSearch: boolean;
|
|
5
|
-
type: string;
|
|
6
|
-
fetch(targets: string[], logger?: Logger): Promise<YoutubedlSong[]>;
|
|
7
|
-
search(): Promise<YoutubedlSong[]>;
|
|
8
|
-
canFetch(target: string, logger?: Logger): Promise<boolean>;
|
|
9
|
-
getSongInfo(url: string, logger?: Logger): Promise<SongInfo>;
|
|
10
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const song_1 = __importDefault(require("./song"));
|
|
15
|
-
const youtube_dl_1 = __importDefault(require("youtube-dl"));
|
|
16
|
-
class YoutubedlService {
|
|
17
|
-
constructor() {
|
|
18
|
-
this.canSearch = false;
|
|
19
|
-
this.type = 'youtubedl';
|
|
20
|
-
}
|
|
21
|
-
fetch(targets, logger) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
return targets.map(x => new song_1.default(this, x, logger));
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
search() {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
return [];
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
canFetch(target, logger) {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
return new Promise(resolve => {
|
|
34
|
-
youtube_dl_1.default.exec(target, ['-j'], {}, (err) => resolve(!!err));
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
getSongInfo(url, logger) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
return {
|
|
41
|
-
full: true,
|
|
42
|
-
metadataType: "unknown",
|
|
43
|
-
imgURL: "",
|
|
44
|
-
title: url,
|
|
45
|
-
duration: 0,
|
|
46
|
-
url: url,
|
|
47
|
-
artist: [],
|
|
48
|
-
date: new Date(),
|
|
49
|
-
custom: {}
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.default = YoutubedlService;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Readable as ReadableStream } from 'stream';
|
|
3
|
-
import { Song, SongInfo, Logger } from '../../core';
|
|
4
|
-
import YoutubedlService from './service';
|
|
5
|
-
export default class YoutubedlSong extends Song {
|
|
6
|
-
readonly type: string;
|
|
7
|
-
readonly streamURL: string;
|
|
8
|
-
readonly URL: string;
|
|
9
|
-
info: SongInfo;
|
|
10
|
-
logger?: Logger;
|
|
11
|
-
constructor(service: YoutubedlService, url: string, logger?: Logger);
|
|
12
|
-
getSongInfo(): Promise<SongInfo>;
|
|
13
|
-
stream(): ReadableStream;
|
|
14
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const core_1 = require("../../core");
|
|
15
|
-
const youtube_dl_1 = __importDefault(require("youtube-dl"));
|
|
16
|
-
class YoutubedlSong extends core_1.Song {
|
|
17
|
-
constructor(service, url, logger) {
|
|
18
|
-
super(service);
|
|
19
|
-
this.type = 'youtubedl';
|
|
20
|
-
this.streamURL = url;
|
|
21
|
-
this.URL = url;
|
|
22
|
-
this.info = {
|
|
23
|
-
full: false,
|
|
24
|
-
metadataType: this.type,
|
|
25
|
-
url: this.URL
|
|
26
|
-
};
|
|
27
|
-
this.logger = logger;
|
|
28
|
-
}
|
|
29
|
-
getSongInfo() {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
if (!this.info.full) {
|
|
32
|
-
this.info = yield this.service.getSongInfo(this.URL);
|
|
33
|
-
}
|
|
34
|
-
return this.info;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
stream() {
|
|
38
|
-
if (typeof (this.logger) == 'function')
|
|
39
|
-
this.logger(`[${this.type}] Fetching stream for ${this.URL}.`);
|
|
40
|
-
return youtube_dl_1.default(this.streamURL, [], {});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.default = YoutubedlSong;
|