youtubei 1.6.5 → 1.6.7

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.
@@ -33,6 +33,7 @@ class HTTP {
33
33
  "accept-encoding": "gzip, deflate, br",
34
34
  };
35
35
  this.oauth = Object.assign({ enabled: false, token: null, expiresAt: null }, options.oauth);
36
+ this.pot = options.pot;
36
37
  this.authorizationPromise = null;
37
38
  this.defaultFetchOptions = options.fetchOptions || {};
38
39
  this.defaultClientOptions = options.youtubeClientOptions || {};
@@ -43,10 +44,13 @@ class HTTP {
43
44
  });
44
45
  }
45
46
  post(path, options) {
47
+ var _a;
46
48
  return __awaiter(this, void 0, void 0, function* () {
47
49
  return yield this.request(path, Object.assign(Object.assign({}, options), { method: "POST", params: Object.assign({ key: this.apiKey, prettyPrint: "false" }, options === null || options === void 0 ? void 0 : options.params), data: Object.assign({ context: {
48
- client: Object.assign({ clientName: this.clientName, clientVersion: this.clientVersion }, this.defaultClientOptions),
49
- } }, options === null || options === void 0 ? void 0 : options.data) }));
50
+ client: Object.assign({ clientName: this.clientName, clientVersion: this.clientVersion, visitorData: (_a = this.pot) === null || _a === void 0 ? void 0 : _a.visitorData }, this.defaultClientOptions),
51
+ }, serviceIntegrityDimensions: this.pot
52
+ ? { poToken: this.pot.token, }
53
+ : undefined }, options === null || options === void 0 ? void 0 : options.data) }));
50
54
  });
51
55
  }
