youtubei 0.0.1-rc.3 → 0.0.1-rc.32

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.
Files changed (62) hide show
  1. package/README.md +6 -5
  2. package/dist/classes/Base.d.ts +10 -0
  3. package/dist/classes/{client/types.js → Base.js} +3 -0
  4. package/dist/classes/BaseVideo.d.ts +59 -0
  5. package/dist/classes/BaseVideo.js +121 -0
  6. package/dist/classes/Channel.d.ts +27 -31
  7. package/dist/classes/Channel.js +59 -135
  8. package/dist/classes/ChannelCompact.d.ts +74 -23
  9. package/dist/classes/ChannelCompact.js +114 -103
  10. package/dist/classes/Chat.d.ts +29 -0
  11. package/dist/classes/Chat.js +31 -0
  12. package/dist/classes/Client.d.ts +49 -0
  13. package/dist/classes/Client.js +97 -0
  14. package/dist/classes/Comment.d.ts +50 -0
  15. package/dist/classes/Comment.js +84 -0
  16. package/dist/classes/LiveVideo.d.ts +47 -0
  17. package/dist/classes/LiveVideo.js +94 -0
  18. package/dist/classes/MixPlaylist.d.ts +32 -0
  19. package/dist/classes/MixPlaylist.js +44 -0
  20. package/dist/classes/Playlist.d.ts +35 -18
  21. package/dist/classes/Playlist.js +80 -116
  22. package/dist/classes/PlaylistCompact.d.ts +27 -15
  23. package/dist/classes/PlaylistCompact.js +42 -46
  24. package/dist/classes/Reply.d.ts +38 -0
  25. package/dist/classes/Reply.js +35 -0
  26. package/dist/classes/SearchResult.d.ts +52 -8
  27. package/dist/classes/SearchResult.js +101 -122
  28. package/dist/classes/Thumbnails.d.ts +42 -0
  29. package/dist/classes/Thumbnails.js +66 -0
  30. package/dist/classes/Video.d.ts +44 -37
  31. package/dist/classes/Video.js +74 -83
  32. package/dist/classes/VideoCompact.d.ts +38 -19
  33. package/dist/classes/VideoCompact.js +53 -53
  34. package/dist/classes/index.d.ts +10 -2
  35. package/dist/classes/index.js +20 -4
  36. package/dist/common/HTTP.d.ts +26 -0
  37. package/dist/common/HTTP.js +85 -0
  38. package/dist/common/decorators.js +6 -26
  39. package/dist/common/helper.d.ts +4 -0
  40. package/dist/common/helper.js +37 -18
  41. package/dist/common/index.d.ts +2 -1
  42. package/dist/common/index.js +5 -3
  43. package/dist/common/mixins.d.ts +2 -0
  44. package/dist/common/mixins.js +12 -0
  45. package/dist/common/types.d.ts +0 -5
  46. package/dist/constants.d.ts +5 -2
  47. package/dist/constants.js +6 -3
  48. package/package.json +23 -20
  49. package/.prettierrc +0 -8
  50. package/.vscode/settings.json +0 -4
  51. package/CHANGELOG.md +0 -6
  52. package/debug.log +0 -47
  53. package/dist/classes/BaseCompact.d.ts +0 -10
  54. package/dist/classes/BaseCompact.js +0 -27
  55. package/dist/classes/client/Client.d.ts +0 -23
  56. package/dist/classes/client/Client.js +0 -128
  57. package/dist/classes/client/index.d.ts +0 -2
  58. package/dist/classes/client/index.js +0 -19
  59. package/dist/classes/client/types.d.ts +0 -12
  60. package/dist/common/axios.d.ts +0 -4
  61. package/dist/common/axios.js +0 -44
  62. package/jest.config.js +0 -5
