vdj 1.6.0 → 1.6.1

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: false,
43
+ full: true,
44
44
  metadataType: "youtubedl",
45
- imgURL: undefined,
45
+ imgURL: "",
46
46
  title: url,
47
- duration: undefined,
47
+ duration: 0,
48
48
  url: url,
49
49
  artist: [],
50
- date: undefined,
50
+ date: new Date(),
51
51
  custom: {}
52
52
  };
53
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdj",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -71,8 +71,11 @@ export default class YouTubeSong extends Song {
71
71
  rmCacheDir: true,
72
72
  verbose: true,
73
73
  },
74
- { stdio: ['ignore', 'pipe', 'ignore'] }
74
+ { stdio: ['ignore', 'pipe', 'ignore'], }
75
75
  );
76
+ stream.on('error', (err) => {
77
+ this.logger && this.logger(`[${this.type}] Error while streaming: ${err}`);
78
+ });
76
79
  return stream.stdout;
77
80
  }
78
81
  }
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(5000);
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(5000);
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(5000);
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 = {