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.
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Readable as ReadableStream } from 'stream';
3
2
  import { IService, SongInfo } from '.';
4
3
  export default abstract class Song {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { IService, Song } from ".";
3
2
  export type SongInfo = {
4
3
  full: boolean;
@@ -1,4 +1,3 @@
1
- /// <reference path="../../../src/typings/simple-youtube-api.d.ts" />
2
1
  import API = require('simple-youtube-api');
3
2
  import { IService, SearchType, SongInfo, Logger } from '../../core/';
4
3
  import YouTubeSong from './song';
@@ -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) {
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../src/typings/simple-youtube-api.d.ts" />
2
- /// <reference types="node" />
3
1
  import { Readable as ReadableStream } from 'stream';
4
2
  import { Video } from 'simple-youtube-api';
5
3
  import { Song, SongInfo, Logger } from '../../core';
@@ -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",
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Readable as ReadableStream } from 'stream';
3
2
  import { Song, SongInfo, Logger } from '../../core';
4
3
  import YoutubedlService from './service';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdj",
3
- "version": "1.5.0",
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": "^3.9.7"
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.7",
23
- "ytdl-core": "^4.11.5"
23
+ "youtube-dl-exec": "^3.0.15"
24
24
  }
25
25
  }
@@ -1,5 +1,5 @@
1
1
  import API = require('simple-youtube-api');
2
- import ytdl = require('ytdl-core');
2
+ import ytdl = require("@distube/ytdl-core");
3
3
 
4
4
  import { IService, SearchType, SongInfo, Logger } from '../../core/';
5
5
  import YouTubeSong from './song';
@@ -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
- try {
177
- const input = "https://www.youtube.com/watch?v=232fF5ECnGo";
178
- const expected = {
179
- full: true,
180
- metadataType: "youtubedl",
181
- url: input,
182
- title: "Rap God in the style of @LinkinPark​ (Feat. @jonathanymusic)",
183
- duration: 371,
184
- artist: [],
185
- date: new Date(1660773600000),
186
- };
187
- var tes = new vdj.YoutubedlService();
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 () {