@@ -1,31 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getQueryParameter = exports.getDuration = void 0;
4
- var url_1 = require("url");
5
- var getDuration = function (s) {
3
+ exports.mapFilter = exports.getContinuationFromItems = exports.stripToInt = exports.getQueryParameter = exports.getDuration = void 0;
4
+ const url_1 = require("url");
5
+ const getDuration = (s) => {
6
6
  s = s.replace(/:/g, ".");
7
- var spl = s.split(".");
7
+ const spl = s.split(".");
8
8
  if (spl.length === 0)
9
9
  return +spl;
10
10
  else {
11
- var sumStr = spl.pop();
12
- if (sumStr !== undefined) {
13
- var sum = +sumStr;
14
- if (spl.length === 1)
15
- sum += +spl[0] * 60;
16
- if (spl.length === 2) {
17
- sum += +spl[1] * 60;
18
- sum += +spl[0] * 3600;
19
- }
20
- return sum;
21
- }
22
- else {
23
- return 0;
11
+ const sumStr = spl.pop();
12
+ let sum = +sumStr;
13
+ if (spl.length === 1)
14
+ sum += +spl[0] * 60;
15
+ if (spl.length === 2) {
16
+ sum += +spl[1] * 60;
17
+ sum += +spl[0] * 3600;
24
18
  }
19
+ return sum;
25
20
  }
26
21
  };
27
22
  exports.getDuration = getDuration;
28
- var getQueryParameter = function (url, queryName) {
23
+ const getQueryParameter = (url, queryName) => {
29
24
  try {
30
25
  return new url_1.URL(url).searchParams.get(queryName) || url;
31
26
  }
@@ -35,3 +30,27 @@ var getQueryParameter = function (url, queryName) {
35
30
  }
36
31
  };
37
32
  exports.getQueryParameter = getQueryParameter;
33
+ const stripToInt = (string) => {
34
+ if (!string)
35
+ return null;
36
+ return +string.replace(/[^0-9]/g, "");
37
+ };
38
+ exports.stripToInt = stripToInt;
39
+ const getContinuationFromItems = (items, accessors = ["continuationEndpoint"]) => {
40
+ const continuation = items[items.length - 1];
41
+ const renderer = continuation === null || continuation === void 0 ? void 0 : continuation.continuationItemRenderer;
42
+ if (!renderer)
43
+ return;
44
+ let current = renderer;
45
+ for (const accessor of accessors) {
46
+ current = current[accessor];
47
+ }
48
+ return current.continuationCommand.token;
49
+ };
50
+ exports.getContinuationFromItems = getContinuationFromItems;
51
+ const mapFilter = (items, key) => {
52
+ return items
53
+ .filter((item) => item[key])
54
+ .map((item) => item[key]);
55
+ };
56
+ exports.mapFilter = mapFilter;
@@ -1,4 +1,5 @@
1
- export { default as axios } from "./axios";
1
+ export { default as HTTP } from "./HTTP";
2
2
  export * from "./helper";
3
3
  export * from "./types";
4
4
  export * from "./decorators";
5
+ export { default as applyMixins } from "./mixins";
@@ -13,9 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.axios = void 0;
17
- var axios_1 = require("./axios");
18
- Object.defineProperty(exports, "axios", { enumerable: true, get: function () { return __importDefault(axios_1).default; } });
16
+ exports.applyMixins = exports.HTTP = void 0;
17
+ var HTTP_1 = require("./HTTP");
18
+ Object.defineProperty(exports, "HTTP", { enumerable: true, get: function () { return __importDefault(HTTP_1).default; } });
19
19
  __exportStar(require("./helper"), exports);
20
20
  __exportStar(require("./types"), exports);
21
21
  __exportStar(require("./decorators"), exports);
22
+ var mixins_1 = require("./mixins");
23
+ Object.defineProperty(exports, "applyMixins", { enumerable: true, get: function () { return __importDefault(mixins_1).default; } });
@@ -0,0 +1,2 @@
1
+ declare const _default: (derivedCtor: any, baseCtors: any[]) => void;
2
+ export default _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
4
+ exports.default = (derivedCtor, baseCtors) => {
5
+ baseCtors.forEach((baseCtor) => {
6
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
7
+ if (name !== "constructor") {
8
+ derivedCtor.prototype[name] = baseCtor.prototype[name];
9
+ }
10
+ });
11
+ });
12
+ };
@@ -1,6 +1 @@
1
1
  export declare type YoutubeRawData = Record<string, any>;
2
- export declare type Thumbnail = {
3
- url: string;
4
- width: number;
5
- height: number;
6
- };
@@ -1,4 +1,7 @@
1
1
  export declare const INNERTUBE_CLIENT_VERSION = "2.20201209.01.00";
2
2
  export declare const INNERTUBE_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
3
- export declare const I_END_POINT = "https://www.youtube.com/youtubei/v1";
4
- export declare const WATCH_END_POINT = "https://www.youtube.com/watch";
3
+ export declare const BASE_URL = "www.youtube.com";
4
+ export declare const I_END_POINT = "/youtubei/v1";
5
+ export declare const LIVE_CHAT_END_POINT: string;
6
+ export declare const WATCH_END_POINT = "/watch";
7
+ export declare const COMMENT_END_POINT = "/comment_service_ajax";
package/dist/constants.js CHANGED
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WATCH_END_POINT = exports.I_END_POINT = exports.INNERTUBE_API_KEY = exports.INNERTUBE_CLIENT_VERSION = void 0;
3
+ exports.COMMENT_END_POINT = exports.WATCH_END_POINT = exports.LIVE_CHAT_END_POINT = exports.I_END_POINT = exports.BASE_URL = exports.INNERTUBE_API_KEY = exports.INNERTUBE_CLIENT_VERSION = void 0;
4
4
  exports.INNERTUBE_CLIENT_VERSION = "2.20201209.01.00";
5
5
  exports.INNERTUBE_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
6
- exports.I_END_POINT = "https://www.youtube.com/youtubei/v1";
7
- exports.WATCH_END_POINT = "https://www.youtube.com/watch";
6
+ exports.BASE_URL = "www.youtube.com";
7
+ exports.I_END_POINT = "/youtubei/v1";
8
+ exports.LIVE_CHAT_END_POINT = `${exports.I_END_POINT}/live_chat/get_live_chat`;
9
+ exports.WATCH_END_POINT = "/watch";
10
+ exports.COMMENT_END_POINT = "/comment_service_ajax";
package/package.json CHANGED
@@ -1,34 +1,32 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "0.0.1-rc.3",
4
- "description": "Simple package to get information from youtube such as search results, video information, related videos, and up next video",
3
+ "version": "0.0.1-rc.32",
4
+ "description": "Simple package to get information from youtube such as videos, playlists, channels, video information & comments, related videos, up next video, and more!",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "directories": {
8
8
  "test": "test"
9
9
  },
10
- "dependencies": {
11
- "axios": "^0.21.0"
12
- },
10
+ "dependencies": {},
13
11
  "devDependencies": {
14
- "@types/jest": "^26.0.19",
15
- "@types/node": "^14.14.12",
16
- "@typescript-eslint/eslint-plugin": "^4.9.1",
17
- "@typescript-eslint/parser": "^4.9.1",
18
- "eslint": "^7.15.0",
19
- "eslint-plugin-prettier": "^3.2.0",
20
- "jest": "^26.6.3",
21
- "jest-extended": "^0.11.5",
22
- "prettier": "^2.2.1",
23
- "ts-jest": "^26.4.4",
24
- "typescript": "^4.1.2"
12
+ "@types/jest": "26.0.19",
13
+ "@types/node": "14.14.12",
14
+ "@typescript-eslint/eslint-plugin": "4.9.1",
15
+ "@typescript-eslint/parser": "4.9.1",
16
+ "eslint": "7.15.0",
17
+ "eslint-plugin-prettier": "3.2.0",
18
+ "jest": "26.6.3",
19
+ "jest-extended": "0.11.5",
20
+ "prettier": "2.2.1",
21
+ "ts-jest": "26.4.4",
22
+ "typescript": "4.1.2"
25
23
  },
26
24
  "scripts": {
27
25
  "test": "jest",
28
26
  "dev": "tsc --watch",
29
27
  "build": "tsc",
30
- "lint:check": "eslint src && prettier -c src",
31
- "lint:fix": "eslint --fix && prettier --write src"
28
+ "lint:check": "eslint src && prettier -c src tests",
29
+ "lint:fix": "eslint --fix && prettier --write src tests"
32
30
  },
33
31
  "repository": {
34
32
  "type": "git",
@@ -42,12 +40,17 @@
42
40
  "videos",
43
41
  "playlist",
44
42
  "channel",
45
- "related"
43
+ "related",
44
+ "comment",
45
+ "comments",
46
+ "live",
47
+ "chat",
48
+ "live chat"
46
49
  ],
47
50
  "author": "Vincent Jonathan",
48
51
  "license": "MIT",
49
52
  "bugs": {
50
53
  "url": "https://github.com/SuspiciousLookingOwl/youtubei/issues"
51
54
  },
52
- "homepage": "https://github.com/SuspiciousLookingOwl/youtubei#readme"
55
+ "homepage": "https://youtubei.netlify.app"
53
56
  }
