vdj 1.6.0 → 1.6.2
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.
|
@@ -66,7 +66,10 @@ class YouTubeSong extends core_1.Song {
|
|
|
66
66
|
limitRate: '1M',
|
|
67
67
|
rmCacheDir: true,
|
|
68
68
|
verbose: true,
|
|
69
|
-
}, { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
69
|
+
}, { stdio: ['ignore', 'pipe', 'ignore'], });
|
|
70
|
+
stream.on('error', (err) => {
|
|
71
|
+
this.logger && this.logger(`[${this.type}] Error while streaming: ${err}`);
|
|
72
|
+
});
|
|
70
73
|
return stream.stdout;
|
|
71
74
|
}
|
|
72
75
|
}
|
|
@@ -40,14 +40,14 @@ class YoutubedlService {
|
|
|
40
40
|
var res = yield (0, youtube_dl_exec_1.default)(url, { dumpSingleJson: true, noCheckCertificates: true, addMetadata: true }, {});
|
|
41
41
|
if (typeof res === 'string') {
|
|
42
42
|
return {
|
|
43
|
-
full:
|
|
43
|
+
full: true,
|
|
44
44
|
metadataType: "youtubedl",
|
|
45
|
-
imgURL:
|
|
45
|
+
imgURL: "",
|
|
46
46
|
title: url,
|
|
47
|
-
duration:
|
|
47
|
+
duration: 0,
|
|
48
48
|
url: url,
|
|
49
49
|
artist: [],
|
|
50
|
-
date:
|
|
50
|
+
date: new Date(),
|
|
51
51
|
custom: {}
|
|
52
52
|
};
|
|
53
53
|
}
|
package/package.json
CHANGED
|
@@ -62,17 +62,29 @@ export default class YouTubeSong extends Song {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
public stream(): ReadableStream | null {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
try {
|
|
66
|
+
const stream = ytdlexec(
|
|
67
|
+
this.streamURL,
|
|
68
|
+
{
|
|
69
|
+
output: '-',
|
|
70
|
+
format: 'bestaudio/best',
|
|
71
|
+
limitRate: '1M',
|
|
72
|
+
rmCacheDir: true,
|
|
73
|
+
verbose: true,
|
|
74
|
+
},
|
|
75
|
+
{ stdio: ['ignore', 'pipe', 'ignore'], }
|
|
76
|
+
);
|
|
77
|
+
stream.on('error', (err) => {
|
|
78
|
+
this.logger && this.logger(`[${this.type}] Error while streaming: ${err}`);
|
|
79
|
+
});
|
|
80
|
+
stream.catch((err) => {
|
|
81
|
+
this.logger && this.logger(`[${this.type}] Error while streaming: ${err}`);
|
|
82
|
+
});
|
|
83
|
+
return stream.stdout;
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
this.logger && this.logger(`[${this.type}] Error while streaming: ${err}`);
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
77
89
|
}
|
|
78
90
|
}
|
package/test/test.js
CHANGED
|
@@ -15,13 +15,17 @@ function sortOfDeepEqual(actual, expected) {
|
|
|
15
15
|
return assert.deepEqual(strippedActual, expected);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
describe("Playlist", function () {
|
|
18
|
+
describe("Playlist", function () {
|
|
19
19
|
before(function () {
|
|
20
20
|
playlist = new vdj.Playlist({
|
|
21
21
|
services: [],
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
+
beforeEach(function () {
|
|
26
|
+
playlist.clear();
|
|
27
|
+
});
|
|
28
|
+
|
|
25
29
|
describe("#add", function () {
|
|
26
30
|
it("should return the not found targets", async function () {
|
|
27
31
|
const input = ["first", "second"];
|
|
@@ -118,6 +122,26 @@ describe("Playlist", function () {
|
|
|
118
122
|
assert.equal(result, expected);
|
|
119
123
|
});
|
|
120
124
|
});
|
|
125
|
+
describe("#next", function () {
|
|
126
|
+
|
|
127
|
+
it("should go to next song", async function () {
|
|
128
|
+
const input = [
|
|
129
|
+
"https://www.youtube.com/watch?v=fmrA-gxJxgQ",
|
|
130
|
+
"https://www.youtube.com/watch?v=DDjcqu9uvUE",
|
|
131
|
+
"https://www.youtube.com/watch?v=lBnAY4VH9T4",
|
|
132
|
+
];
|
|
133
|
+
await playlist.add(input);
|
|
134
|
+
const current1 = playlist.current;
|
|
135
|
+
await playlist.next();
|
|
136
|
+
const current2 = playlist.current;
|
|
137
|
+
await playlist.next();
|
|
138
|
+
const current3 = playlist.current;
|
|
139
|
+
assert.equal(current1.URL, input[0]);
|
|
140
|
+
assert.equal(current2.URL, input[1]);
|
|
141
|
+
assert.equal(current3.URL, input[2]);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
121
145
|
describe("#getSongInfo", function () {
|
|
122
146
|
it("should return a lot more information from working youtube video link", async function () {
|
|
123
147
|
const input = "https://www.youtube.com/watch?v=FtsefkeIE7k";
|
|
@@ -142,7 +166,7 @@ describe("Playlist", function () {
|
|
|
142
166
|
});
|
|
143
167
|
});
|
|
144
168
|
describe("#add", function () {
|
|
145
|
-
this.timeout(
|
|
169
|
+
this.timeout(10000);
|
|
146
170
|
it("should return a YoutubedlSong from working ogg link", async function () {
|
|
147
171
|
const input = ["https://upload.wikimedia.org/wikipedia/commons/d/de/Lorem_ipsum.ogg"];
|
|
148
172
|
const expected = {
|
|
@@ -170,7 +194,7 @@ describe("Playlist", function () {
|
|
|
170
194
|
});
|
|
171
195
|
});
|
|
172
196
|
describe("#getSongInfo", function () {
|
|
173
|
-
this.timeout(
|
|
197
|
+
this.timeout(10000);
|
|
174
198
|
it("should return a lot more information from working youtube link", async function () {
|
|
175
199
|
const input = "https://www.youtube.com/watch?v=232fF5ECnGo";
|
|
176
200
|
const expected = {
|
|
@@ -187,7 +211,7 @@ describe("Playlist", function () {
|
|
|
187
211
|
});
|
|
188
212
|
});
|
|
189
213
|
describe("#getSongInfo", function () {
|
|
190
|
-
this.timeout(
|
|
214
|
+
this.timeout(10000);
|
|
191
215
|
it("should return a lot more information from working soundcloud link", async function () {
|
|
192
216
|
const input = "https://soundcloud.com/bionicelcor/wakusei-abnormal";
|
|
193
217
|
const expected = {
|