52
56
  request(path, partialOptions) {
@@ -17,8 +17,8 @@ const constants_1 = require("../constants");
17
17
  /** Youtube Music Client */
18
18
  class MusicClient {
19
19
  constructor(options = {}) {
20
- const fullOptions = Object.assign(Object.assign({ initialCookie: "", fetchOptions: {} }, options), { youtubeClientOptions: Object.assign({ hl: "en", gl: "US" }, options.youtubeClientOptions) });
21
- this.http = new common_1.HTTP(Object.assign({ apiKey: constants_1.INNERTUBE_API_KEY, baseUrl: constants_1.BASE_URL, clientName: "WEB_REMIX", clientVersion: constants_1.INNERTUBE_CLIENT_VERSION }, fullOptions));
20
+ const fullOptions = Object.assign(Object.assign({ initialCookie: "", oauth: { enabled: false }, fetchOptions: {} }, options), { youtubeClientOptions: Object.assign({ hl: "en", gl: "US" }, options.youtubeClientOptions), apiKey: options.apiKey || constants_1.INNERTUBE_API_KEY, baseUrl: options.baseUrl || constants_1.BASE_URL, clientName: options.clientName || constants_1.INNERTUBE_CLIENT_NAME, clientVersion: options.clientVersion || constants_1.INNERTUBE_CLIENT_VERSION });
21
+ this.http = new common_1.HTTP(fullOptions);
22
22
  }
23
23
  search(query, type) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.I_END_POINT = exports.BASE_URL = exports.INNERTUBE_API_KEY = exports.INNERTUBE_CLIENT_VERSION = void 0;
3
+ exports.I_END_POINT = exports.BASE_URL = exports.INNERTUBE_API_KEY = exports.INNERTUBE_CLIENT_NAME = exports.INNERTUBE_CLIENT_VERSION = void 0;
4
4
  exports.INNERTUBE_CLIENT_VERSION = "1.20221219.01.00";
5
+ exports.INNERTUBE_CLIENT_NAME = "WEB_REMIX";
5
6
  exports.INNERTUBE_API_KEY = "AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30";
6
7
  exports.BASE_URL = "music.youtube.com";
7
8
  exports.I_END_POINT = "/youtubei/v1";
@@ -52,18 +52,19 @@ class VideoCaptions extends Base_1.Base {
52
52
  * Get captions of a specific language or a translation of a specific language
53
53
  */
54
54
  get(languageCode, translationLanguageCode) {
55
- var _a, _b;
55
+ var _a, _b, _c;
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
- if (!languageCode)
57
+ if (!languageCode && ((_a = this.client.options.youtubeClientOptions) === null || _a === void 0 ? void 0 : _a.hl)) {
58
58
  languageCode = this.client.options.youtubeClientOptions.hl;
59
- const url = (_a = this.languages.find((l) => l.code.toUpperCase() === (languageCode === null || languageCode === void 0 ? void 0 : languageCode.toUpperCase()))) === null || _a === void 0 ? void 0 : _a.url;
59
+ }
60
+ const url = (_b = this.languages.find((l) => l.code.toUpperCase() === (languageCode === null || languageCode === void 0 ? void 0 : languageCode.toUpperCase()))) === null || _b === void 0 ? void 0 : _b.url;
60
61
  if (!url)
61
62
  return undefined;
62
63
  const params = { fmt: "json3" };
63
64
  if (translationLanguageCode)
64
65
  params["tlang"] = translationLanguageCode;
65
66
  const response = yield this.client.http.get(url, { params });
66
- const captions = (_b = response.data.events) === null || _b === void 0 ? void 0 : _b.reduce((curr, e) => {
67
+ const captions = (_c = response.data.events) === null || _c === void 0 ? void 0 : _c.reduce((curr, e) => {
67
68
  var _a;
68
69
  if (e.segs === undefined)
69
70
  return curr;
@@ -7,8 +7,8 @@ const PlaylistCompact_1 = require("../PlaylistCompact");
7
7
  const VideoCompact_1 = require("../VideoCompact");
8
8
  class ChannelParser {
9
9
  static loadChannel(target, data) {
10
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
11
- let channelId, title, avatar, subscriberCountText, videoCountText, tvBanner, mobileBanner, banner;
10
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
11
+ let channelId, title, handle, description, avatar, subscriberCountText, videoCountText, tvBanner, mobileBanner, banner;
12
12
  const { c4TabbedHeaderRenderer, pageHeaderRenderer } = data.header;
13
13
  if (c4TabbedHeaderRenderer) {
14
14
  channelId = c4TabbedHeaderRenderer.channelId;
@@ -25,15 +25,20 @@ class ChannelParser {
25
25
  data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.endpoint
26
26
  .browseEndpoint.browseId;
27
27
  title = pageHeaderRenderer.pageTitle;
28
- const { metadata, image: imageModel, banner: bannerModel, } = pageHeaderRenderer.content.pageHeaderViewModel;
29
- const metadataRow = metadata.contentMetadataViewModel.metadataRows.find((m) => m.metadataParts);
30
- subscriberCountText = metadataRow.metadataParts.find((m) => !m.text.styeRuns).text.content;
31
- videoCountText = (_j = metadataRow.metadataParts.find((m) => m.text.styeRuns)) === null || _j === void 0 ? void 0 : _j.text.content;
28
+ const { metadata, image: imageModel, banner: bannerModel, description: descriptionModel, } = pageHeaderRenderer.content.pageHeaderViewModel;
29
+ const metadataRow = metadata.contentMetadataViewModel.metadataRows.find((m) => m.metadataParts && m.metadataParts.length == 2);
30
+ const handleRow = metadata.contentMetadataViewModel.metadataRows.find((m) => m.metadataParts && m.metadataParts.length == 1);
31
+ handle = (_j = handleRow === null || handleRow === void 0 ? void 0 : handleRow.metadataParts[0].text) === null || _j === void 0 ? void 0 : _j.content;
32
+ videoCountText = (_k = metadataRow.metadataParts.find((m) => m.text.styleRuns)) === null || _k === void 0 ? void 0 : _k.text.content;
33
+ subscriberCountText = (_l = metadataRow.metadataParts.find((m) => !m.text.styleRuns)) === null || _l === void 0 ? void 0 : _l.text.content;
32
34
  avatar = imageModel.decoratedAvatarViewModel.avatar.avatarViewModel.image.sources;
33
35
  banner = bannerModel === null || bannerModel === void 0 ? void 0 : bannerModel.imageBannerViewModel.image.sources;
36
+ description = descriptionModel === null || descriptionModel === void 0 ? void 0 : descriptionModel.descriptionPreviewViewModel.description.content;
34
37
  }
35
38
  target.id = channelId;
36
39
  target.name = title;
40
+ target.handle = handle;
41
+ target.description = description;
37
42
  target.thumbnails = new common_1.Thumbnails().load(avatar);
38
43
  target.videoCount = videoCountText;
39
44
  target.subscriberCount = subscriberCountText;
@@ -21,8 +21,8 @@ const constants_1 = require("../constants");
21
21
  /** Youtube Client */
22
22
  class Client {
23
23
  constructor(options = {}) {
24
- this.options = Object.assign(Object.assign({ initialCookie: "", oauth: { enabled: false }, fetchOptions: {} }, options), { youtubeClientOptions: Object.assign({ hl: "en", gl: "US" }, options.youtubeClientOptions) });
25
- this.http = new common_1.HTTP(Object.assign({ apiKey: constants_1.INNERTUBE_API_KEY, baseUrl: constants_1.BASE_URL, clientName: constants_1.INNERTUBE_CLIENT_NAME, clientVersion: constants_1.INNERTUBE_CLIENT_VERSION }, this.options));
24
+ this.options = Object.assign(Object.assign({ initialCookie: "", oauth: { enabled: false }, fetchOptions: {} }, options), { youtubeClientOptions: Object.assign({ hl: "en", gl: "US" }, options.youtubeClientOptions), apiKey: options.apiKey || constants_1.INNERTUBE_API_KEY, baseUrl: options.baseUrl || constants_1.BASE_URL, clientName: options.clientName || constants_1.INNERTUBE_CLIENT_NAME, clientVersion: options.clientVersion || constants_1.INNERTUBE_CLIENT_VERSION });
25
+ this.http = new common_1.HTTP(this.options);
26
26
  }
27
27
  get oauth() {
28
28
  return {
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.optionsToProto = exports.SearchProto = void 0;
7
7
  const protobufjs_1 = __importDefault(require("protobufjs"));
8
8
  // TODO move this to .proto file
9
- exports.SearchProto = protobufjs_1.default.parse(`
9
+ exports.SearchProto = protobufjs_1.default
10
+ .parse(`
10
11
  message SearchOptions {
11
12
  message Options {
12
13
  optional int32 uploadDate = 1;
@@ -26,7 +27,8 @@ exports.SearchProto = protobufjs_1.default.parse(`
26
27
  optional int32 sortBy = 1;
27
28
  optional Options options = 2;
28
29
  }
29
- `).root.lookupType("SearchOptions");
30
+ `)
31
+ .root.lookupType("SearchOptions");
30
32
  const searchUploadDateProto = {
31
33
  all: 0,
32
34
  hour: 1,
@@ -5,7 +5,7 @@ const common_1 = require("../../common");
5
5
  const BaseChannel_1 = require("../BaseChannel");
6
6
  class VideoCompactParser {
7
7
  static loadVideoCompact(target, data) {
8
- var _a, _b, _c, _d, _e, _f, _g, _h;
8
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
9
9
  const { videoId, title, headline, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, channelThumbnailSupportedRenderers, detailedMetadataSnippets, } = data;
10
10
  target.id = videoId;
11
11
  target.title = headline
@@ -21,8 +21,10 @@ class VideoCompactParser {
21
21
  target.isLive =
22
22
  !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW") ||
23
23
  ((_e = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _e === void 0 ? void 0 : _e.style) === "LIVE";
24
+ target.isShort =
25
+ ((_f = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _f === void 0 ? void 0 : _f.style) === "SHORTS" || false;
24
26
  // Channel
25
- const browseEndpoint = (_h = (_g = (_f = (ownerText || shortBylineText)) === null || _f === void 0 ? void 0 : _f.runs[0]) === null || _g === void 0 ? void 0 : _g.navigationEndpoint) === null || _h === void 0 ? void 0 : _h.browseEndpoint;
27
+ const browseEndpoint = (_j = (_h = (_g = (ownerText || shortBylineText)) === null || _g === void 0 ? void 0 : _g.runs[0]) === null || _h === void 0 ? void 0 : _h.navigationEndpoint) === null || _j === void 0 ? void 0 : _j.browseEndpoint;
26
28
  if (browseEndpoint) {
27
29
  const id = browseEndpoint.browseId;
28
30
  const thumbnails = channelThumbnailSupportedRenderers === null || channelThumbnailSupportedRenderers === void 0 ? void 0 : channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail.thumbnails;
@@ -92,6 +92,7 @@ var HTTP = /** @class */ (function () {
92
92
  "accept-encoding": "gzip, deflate, br",
93
93
  };
94
94
  this.oauth = __assign({ enabled: false, token: null, expiresAt: null }, options.oauth);
95
+ this.pot = options.pot;
95
96
  this.authorizationPromise = null;
96
97
  this.defaultFetchOptions = options.fetchOptions || {};
97
98
  this.defaultClientOptions = options.youtubeClientOptions || {};
@@ -107,13 +108,16 @@ var HTTP = /** @class */ (function () {
107
108
  });
108
109
  };
109
110
  HTTP.prototype.post = function (path, options) {
111
+ var _a;
110
112
  return __awaiter(this, void 0, void 0, function () {
111
- return __generator(this, function (_a) {
112
- switch (_a.label) {
113
+ return __generator(this, function (_b) {
114
+ switch (_b.label) {
113
115
  case 0: return [4 /*yield*/, this.request(path, __assign(__assign({}, options), { method: "POST", params: __assign({ key: this.apiKey, prettyPrint: "false" }, options === null || options === void 0 ? void 0 : options.params), data: __assign({ context: {
114
- client: __assign({ clientName: this.clientName, clientVersion: this.clientVersion }, this.defaultClientOptions),
115
- } }, options === null || options === void 0 ? void 0 : options.data) }))];
116
- case 1: return [2 /*return*/, _a.sent()];
116
+ client: __assign({ clientName: this.clientName, clientVersion: this.clientVersion, visitorData: (_a = this.pot) === null || _a === void 0 ? void 0 : _a.visitorData }, this.defaultClientOptions),
117
+ }, serviceIntegrityDimensions: this.pot
118
+ ? { poToken: this.pot.token, }
119
+ : undefined }, options === null || options === void 0 ? void 0 : options.data) }))];
120
+ case 1: return [2 /*return*/, _b.sent()];
117
121
  }
118
122
  });
119
123
  });
@@ -48,13 +48,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  import { HTTP } from "../../common";
49
49
  import { MusicLyrics } from "../MusicLyrics";
50
50
  import { MusicAllSearchResultParser, MusicSearchResult, } from "../MusicSearchResult";
51
- import { BASE_URL, INNERTUBE_API_KEY, INNERTUBE_CLIENT_VERSION, I_END_POINT } from "../constants";
51
+ import { BASE_URL, INNERTUBE_API_KEY, INNERTUBE_CLIENT_NAME, INNERTUBE_CLIENT_VERSION, I_END_POINT, } from "../constants";
52
52
  /** Youtube Music Client */
53
53
  var MusicClient = /** @class */ (function () {
54
54
  function MusicClient(options) {
55
55
  if (options === void 0) { options = {}; }
56
- var fullOptions = __assign(__assign({ initialCookie: "", fetchOptions: {} }, options), { youtubeClientOptions: __assign({ hl: "en", gl: "US" }, options.youtubeClientOptions) });
57
- this.http = new HTTP(__assign({ apiKey: INNERTUBE_API_KEY, baseUrl: BASE_URL, clientName: "WEB_REMIX", clientVersion: INNERTUBE_CLIENT_VERSION }, fullOptions));
56
+ var fullOptions = __assign(__assign({ initialCookie: "", oauth: { enabled: false }, fetchOptions: {} }, options), { youtubeClientOptions: __assign({ hl: "en", gl: "US" }, options.youtubeClientOptions), apiKey: options.apiKey || INNERTUBE_API_KEY, baseUrl: options.baseUrl || BASE_URL, clientName: options.clientName || INNERTUBE_CLIENT_NAME, clientVersion: options.clientVersion || INNERTUBE_CLIENT_VERSION });
57
+ this.http = new HTTP(fullOptions);
58
58
  }
59
59
  MusicClient.prototype.search = function (query, type) {
60
60
  return __awaiter(this, void 0, void 0, function () {
@@ -1,4 +1,5 @@
1
1
  export var INNERTUBE_CLIENT_VERSION = "1.20221219.01.00";
2
+ export var INNERTUBE_CLIENT_NAME = "WEB_REMIX";
2
3
  export var INNERTUBE_API_KEY = "AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30";
3
4
  export var BASE_URL = "music.youtube.com";
4
5
  export var I_END_POINT = "/youtubei/v1";
@@ -95,15 +95,16 @@ var VideoCaptions = /** @class */ (function (_super) {
95
95
  * Get captions of a specific language or a translation of a specific language
96
96
  */
97
97
  VideoCaptions.prototype.get = function (languageCode, translationLanguageCode) {
98
- var _a, _b;
98
+ var _a, _b, _c;
99
99
  return __awaiter(this, void 0, void 0, function () {
100
100
  var url, params, response, captions;
101
- return __generator(this, function (_c) {
102
- switch (_c.label) {
101
+ return __generator(this, function (_d) {
102
+ switch (_d.label) {
103
103
  case 0:
104
- if (!languageCode)
104
+ if (!languageCode && ((_a = this.client.options.youtubeClientOptions) === null || _a === void 0 ? void 0 : _a.hl)) {
105
105
  languageCode = this.client.options.youtubeClientOptions.hl;
106
- url = (_a = this.languages.find(function (l) { return l.code.toUpperCase() === (languageCode === null || languageCode === void 0 ? void 0 : languageCode.toUpperCase()); })) === null || _a === void 0 ? void 0 : _a.url;
106
+ }
107
+ url = (_b = this.languages.find(function (l) { return l.code.toUpperCase() === (languageCode === null || languageCode === void 0 ? void 0 : languageCode.toUpperCase()); })) === null || _b === void 0 ? void 0 : _b.url;
107
108
  if (!url)
108
109
  return [2 /*return*/, undefined];
109
110
  params = { fmt: "json3" };
@@ -111,8 +112,8 @@ var VideoCaptions = /** @class */ (function (_super) {
111
112
  params["tlang"] = translationLanguageCode;
112
113
  return [4 /*yield*/, this.client.http.get(url, { params: params })];
113
114
  case 1:
114
- response = _c.sent();
115
- captions = (_b = response.data.events) === null || _b === void 0 ? void 0 : _b.reduce(function (curr, e) {
115
+ response = _d.sent();
116
+ captions = (_c = response.data.events) === null || _c === void 0 ? void 0 : _c.reduce(function (curr, e) {
116
117
  var _a;
117
118
  if (e.segs === undefined)
118
119
  return curr;
@@ -17,9 +17,9 @@ var ChannelParser = /** @class */ (function () {
17
17
  function ChannelParser() {
18
18
  }
19
19
  ChannelParser.loadChannel = function (target, data) {
20
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
21
- var channelId, title, avatar, subscriberCountText, videoCountText, tvBanner, mobileBanner, banner;
22
- var _k = data.header, c4TabbedHeaderRenderer = _k.c4TabbedHeaderRenderer, pageHeaderRenderer = _k.pageHeaderRenderer;
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
21
+ var channelId, title, handle, description, avatar, subscriberCountText, videoCountText, tvBanner, mobileBanner, banner;
22
+ var _m = data.header, c4TabbedHeaderRenderer = _m.c4TabbedHeaderRenderer, pageHeaderRenderer = _m.pageHeaderRenderer;
23
23
  if (c4TabbedHeaderRenderer) {
24
24
  channelId = c4TabbedHeaderRenderer.channelId;
25
25
  title = c4TabbedHeaderRenderer.title;
@@ -35,15 +35,20 @@ var ChannelParser = /** @class */ (function () {
35
35
  data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.endpoint
36
36
  .browseEndpoint.browseId;
37
37
  title = pageHeaderRenderer.pageTitle;
38
- var _l = pageHeaderRenderer.content.pageHeaderViewModel, metadata = _l.metadata, imageModel = _l.image, bannerModel = _l.banner;
39
- var metadataRow = metadata.contentMetadataViewModel.metadataRows.find(function (m) { return m.metadataParts; });
40
- subscriberCountText = metadataRow.metadataParts.find(function (m) { return !m.text.styeRuns; }).text.content;
41
- videoCountText = (_j = metadataRow.metadataParts.find(function (m) { return m.text.styeRuns; })) === null || _j === void 0 ? void 0 : _j.text.content;
38
+ var _o = pageHeaderRenderer.content.pageHeaderViewModel, metadata = _o.metadata, imageModel = _o.image, bannerModel = _o.banner, descriptionModel = _o.description;
39
+ var metadataRow = metadata.contentMetadataViewModel.metadataRows.find(function (m) { return m.metadataParts && m.metadataParts.length == 2; });
40
+ var handleRow = metadata.contentMetadataViewModel.metadataRows.find(function (m) { return m.metadataParts && m.metadataParts.length == 1; });
41
+ handle = (_j = handleRow === null || handleRow === void 0 ? void 0 : handleRow.metadataParts[0].text) === null || _j === void 0 ? void 0 : _j.content;
42
+ videoCountText = (_k = metadataRow.metadataParts.find(function (m) { return m.text.styleRuns; })) === null || _k === void 0 ? void 0 : _k.text.content;
43
+ subscriberCountText = (_l = metadataRow.metadataParts.find(function (m) { return !m.text.styleRuns; })) === null || _l === void 0 ? void 0 : _l.text.content;
42
44
  avatar = imageModel.decoratedAvatarViewModel.avatar.avatarViewModel.image.sources;
43
45
  banner = bannerModel === null || bannerModel === void 0 ? void 0 : bannerModel.imageBannerViewModel.image.sources;
46
+ description = descriptionModel === null || descriptionModel === void 0 ? void 0 : descriptionModel.descriptionPreviewViewModel.description.content;
44
47
  }
45
48
  target.id = channelId;
46
49
  target.name = title;
50
+ target.handle = handle;
51
+ target.description = description;
47
52
  target.thumbnails = new Thumbnails().load(avatar);
48
53
  target.videoCount = videoCountText;
49
54
  target.subscriberCount = subscriberCountText;
@@ -73,8 +73,8 @@ import { BASE_URL, INNERTUBE_API_KEY, INNERTUBE_CLIENT_NAME, INNERTUBE_CLIENT_VE
73
73
  var Client = /** @class */ (function () {
74
74
  function Client(options) {
75
75
  if (options === void 0) { options = {}; }
76
- this.options = __assign(__assign({ initialCookie: "", oauth: { enabled: false }, fetchOptions: {} }, options), { youtubeClientOptions: __assign({ hl: "en", gl: "US" }, options.youtubeClientOptions) });
77
- this.http = new HTTP(__assign({ apiKey: INNERTUBE_API_KEY, baseUrl: BASE_URL, clientName: INNERTUBE_CLIENT_NAME, clientVersion: INNERTUBE_CLIENT_VERSION }, this.options));
76
+ this.options = __assign(__assign({ initialCookie: "", oauth: { enabled: false }, fetchOptions: {} }, options), { youtubeClientOptions: __assign({ hl: "en", gl: "US" }, options.youtubeClientOptions), apiKey: options.apiKey || INNERTUBE_API_KEY, baseUrl: options.baseUrl || BASE_URL, clientName: options.clientName || INNERTUBE_CLIENT_NAME, clientVersion: options.clientVersion || INNERTUBE_CLIENT_VERSION });
77
+ this.http = new HTTP(this.options);
78
78
  }
79
79
  Object.defineProperty(Client.prototype, "oauth", {
80
80
  get: function () {
@@ -11,7 +11,9 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import protobuf from "protobufjs";
13
13
  // TODO move this to .proto file
14
- export var SearchProto = protobuf.parse("\n\tmessage SearchOptions {\n\t\tmessage Options {\n\t\t\toptional int32 uploadDate = 1;\n\t\t\toptional int32 type = 2;\n\t\t\toptional int32 duration = 3;\n\t\t\toptional int32 hd = 4;\n\t\t\toptional int32 subtitles = 5;\n\t\t\toptional int32 creativeCommons = 6;\n\t\t\toptional int32 live = 8;\n\t\t\toptional int32 _4k = 14;\n\t\t\toptional int32 _360 = 15;\n\t\t\toptional int32 location = 23;\n\t\t\toptional int32 hdr = 25;\n\t\t\toptional int32 vr180 = 26;\n\t\t}\n\n\t\toptional int32 sortBy = 1;\n\t\toptional Options options = 2;\n\t}\n").root.lookupType("SearchOptions");
14
+ export var SearchProto = protobuf
15
+ .parse("\n\tmessage SearchOptions {\n\t\tmessage Options {\n\t\t\toptional int32 uploadDate = 1;\n\t\t\toptional int32 type = 2;\n\t\t\toptional int32 duration = 3;\n\t\t\toptional int32 hd = 4;\n\t\t\toptional int32 subtitles = 5;\n\t\t\toptional int32 creativeCommons = 6;\n\t\t\toptional int32 live = 8;\n\t\t\toptional int32 _4k = 14;\n\t\t\toptional int32 _360 = 15;\n\t\t\toptional int32 location = 23;\n\t\t\toptional int32 hdr = 25;\n\t\t\toptional int32 vr180 = 26;\n\t\t}\n\n\t\toptional int32 sortBy = 1;\n\t\toptional Options options = 2;\n\t}\n")
16
+ .root.lookupType("SearchOptions");
15
17
  var searchUploadDateProto = {
16
18
  all: 0,
17
19
  hour: 1,
@@ -4,7 +4,7 @@ var VideoCompactParser = /** @class */ (function () {
4
4
  function VideoCompactParser() {
5
5
  }
6
6
  VideoCompactParser.loadVideoCompact = function (target, data) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
8
8
  var videoId = data.videoId, title = data.title, headline = data.headline, lengthText = data.lengthText, thumbnail = data.thumbnail, ownerText = data.ownerText, shortBylineText = data.shortBylineText, publishedTimeText = data.publishedTimeText, viewCountText = data.viewCountText, badges = data.badges, thumbnailOverlays = data.thumbnailOverlays, channelThumbnailSupportedRenderers = data.channelThumbnailSupportedRenderers, detailedMetadataSnippets = data.detailedMetadataSnippets;
9
9
  target.id = videoId;
10
10
  target.title = headline
@@ -20,8 +20,10 @@ var VideoCompactParser = /** @class */ (function () {
20
20
  target.isLive =
21
21
  !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW") ||
22
22
  ((_e = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _e === void 0 ? void 0 : _e.style) === "LIVE";
23
+ target.isShort =
24
+ ((_f = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _f === void 0 ? void 0 : _f.style) === "SHORTS" || false;
23
25
  // Channel
24
- var browseEndpoint = (_h = (_g = (_f = (ownerText || shortBylineText)) === null || _f === void 0 ? void 0 : _f.runs[0]) === null || _g === void 0 ? void 0 : _g.navigationEndpoint) === null || _h === void 0 ? void 0 : _h.browseEndpoint;
26
+ var browseEndpoint = (_j = (_h = (_g = (ownerText || shortBylineText)) === null || _g === void 0 ? void 0 : _g.runs[0]) === null || _h === void 0 ? void 0 : _h.navigationEndpoint) === null || _j === void 0 ? void 0 : _j.browseEndpoint;
25
27
  if (browseEndpoint) {
26
28
  var id = browseEndpoint.browseId;
27
29
  var thumbnails = channelThumbnailSupportedRenderers === null || channelThumbnailSupportedRenderers === void 0 ? void 0 : channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail.thumbnails;
@@ -8,7 +8,11 @@ export declare type OAuthProps = {
8
8
  expiresAt: Date | null;
9
9
  refreshToken?: string;
10
10
  };
11
- declare type HTTPOptions = {
11
+ export declare type PotOptions = {
12
+ token: string;
13
+ visitorData: string;
14
+ };
15
+ export declare type HTTPOptions = {
12
16
  apiKey: string;
13
17
  baseUrl: string;
14
18
  clientName: string;
@@ -17,6 +21,7 @@ declare type HTTPOptions = {
17
21
  youtubeClientOptions?: Record<string, unknown>;
18
22
  initialCookie?: string;
19
23
  oauth?: OAuthOptions;
24
+ pot?: PotOptions;
20
25
  };
21
26
  declare type Response<T = any> = {
22
27
  data: T;
@@ -38,6 +43,7 @@ export declare class HTTP {
38
43
  private defaultFetchOptions;
39
44
  private defaultClientOptions;
40
45
  private authorizationPromise;
46
+ private pot?;
41
47
  oauth: OAuthOptions & OAuthProps;
42
48
  constructor(options: HTTPOptions);
43
49
  get(path: string, options?: Partial<Options>): Promise<Response>;
@@ -1,5 +1,4 @@
1
- import { RequestInit } from "node-fetch";
2
- import { HTTP, Shelf } from "../../common";
1
+ import { HTTP, HTTPOptions, Shelf } from "../../common";
3
2
  import { MusicAlbumCompact } from "../MusicAlbumCompact";
4
3
  import { MusicArtistCompact } from "../MusicArtistCompact";
5
4
  import { MusicLyrics } from "../MusicLyrics";
@@ -10,13 +9,7 @@ export declare type MusicTopShelf = {
10
9
  item?: MusicVideoCompact | MusicAlbumCompact | MusicPlaylistCompact | MusicArtistCompact;
11
10
  more?: (MusicVideoCompact | MusicAlbumCompact | MusicPlaylistCompact | MusicArtistCompact)[];
12
11
  };
13
- export declare type MusicClientOptions = {
14
- initialCookie: string;
15
- /** Optional options for http client */
16
- fetchOptions: Partial<RequestInit>;
17
- /** Optional options passed when sending a request to youtube (context.client) */
18
- youtubeClientOptions: Record<string, unknown>;
19
- };
12
+ export declare type MusicClientOptions = HTTPOptions;
20
13
  /** Youtube Music Client */
21
14
  export declare class MusicClient {
22
15
  /** @hidden */
@@ -1,4 +1,5 @@
1
1
  export declare const INNERTUBE_CLIENT_VERSION = "1.20221219.01.00";
2
+ export declare const INNERTUBE_CLIENT_NAME = "WEB_REMIX";
2
3
  export declare const INNERTUBE_API_KEY = "AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30";
3
4
  export declare const BASE_URL = "music.youtube.com";
4
5
  export declare const I_END_POINT = "/youtubei/v1";
@@ -16,6 +16,10 @@ export declare class BaseChannel extends Base implements BaseChannelProperties {
16
16
  id: string;
17
17
  /** The channel's name */
18
18
  name: string;
19
+ /** The channel's handle start with @ */
20
+ handle: string;
21
+ /** The channel's description */
22
+ description?: string;
19
23
  /** Thumbnails of this Channel */
20
24
  thumbnails?: Thumbnails;
21
25
  /**
@@ -1,5 +1,4 @@
1
- import { RequestInit } from "node-fetch";
2
- import { HTTP, OAuthOptions, OAuthProps } from "../../common";
1
+ import { HTTP, HTTPOptions, OAuthProps } from "../../common";
3
2
  import { Caption } from "../Caption";
4
3
  import { Channel } from "../Channel";
5
4
  import { LiveVideo } from "../LiveVideo";
@@ -7,20 +6,13 @@ import { MixPlaylist } from "../MixPlaylist";
7
6
  import { Playlist } from "../Playlist";
8
7
  import { SearchOptions, SearchResult, SearchResultItem } from "../SearchResult";
9
8
  import { Video } from "../Video";
10
- export declare type ClientOptions = {
11
- initialCookie: string;
12
- oauth: OAuthOptions;
13
- /** Optional options for http client */
14
- fetchOptions: Partial<RequestInit>;
15
- /** Optional options passed when sending a request to youtube (context.client) */
16
- youtubeClientOptions: Record<string, string>;
17
- };
9
+ export declare type ClientOptions = HTTPOptions;
18
10
  /** Youtube Client */
19
11
  export declare class Client {
20
12
  /** @hidden */
21
13
  http: HTTP;
22
14
  /** @hidden */
23
- options: ClientOptions;
15
+ options: HTTPOptions;
24
16
  constructor(options?: Partial<ClientOptions>);
25
17
  get oauth(): OAuthProps;
26
18
  /**
@@ -28,6 +28,8 @@ export declare class VideoCompact extends Base implements VideoCompactProperties
28
28
  duration: number | null;
29
29
  /** Whether this video is a live now or not */
30
30
  isLive: boolean;
31
+ /** Whether this video is a shorts or not */
32
+ isShort: boolean;
31
33
  /** The channel who uploads this video */
32
34
  channel?: BaseChannel;
33
35
  /** The date this video is uploaded at */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
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/cjs/index.js",
6
6
  "module": "dist/esm/index.js",