package/.prettierrc DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "singleQuote": false,
3
- "semi": true,
4
- "tabWidth": 4,
5
- "printWidth": 100,
6
- "useTabs": true,
7
- "endOfLine": "lf"
8
- }
@@ -1,4 +0,0 @@
1
- {
2
- "editor.formatOnSave": true,
3
- "discord.enabled": true,
4
- }
package/CHANGELOG.md DELETED
@@ -1,6 +0,0 @@
1
- # Changelog
2
- All notable changes to this project will be documented in this file.
3
-
4
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
-
package/debug.log DELETED
@@ -1,47 +0,0 @@
1
- [0215/004332.981:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
2
- [0215/004333.607:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
3
- [0215/004333.616:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
4
- [0215/004338.492:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
5
- [0215/004406.315:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
6
- [0215/004406.321:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
7
- [0215/004948.880:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
8
- [0215/004959.055:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
9
- [0215/005002.150:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
10
- [0215/005108.832:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
11
- [0215/005114.322:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
12
- [0215/005122.274:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
13
- [0215/005201.984:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
14
- [0215/194248.201:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
15
- [0215/194248.258:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
16
- [0215/194249.741:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
17
- [0215/194252.714:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
18
- [0215/194303.324:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
19
- [0216/173254.195:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
20
- [0216/173254.202:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
21
- [0216/173254.290:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
22
- [0216/175844.398:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
23
- [0216/175844.409:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
24
- [0216/175844.410:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
25
- [0216/175844.417:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
26
- [0218/023812.802:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
27
- [0218/023815.165:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
28
- [0218/023818.112:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
29
- [0218/023917.208:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
30
- [0218/023917.847:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
31
- [0218/023929.481:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
32
- [0218/023930.506:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
33
- [0218/024053.658:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
34
- [0218/024053.663:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
35
- [0218/024053.670:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
36
- [0218/024227.861:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
37
- [0218/024232.612:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
38
- [0218/024238.248:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
39
- [0218/024552.163:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
40
- [0218/024553.127:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
41
- [0218/024559.602:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
42
- [0218/024559.608:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
43
- [0218/024559.617:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
44
- [0218/024559.626:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
45
- [0218/024559.631:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
46
- [0218/024607.413:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
47
- [0218/032707.827:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2)
@@ -1,10 +0,0 @@
1
- import { Thumbnail } from "../common";
2
- export default class BaseCompact {
3
- id: string;
4
- thumbnails: Thumbnail[];
5
- /**
6
- * Returns thumbnail with the highest resolution
7
- */
8
- get thumbnail(): string;
9
- set thumbnail(_val: string);
10
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var BaseCompact = /** @class */ (function () {
4
- function BaseCompact() {
5
- }
6
- Object.defineProperty(BaseCompact.prototype, "thumbnail", {
7
- /**
8
- * Returns thumbnail with the highest resolution
9
- */
10
- get: function () {
11
- var thumbnail = this.thumbnails[this.thumbnails.length - 1].url;
12
- if (thumbnail.startsWith("//"))
13
- return "https:" + thumbnail;
14
- if (!thumbnail.startsWith("https://"))
15
- return "https://" + thumbnail;
16
- return thumbnail;
17
- },
18
- // To prevent error because of Object.assign from subclass
19
- set: function (_val) {
20
- return;
21
- },
22
- enumerable: false,
23
- configurable: true
24
- });
25
- return BaseCompact;
26
- }());
27
- exports.default = BaseCompact;
@@ -1,23 +0,0 @@
1
- import { SearchOptions } from "./types";
2
- import { Playlist, Video, SearchResult } from "..";
3
- export default class YoutubeClient {
4
- /**
5
- * Searches for videos / playlists / channels
6
- *
7
- * @param {string} query
8
- * @param {SearchOptions} searchOptions
9
- */
10
- search<T extends SearchOptions>(query: string, searchOptions?: Partial<T>): Promise<SearchResult<T>>;
11
- /**
12
- * Get playlist information and its videos by playlist id or URL
13
- *
14
- * @param playlistIdOrUrl
15
- */
16
- getPlaylist(playlistIdOrUrl: string): Promise<Playlist | undefined>;
17
- /**
18
- * Get video information by video id or URL
19
- *
20
- * @param videoIdOrUrl
21
- */
22
- getVideo(videoIdOrUrl: string): Promise<Video | undefined>;
23
- }
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- var constants_1 = require("../../constants");
51
- var common_1 = require("../../common");
52
- var __1 = require("..");
53
- var YoutubeClient = /** @class */ (function () {
54
- function YoutubeClient() {
55
- }
56
- /**
57
- * Searches for videos / playlists / channels
58
- *
59
- * @param {string} query
60
- * @param {SearchOptions} searchOptions
61
- */
62
- YoutubeClient.prototype.search = function (query, searchOptions) {
63
- return __awaiter(this, void 0, void 0, function () {
64
- var options, result;
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0:
68
- options = __assign({ type: "all" }, searchOptions);
69
- result = new __1.SearchResult();
70
- return [4 /*yield*/, result.init(query, options)];
71
- case 1:
72
- _a.sent();
73
- return [2 /*return*/, result];
74
- }
75
- });
76
- });
77
- };
78
- /**
79
- * Get playlist information and its videos by playlist id or URL
80
- *
81
- * @param playlistIdOrUrl
82
- */
83
- YoutubeClient.prototype.getPlaylist = function (playlistIdOrUrl) {
84
- return __awaiter(this, void 0, void 0, function () {
85
- var playlistId, response;
86
- return __generator(this, function (_a) {
87
- switch (_a.label) {
88
- case 0:
89
- playlistId = common_1.getQueryParameter(playlistIdOrUrl, "list");
90
- return [4 /*yield*/, common_1.axios.post(constants_1.I_END_POINT + "/browse", {
91
- browseId: "VL" + playlistId,
92
- })];
93
- case 1:
94
- response = _a.sent();
95
- if (response.data.error || response.data.alerts)
96
- return [2 /*return*/, undefined];
97
- return [2 /*return*/, new __1.Playlist().load(response.data)];
98
- }
99
- });
100
- });
101
- };
102
- /**
103
- * Get video information by video id or URL
104
- *
105
- * @param videoIdOrUrl
106
- */
107
- YoutubeClient.prototype.getVideo = function (videoIdOrUrl) {
108
- return __awaiter(this, void 0, void 0, function () {
109
- var videoId, response;
110
- return __generator(this, function (_a) {
111
- switch (_a.label) {
112
- case 0:
113
- videoId = common_1.getQueryParameter(videoIdOrUrl, "v");
114
- return [4 /*yield*/, common_1.axios.get("" + constants_1.WATCH_END_POINT, {
115
- params: { v: videoId, pbj: 1 },
116
- })];
117
- case 1:
118
- response = _a.sent();
119
- if (!response.data[3].response.contents)
120
- return [2 /*return*/, undefined];
121
- return [2 /*return*/, new __1.Video().load(response.data)];
122
- }
123
- });
124
- });
125
- };
126
- return YoutubeClient;
127
- }());
128
- exports.default = YoutubeClient;
@@ -1,2 +0,0 @@
1
- export { default as Client } from "./Client";
2
- export * from "./types";
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.Client = void 0;
17
- var Client_1 = require("./Client");
18
- Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return __importDefault(Client_1).default; } });
19
- __exportStar(require("./types"), exports);
@@ -1,12 +0,0 @@
1
- import { Channel, PlaylistCompact, VideoCompact } from "..";
2
- export declare type SearchType = "video" | "channel" | "playlist" | "all";
3
- export declare type SearchOptions = {
4
- type: SearchType;
5
- };
6
- export declare type SearchResultType<T> = T extends {
7
- type: "video";
8
- } ? VideoCompact : T extends {
9
- type: "channel";
10
- } ? Channel : T extends {
11
- type: "playlist";
12
- } ? PlaylistCompact : VideoCompact | Channel | PlaylistCompact;
@@ -1,4 +0,0 @@
1
- import { AxiosRequestConfig } from "axios";
2
- declare const axiosInstance: import("axios").AxiosInstance;
3
- export declare const axiosRequestInterceptor: (config: AxiosRequestConfig) => AxiosRequestConfig;
4
- export default axiosInstance;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.axiosRequestInterceptor = void 0;
18
- var axios_1 = __importDefault(require("axios"));
19
- var constants_1 = require("../constants");
20
- var axiosInstance = axios_1.default.create();
21
- var axiosRequestInterceptor = function (config) {
22
- var _a, _b;
23
- if (((_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === "POST") {
24
- config.params = __assign({ key: constants_1.INNERTUBE_API_KEY }, config.params);
25
- config.data = __assign({ context: {
26
- client: {
27
- clientName: "WEB",
28
- clientVersion: constants_1.INNERTUBE_CLIENT_VERSION,
29
- },
30
- } }, config.data);
31
- }
32
- else if (((_b = config.method) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === "GET") {
33
- config.headers = {
34
- "x-youtube-client-version": constants_1.INNERTUBE_CLIENT_VERSION,
35
- "x-youtube-client-name": 1,
36
- };
37
- config.params = __assign({}, config.params);
38
- }
39
- return config;
40
- };
41
- exports.axiosRequestInterceptor = axiosRequestInterceptor;
42
- axiosInstance.interceptors.request.use(exports.axiosRequestInterceptor);
43
- axiosInstance.defaults.validateStatus = function () { return true; };
44
- exports.default = axiosInstance;
package/jest.config.js DELETED
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- preset: "ts-jest",
3
- testEnvironment: "node",
4
- testTimeout: 15000,
5
- };