youtubei 1.1.2 → 1.2.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.
Files changed (36) hide show
  1. package/dist/cjs/music/MusicClient/MusicSearchResultParser.js +3 -1
  2. package/dist/cjs/youtube/BaseChannel/BaseChannel.js +4 -0
  3. package/dist/cjs/youtube/BaseChannel/BaseChannelParser.js +6 -4
  4. package/dist/cjs/youtube/BaseChannel/ChannelLive.js +57 -0
  5. package/dist/cjs/youtube/BaseChannel/ChannelPlaylists.js +1 -1
  6. package/dist/cjs/youtube/BaseChannel/ChannelShorts.js +57 -0
  7. package/dist/cjs/youtube/BaseChannel/ChannelVideos.js +1 -1
  8. package/dist/cjs/youtube/BaseChannel/index.js +2 -0
  9. package/dist/cjs/youtube/BaseVideo/BaseVideoParser.js +2 -3
  10. package/dist/cjs/youtube/Client/Client.js +1 -1
  11. package/dist/cjs/youtube/SearchResult/SearchResult.js +1 -1
  12. package/dist/cjs/youtube/SearchResult/proto/index.js +5 -5
  13. package/dist/cjs/youtube/Transcript/proto/TranscriptParamsProto.js +3 -3
  14. package/dist/cjs/youtube/VideoCompact/VideoCompactParser.js +2 -2
  15. package/dist/esm/music/MusicClient/MusicSearchResultParser.js +3 -1
  16. package/dist/esm/youtube/BaseChannel/BaseChannel.js +4 -0
  17. package/dist/esm/youtube/BaseChannel/BaseChannelParser.js +6 -4
  18. package/dist/esm/youtube/BaseChannel/ChannelLive.js +109 -0
  19. package/dist/esm/youtube/BaseChannel/ChannelPlaylists.js +1 -1
  20. package/dist/esm/youtube/BaseChannel/ChannelShorts.js +109 -0
  21. package/dist/esm/youtube/BaseChannel/ChannelVideos.js +1 -1
  22. package/dist/esm/youtube/BaseChannel/index.js +2 -0
  23. package/dist/esm/youtube/BaseVideo/BaseVideoParser.js +3 -4
  24. package/dist/esm/youtube/Client/Client.js +1 -1
  25. package/dist/esm/youtube/SearchResult/SearchResult.js +1 -1
  26. package/dist/esm/youtube/SearchResult/proto/index.js +2 -2
  27. package/dist/esm/youtube/Transcript/proto/TranscriptParamsProto.js +2 -2
  28. package/dist/esm/youtube/VideoCompact/VideoCompactParser.js +2 -2
  29. package/dist/typings/youtube/BaseChannel/BaseChannel.d.ts +6 -0
  30. package/dist/typings/youtube/BaseChannel/BaseChannelParser.d.ts +7 -3
  31. package/dist/typings/youtube/BaseChannel/ChannelLive.d.ts +30 -0
  32. package/dist/typings/youtube/BaseChannel/ChannelShorts.d.ts +30 -0
  33. package/dist/typings/youtube/BaseChannel/index.d.ts +2 -0
  34. package/dist/typings/youtube/SearchResult/proto/index.d.ts +2 -41
  35. package/dist/typings/youtube/Transcript/proto/TranscriptParamsProto.d.ts +2 -11
  36. package/package.json +2 -2
@@ -28,6 +28,8 @@ class MusicSearchResultParser {
28
28
  if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchEndpoint) {
29
29
  const pageType = playEndpoint.watchEndpoint.watchEndpointMusicSupportedConfigs
30
30
  .watchEndpointMusicConfig.musicVideoType;
31
+ if (pageType === "MUSIC_VIDEO_TYPE_PODCAST_EPISODE")
32
+ return;
31
33
  return MusicSearchResultParser.parseVideoItem(item, pageType, client);
32
34
  }
33
35
  else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint.params) {
@@ -69,7 +71,7 @@ class MusicSearchResultParser {
69
71
  duration,
70
72
  });
71
73
  }
72
- else {
74
+ else if (pageType === "MUSIC_VIDEO_TYPE_UGC") {
73
75
  return new MusicVideoCompact_1.MusicVideoCompact({ client, id, title, artists, thumbnails, duration });
74
76
  }
75
77
  }
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseChannel = void 0;
4
4
  const Base_1 = require("../Base");
5
5
  const BaseChannelParser_1 = require("./BaseChannelParser");
6
+ const ChannelLive_1 = require("./ChannelLive");
6
7
  const ChannelPlaylists_1 = require("./ChannelPlaylists");
8
+ const ChannelShorts_1 = require("./ChannelShorts");
7
9
  const ChannelVideos_1 = require("./ChannelVideos");
8
10
  /** Represents a Youtube Channel */
9
11
  class BaseChannel extends Base_1.Base {
@@ -12,6 +14,8 @@ class BaseChannel extends Base_1.Base {
12
14
  super(attr.client);
13
15
  Object.assign(this, attr);
14
16
  this.videos = new ChannelVideos_1.ChannelVideos({ channel: this, client: this.client });
17
+ this.shorts = new ChannelShorts_1.ChannelShorts({ channel: this, client: this.client });
18
+ this.live = new ChannelLive_1.ChannelLive({ channel: this, client: this.client });
15
19
  this.playlists = new ChannelPlaylists_1.ChannelPlaylists({ channel: this, client: this.client });
16
20
  }
17
21
  /** The URL of the channel page */
@@ -15,18 +15,20 @@ class BaseChannelParser {
15
15
  }
16
16
  /** Parse tab data from request, tab name is ignored if it's a continuation data */
17
17
  static parseTabData(name, data) {
18
- var _a, _b, _c, _d;
18
+ var _a, _b, _c, _d, _e;
19
19
  const tab = (_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs.find((t) => {
20
20
  var _a;
21
21
  return (((_a = t.tabRenderer) === null || _a === void 0 ? void 0 : _a.endpoint.browseEndpoint.params) ===
22
22
  BaseChannelParser.TAB_TYPE_PARAMS[name]);
23
23
  });
24
- return (((_c = (_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer.contents) === null || _b === void 0 ? void 0 : _b[0].itemSectionRenderer.contents[0].gridRenderer) === null || _c === void 0 ? void 0 : _c.items) || (tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.richGridRenderer.contents.map((c) => { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((_d = data.onResponseReceivedActions) === null || _d === void 0 ? void 0 : _d[0].appendContinuationItemsAction.continuationItems.map((c) => { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) ||
24
+ return (((_d = (_c = (_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer) === null || _b === void 0 ? void 0 : _b.contents) === null || _c === void 0 ? void 0 : _c[0].itemSectionRenderer.contents[0].gridRenderer) === null || _d === void 0 ? void 0 : _d.items) || (tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.richGridRenderer.contents.map((c) => { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((_e = data.onResponseReceivedActions) === null || _e === void 0 ? void 0 : _e[0].appendContinuationItemsAction.continuationItems.map((c) => { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) ||
25
25
  []);
26
26
  }
27
27
  }
28
28
  exports.BaseChannelParser = BaseChannelParser;
29
29
  BaseChannelParser.TAB_TYPE_PARAMS = {
30
- videos: "EgZ2aWRlb3M%3D",
31
- playlists: "EglwbGF5bGlzdHM%3D",
30
+ videos: "EgZ2aWRlb3PyBgQKAjoA",
31
+ shorts: "EgZzaG9ydHPyBgUKA5oBAA%3D%3D",
32
+ live: "EgdzdHJlYW1z8gYECgJ6AA%3D%3D",
33
+ playlists: "EglwbGF5bGlzdHPyBgQKAkIA",
32
34
  };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ChannelLive = void 0;
13
+ const common_1 = require("../../common");
14
+ const Continuable_1 = require("../Continuable");
15
+ const VideoCompact_1 = require("../VideoCompact");
16
+ const constants_1 = require("../constants");
17
+ const BaseChannelParser_1 = require("./BaseChannelParser");
18
+ /**
19
+ * {@link Continuable} of videos inside a {@link BaseChannel}
20
+ *
21
+ * @example
22
+ * ```js
23
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
24
+ * await channel.live.next();
25
+ * console.log(channel.live.items) // first 30 live videos
26
+ *
27
+ * let newLives = await channel.videos.next();
28
+ * console.log(newLives) // 30 loaded live videos
29
+ * console.log(channel.live.items) // first 60 live videos
30
+ *
31
+ * await channel.live.next(0); // load the rest of the live videos in the channel
32
+ * ```
33
+ */
34
+ class ChannelLive extends Continuable_1.Continuable {
35
+ /** @hidden */
36
+ constructor({ client, channel }) {
37
+ super({ client, strictContinuationCheck: true });
38
+ this.channel = channel;
39
+ }
40
+ fetch() {
41
+ var _a;
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const params = BaseChannelParser_1.BaseChannelParser.TAB_TYPE_PARAMS.live;
44
+ const response = yield this.client.http.post(`${constants_1.I_END_POINT}/browse`, {
45
+ data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params, continuation: this.continuation },
46
+ });
47
+ const items = BaseChannelParser_1.BaseChannelParser.parseTabData("live", response.data);
48
+ const continuation = common_1.getContinuationFromItems(items);
49
+ const data = common_1.mapFilter(items, "videoRenderer");
50
+ return {
51
+ continuation,
52
+ items: data.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i)),
53
+ };
54
+ });
55
+ }
56
+ }
57
+ exports.ChannelLive = ChannelLive;
@@ -40,7 +40,7 @@ class ChannelPlaylists extends Continuable_1.Continuable {
40
40
  fetch() {
41
41
  var _a;
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- const params = "EglwbGF5bGlzdHMgAQ%3D%3D";
43
+ const params = BaseChannelParser_1.BaseChannelParser.TAB_TYPE_PARAMS.playlists;
44
44
  const response = yield this.client.http.post(`${constants_1.I_END_POINT}/browse`, {
45
45
  data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params, continuation: this.continuation },
46
46
  });
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ChannelShorts = void 0;
13
+ const common_1 = require("../../common");
14
+ const Continuable_1 = require("../Continuable");
15
+ const VideoCompact_1 = require("../VideoCompact");
16
+ const constants_1 = require("../constants");
17
+ const BaseChannelParser_1 = require("./BaseChannelParser");
18
+ /**
19
+ * {@link Continuable} of shorts inside a {@link BaseChannel}
20
+ *
21
+ * @example
22
+ * ```js
23
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
24
+ * await channel.short.next();
25
+ * console.log(channel.short.items) // first 30 shorts
26
+ *
27
+ * let newShorts = await channel.short.next();
28
+ * console.log(newShorts) // 30 loaded shorts
29
+ * console.log(channel.short.items) // first 60 shorts
30
+ *
31
+ * await channel.short.next(0); // load the rest of the shorts in the channel
32
+ * ```
33
+ */
34
+ class ChannelShorts extends Continuable_1.Continuable {
35
+ /** @hidden */
36
+ constructor({ client, channel }) {
37
+ super({ client, strictContinuationCheck: true });
38
+ this.channel = channel;
39
+ }
40
+ fetch() {
41
+ var _a;
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const params = BaseChannelParser_1.BaseChannelParser.TAB_TYPE_PARAMS.shorts;
44
+ const response = yield this.client.http.post(`${constants_1.I_END_POINT}/browse`, {
45
+ data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params, continuation: this.continuation },
46
+ });
47
+ const items = BaseChannelParser_1.BaseChannelParser.parseTabData("shorts", response.data);
48
+ const continuation = common_1.getContinuationFromItems(items);
49
+ const data = common_1.mapFilter(items, "reelItemRenderer");
50
+ return {
51
+ continuation,
52
+ items: data.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i)),
53
+ };
54
+ });
55
+ }
56
+ }
57
+ exports.ChannelShorts = ChannelShorts;
@@ -40,7 +40,7 @@ class ChannelVideos extends Continuable_1.Continuable {
40
40
  fetch() {
41
41
  var _a;
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- const params = "EgZ2aWRlb3M%3D";
43
+ const params = BaseChannelParser_1.BaseChannelParser.TAB_TYPE_PARAMS.videos;
44
44
  const response = yield this.client.http.post(`${constants_1.I_END_POINT}/browse`, {
45
45
  data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params, continuation: this.continuation },
46
46
  });
@@ -12,5 +12,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./BaseChannel"), exports);
14
14
  __exportStar(require("./BaseChannelParser"), exports);
15
+ __exportStar(require("./ChannelLive"), exports);
15
16
  __exportStar(require("./ChannelPlaylists"), exports);
17
+ __exportStar(require("./ChannelShorts"), exports);
16
18
  __exportStar(require("./ChannelVideos"), exports);
@@ -7,7 +7,7 @@ const PlaylistCompact_1 = require("../PlaylistCompact");
7
7
  const VideoCompact_1 = require("../VideoCompact");
8
8
  class BaseVideoParser {
9
9
  static loadBaseVideo(target, data) {
10
- var _a, _b, _c;
10
+ var _a, _b;
11
11
  const videoInfo = BaseVideoParser.parseRawData(data);
12
12
  // Basic information
13
13
  target.id = videoInfo.videoDetails.videoId;
@@ -31,8 +31,7 @@ class BaseVideoParser {
31
31
  // Tags and description
32
32
  target.tags =
33
33
  ((_b = (_a = videoInfo.superTitleLink) === null || _a === void 0 ? void 0 : _a.runs) === null || _b === void 0 ? void 0 : _b.map((r) => r.text.trim()).filter((t) => t)) || [];
34
- target.description =
35
- ((_c = videoInfo.description) === null || _c === void 0 ? void 0 : _c.runs.map((d) => d.text).join("")) || "";
34
+ target.description = videoInfo.videoDetails.shortDescription || "";
36
35
  // related videos
37
36
  const secondaryContents = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
38
37
  .results;
@@ -100,7 +100,7 @@ class Client {
100
100
  }
101
101
  getVideoTranscript(videoId) {
102
102
  return __awaiter(this, void 0, void 0, function* () {
103
- const bufferParams = Transcript_1.TranscriptParamsProto.TranscriptParams.encode({ videoId });
103
+ const bufferParams = Transcript_1.TranscriptParamsProto.encode({ videoId }).finish();
104
104
  const response = yield this.http.post(`${constants_1.I_END_POINT}/get_transcript`, {
105
105
  data: { params: Buffer.from(bufferParams).toString("base64") },
106
106
  });
@@ -101,7 +101,7 @@ class SearchResult extends Continuable_1.Continuable {
101
101
  return __awaiter(this, void 0, void 0, function* () {
102
102
  this.items = [];
103
103
  this.estimatedResults = 0;
104
- const bufferParams = proto_1.SearchProto.SearchOptions.encode(proto_1.optionsToProto(options));
104
+ const bufferParams = proto_1.SearchProto.encode(proto_1.optionsToProto(options)).finish();
105
105
  const response = yield this.client.http.post(`${constants_1.I_END_POINT}/search`, {
106
106
  data: {
107
107
  query,
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.optionsToProto = exports.SearchProto = void 0;
7
- const protocol_buffers_1 = __importDefault(require("protocol-buffers"));
7
+ const protobufjs_1 = __importDefault(require("protobufjs"));
8
8
  // TODO move this to .proto file
9
- exports.SearchProto = protocol_buffers_1.default(`
9
+ exports.SearchProto = protobufjs_1.default.parse(`
10
10
  message SearchOptions {
11
11
  message Options {
12
12
  optional int32 uploadDate = 1;
@@ -16,8 +16,8 @@ exports.SearchProto = protocol_buffers_1.default(`
16
16
  optional int32 subtitles = 5;
17
17
  optional int32 creativeCommons = 6;
18
18
  optional int32 live = 8;
19
- optional int32 4k = 14;
20
- optional int32 360 = 15;
19
+ optional int32 _4k = 14;
20
+ optional int32 _360 = 15;
21
21
  optional int32 location = 23;
22
22
  optional int32 hdr = 25;
23
23
  optional int32 vr180 = 26;
@@ -26,7 +26,7 @@ exports.SearchProto = protocol_buffers_1.default(`
26
26
  optional int32 sortBy = 1;
27
27
  optional Options options = 2;
28
28
  }
29
- `);
29
+ `).root.lookupType("SearchOptions");
30
30
  const searchUploadDateProto = {
31
31
  all: 0,
32
32
  hour: 1,
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TranscriptParamsProto = void 0;
7
- const protocol_buffers_1 = __importDefault(require("protocol-buffers"));
8
- exports.TranscriptParamsProto = protocol_buffers_1.default(`
7
+ const protobufjs_1 = __importDefault(require("protobufjs"));
8
+ exports.TranscriptParamsProto = protobufjs_1.default.parse(`
9
9
  message TranscriptParams {
10
10
  optional string videoId = 1;
11
11
  }
12
- `);
12
+ `).root.lookupType("TranscriptParams");
@@ -6,9 +6,9 @@ const BaseChannel_1 = require("../BaseChannel");
6
6
  class VideoCompactParser {
7
7
  static loadVideoCompact(target, data) {
8
8
  var _a, _b, _c;
9
- const { videoId, title, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, channelThumbnailSupportedRenderers, detailedMetadataSnippets, } = data;
9
+ const { videoId, title, headline, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, channelThumbnailSupportedRenderers, detailedMetadataSnippets, } = data;
10
10
  target.id = videoId;
11
- target.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
11
+ target.title = headline ? headline.simpleText : title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
12
12
  target.thumbnails = new common_1.Thumbnails().load(thumbnail.thumbnails);
13
13
  target.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
14
14
  target.description =
@@ -45,6 +45,8 @@ var MusicSearchResultParser = /** @class */ (function () {
45
45
  if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchEndpoint) {
46
46
  var pageType = playEndpoint.watchEndpoint.watchEndpointMusicSupportedConfigs
47
47
  .watchEndpointMusicConfig.musicVideoType;
48
+ if (pageType === "MUSIC_VIDEO_TYPE_PODCAST_EPISODE")
49
+ return;
48
50
  return MusicSearchResultParser.parseVideoItem(item, pageType, client);
49
51
  }
50
52
  else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint.params) {
@@ -86,7 +88,7 @@ var MusicSearchResultParser = /** @class */ (function () {
86
88
  duration: duration,
87
89
  });
88
90
  }
89
- else {
91
+ else if (pageType === "MUSIC_VIDEO_TYPE_UGC") {
90
92
  return new MusicVideoCompact({ client: client, id: id, title: title, artists: artists, thumbnails: thumbnails, duration: duration });
91
93
  }
92
94
  };
@@ -13,7 +13,9 @@ var __extends = (this && this.__extends) || (function () {
13
13
  })();
14
14
  import { Base } from "../Base";
15
15
  import { BaseChannelParser } from "./BaseChannelParser";
16
+ import { ChannelLive } from "./ChannelLive";
16
17
  import { ChannelPlaylists } from "./ChannelPlaylists";
18
+ import { ChannelShorts } from "./ChannelShorts";
17
19
  import { ChannelVideos } from "./ChannelVideos";
18
20
  /** Represents a Youtube Channel */
19
21
  var BaseChannel = /** @class */ (function (_super) {
@@ -23,6 +25,8 @@ var BaseChannel = /** @class */ (function (_super) {
23
25
  var _this = _super.call(this, attr.client) || this;
24
26
  Object.assign(_this, attr);
25
27
  _this.videos = new ChannelVideos({ channel: _this, client: _this.client });
28
+ _this.shorts = new ChannelShorts({ channel: _this, client: _this.client });
29
+ _this.live = new ChannelLive({ channel: _this, client: _this.client });
26
30
  _this.playlists = new ChannelPlaylists({ channel: _this, client: _this.client });
27
31
  return _this;
28
32
  }
@@ -14,18 +14,20 @@ var BaseChannelParser = /** @class */ (function () {
14
14
  };
15
15
  /** Parse tab data from request, tab name is ignored if it's a continuation data */
16
16
  BaseChannelParser.parseTabData = function (name, data) {
17
- var _a, _b, _c, _d;
17
+ var _a, _b, _c, _d, _e;
18
18
  var tab = (_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs.find(function (t) {
19
19
  var _a;
20
20
  return (((_a = t.tabRenderer) === null || _a === void 0 ? void 0 : _a.endpoint.browseEndpoint.params) ===
21
21
  BaseChannelParser.TAB_TYPE_PARAMS[name]);
22
22
  });
23
- return (((_c = (_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer.contents) === null || _b === void 0 ? void 0 : _b[0].itemSectionRenderer.contents[0].gridRenderer) === null || _c === void 0 ? void 0 : _c.items) || (tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.richGridRenderer.contents.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((_d = data.onResponseReceivedActions) === null || _d === void 0 ? void 0 : _d[0].appendContinuationItemsAction.continuationItems.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) ||
23
+ return (((_d = (_c = (_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer) === null || _b === void 0 ? void 0 : _b.contents) === null || _c === void 0 ? void 0 : _c[0].itemSectionRenderer.contents[0].gridRenderer) === null || _d === void 0 ? void 0 : _d.items) || (tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.richGridRenderer.contents.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((_e = data.onResponseReceivedActions) === null || _e === void 0 ? void 0 : _e[0].appendContinuationItemsAction.continuationItems.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) ||
24
24
  []);
25
25
  };
26
26
  BaseChannelParser.TAB_TYPE_PARAMS = {
27
- videos: "EgZ2aWRlb3M%3D",
28
- playlists: "EglwbGF5bGlzdHM%3D",
27
+ videos: "EgZ2aWRlb3PyBgQKAjoA",
28
+ shorts: "EgZzaG9ydHPyBgUKA5oBAA%3D%3D",
29
+ live: "EgdzdHJlYW1z8gYECgJ6AA%3D%3D",
30
+ playlists: "EglwbGF5bGlzdHPyBgQKAkIA",
29
31
  };
30
32
  return BaseChannelParser;
31
33
  }());
@@ -0,0 +1,109 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (_) try {
30
+ 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;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ import { getContinuationFromItems, mapFilter } from "../../common";
51
+ import { Continuable } from "../Continuable";
52
+ import { VideoCompact } from "../VideoCompact";
53
+ import { I_END_POINT } from "../constants";
54
+ import { BaseChannelParser } from "./BaseChannelParser";
55
+ /**
56
+ * {@link Continuable} of videos inside a {@link BaseChannel}
57
+ *
58
+ * @example
59
+ * ```js
60
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
61
+ * await channel.live.next();
62
+ * console.log(channel.live.items) // first 30 live videos
63
+ *
64
+ * let newLives = await channel.videos.next();
65
+ * console.log(newLives) // 30 loaded live videos
66
+ * console.log(channel.live.items) // first 60 live videos
67
+ *
68
+ * await channel.live.next(0); // load the rest of the live videos in the channel
69
+ * ```
70
+ */
71
+ var ChannelLive = /** @class */ (function (_super) {
72
+ __extends(ChannelLive, _super);
73
+ /** @hidden */
74
+ function ChannelLive(_a) {
75
+ var client = _a.client, channel = _a.channel;
76
+ var _this = _super.call(this, { client: client, strictContinuationCheck: true }) || this;
77
+ _this.channel = channel;
78
+ return _this;
79
+ }
80
+ ChannelLive.prototype.fetch = function () {
81
+ var _a;
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var params, response, items, continuation, data;
84
+ var _this = this;
85
+ return __generator(this, function (_b) {
86
+ switch (_b.label) {
87
+ case 0:
88
+ params = BaseChannelParser.TAB_TYPE_PARAMS.live;
89
+ return [4 /*yield*/, this.client.http.post(I_END_POINT + "/browse", {
90
+ data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params: params, continuation: this.continuation },
91
+ })];
92
+ case 1:
93
+ response = _b.sent();
94
+ items = BaseChannelParser.parseTabData("live", response.data);
95
+ continuation = getContinuationFromItems(items);
96
+ data = mapFilter(items, "videoRenderer");
97
+ return [2 /*return*/, {
98
+ continuation: continuation,
99
+ items: data.map(function (i) {
100
+ return new VideoCompact({ client: _this.client, channel: _this.channel }).load(i);
101
+ }),
102
+ }];
103
+ }
104
+ });
105
+ });
106
+ };
107
+ return ChannelLive;
108
+ }(Continuable));
109
+ export { ChannelLive };
@@ -85,7 +85,7 @@ var ChannelPlaylists = /** @class */ (function (_super) {
85
85
  return __generator(this, function (_b) {
86
86
  switch (_b.label) {
87
87
  case 0:
88
- params = "EglwbGF5bGlzdHMgAQ%3D%3D";
88
+ params = BaseChannelParser.TAB_TYPE_PARAMS.playlists;
89
89
  return [4 /*yield*/, this.client.http.post(I_END_POINT + "/browse", {
90
90
  data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params: params, continuation: this.continuation },
91
91
  })];
@@ -0,0 +1,109 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (_) try {
30
+ 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;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ import { getContinuationFromItems, mapFilter } from "../../common";
51
+ import { Continuable } from "../Continuable";
52
+ import { VideoCompact } from "../VideoCompact";
53
+ import { I_END_POINT } from "../constants";
54
+ import { BaseChannelParser } from "./BaseChannelParser";
55
+ /**
56
+ * {@link Continuable} of shorts inside a {@link BaseChannel}
57
+ *
58
+ * @example
59
+ * ```js
60
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
61
+ * await channel.short.next();
62
+ * console.log(channel.short.items) // first 30 shorts
63
+ *
64
+ * let newShorts = await channel.short.next();
65
+ * console.log(newShorts) // 30 loaded shorts
66
+ * console.log(channel.short.items) // first 60 shorts
67
+ *
68
+ * await channel.short.next(0); // load the rest of the shorts in the channel
69
+ * ```
70
+ */
71
+ var ChannelShorts = /** @class */ (function (_super) {
72
+ __extends(ChannelShorts, _super);
73
+ /** @hidden */
74
+ function ChannelShorts(_a) {
75
+ var client = _a.client, channel = _a.channel;
76
+ var _this = _super.call(this, { client: client, strictContinuationCheck: true }) || this;
77
+ _this.channel = channel;
78
+ return _this;
79
+ }
80
+ ChannelShorts.prototype.fetch = function () {
81
+ var _a;
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var params, response, items, continuation, data;
84
+ var _this = this;
85
+ return __generator(this, function (_b) {
86
+ switch (_b.label) {
87
+ case 0:
88
+ params = BaseChannelParser.TAB_TYPE_PARAMS.shorts;
89
+ return [4 /*yield*/, this.client.http.post(I_END_POINT + "/browse", {
90
+ data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params: params, continuation: this.continuation },
91
+ })];
92
+ case 1:
93
+ response = _b.sent();
94
+ items = BaseChannelParser.parseTabData("shorts", response.data);
95
+ continuation = getContinuationFromItems(items);
96
+ data = mapFilter(items, "reelItemRenderer");
97
+ return [2 /*return*/, {
98
+ continuation: continuation,
99
+ items: data.map(function (i) {
100
+ return new VideoCompact({ client: _this.client, channel: _this.channel }).load(i);
101
+ }),
102
+ }];
103
+ }
104
+ });
105
+ });
106
+ };
107
+ return ChannelShorts;
108
+ }(Continuable));
109
+ export { ChannelShorts };
@@ -85,7 +85,7 @@ var ChannelVideos = /** @class */ (function (_super) {
85
85
  return __generator(this, function (_b) {
86
86
  switch (_b.label) {
87
87
  case 0:
88
- params = "EgZ2aWRlb3M%3D";
88
+ params = BaseChannelParser.TAB_TYPE_PARAMS.videos;
89
89
  return [4 /*yield*/, this.client.http.post(I_END_POINT + "/browse", {
90
90
  data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params: params, continuation: this.continuation },
91
91
  })];
@@ -1,4 +1,6 @@
1
1
  export * from "./BaseChannel";
2
2
  export * from "./BaseChannelParser";
3
+ export * from "./ChannelLive";
3
4
  export * from "./ChannelPlaylists";
5
+ export * from "./ChannelShorts";
4
6
  export * from "./ChannelVideos";
@@ -17,7 +17,7 @@ var BaseVideoParser = /** @class */ (function () {
17
17
  function BaseVideoParser() {
18
18
  }
19
19
  BaseVideoParser.loadBaseVideo = function (target, data) {
20
- var _a, _b, _c;
20
+ var _a, _b;
21
21
  var videoInfo = BaseVideoParser.parseRawData(data);
22
22
  // Basic information
23
23
  target.id = videoInfo.videoDetails.videoId;
@@ -27,7 +27,7 @@ var BaseVideoParser = /** @class */ (function () {
27
27
  target.isLiveContent = videoInfo.videoDetails.isLiveContent;
28
28
  target.thumbnails = new Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
29
29
  // Channel
30
- var _d = videoInfo.owner.videoOwnerRenderer, title = _d.title, thumbnail = _d.thumbnail, subscriberCountText = _d.subscriberCountText;
30
+ var _c = videoInfo.owner.videoOwnerRenderer, title = _c.title, thumbnail = _c.thumbnail, subscriberCountText = _c.subscriberCountText;
31
31
  target.channel = new BaseChannel({
32
32
  client: target.client,
33
33
  id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
@@ -41,8 +41,7 @@ var BaseVideoParser = /** @class */ (function () {
41
41
  // Tags and description
42
42
  target.tags =
43
43
  ((_b = (_a = videoInfo.superTitleLink) === null || _a === void 0 ? void 0 : _a.runs) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.text.trim(); }).filter(function (t) { return t; })) || [];
44
- target.description =
45
- ((_c = videoInfo.description) === null || _c === void 0 ? void 0 : _c.runs.map(function (d) { return d.text; }).join("")) || "";
44
+ target.description = videoInfo.videoDetails.shortDescription || "";
46
45
  // related videos
47
46
  var secondaryContents = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
48
47
  .results;
@@ -178,7 +178,7 @@ var Client = /** @class */ (function () {
178
178
  return __generator(this, function (_a) {
179
179
  switch (_a.label) {
180
180
  case 0:
181
- bufferParams = TranscriptParamsProto.TranscriptParams.encode({ videoId: videoId });
181
+ bufferParams = TranscriptParamsProto.encode({ videoId: videoId }).finish();
182
182
  return [4 /*yield*/, this.http.post(I_END_POINT + "/get_transcript", {
183
183
  data: { params: Buffer.from(bufferParams).toString("base64") },
184
184
  })];
@@ -165,7 +165,7 @@ var SearchResult = /** @class */ (function (_super) {
165
165
  case 0:
166
166
  this.items = [];
167
167
  this.estimatedResults = 0;
168
- bufferParams = SearchProto.SearchOptions.encode(optionsToProto(options));
168
+ bufferParams = SearchProto.encode(optionsToProto(options)).finish();
169
169
  return [4 /*yield*/, this.client.http.post(I_END_POINT + "/search", {
170
170
  data: {
171
171
  query: query,
@@ -9,9 +9,9 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import proto from "protocol-buffers";
12
+ import protobuf from "protobufjs";
13
13
  // TODO move this to .proto file
14
- export var SearchProto = proto("\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");
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");
15
15
  var searchUploadDateProto = {
16
16
  all: 0,
17
17
  hour: 1,
@@ -1,2 +1,2 @@
1
- import proto from "protocol-buffers";
2
- export var TranscriptParamsProto = proto("\n\tmessage TranscriptParams {\n\t\toptional string videoId = 1;\n\t}\n");
1
+ import protobuf from "protobufjs";
2
+ export var TranscriptParamsProto = protobuf.parse("\n\tmessage TranscriptParams {\n\t\toptional string videoId = 1;\n\t}\n").root.lookupType("TranscriptParams");
@@ -5,9 +5,9 @@ var VideoCompactParser = /** @class */ (function () {
5
5
  }
6
6
  VideoCompactParser.loadVideoCompact = function (target, data) {
7
7
  var _a, _b, _c;
8
- var videoId = data.videoId, title = data.title, 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;
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
- target.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
10
+ target.title = headline ? headline.simpleText : title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
11
11
  target.thumbnails = new Thumbnails().load(thumbnail.thumbnails);
12
12
  target.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
13
13
  target.description =
@@ -1,6 +1,8 @@
1
1
  import { Thumbnails, YoutubeRawData } from "../../common";
2
2
  import { Base, BaseProperties } from "../Base";
3
+ import { ChannelLive } from "./ChannelLive";
3
4
  import { ChannelPlaylists } from "./ChannelPlaylists";
5
+ import { ChannelShorts } from "./ChannelShorts";
4
6
  import { ChannelVideos } from "./ChannelVideos";
5
7
  /** @hidden */
6
8
  export interface BaseChannelProperties extends BaseProperties {
@@ -27,6 +29,10 @@ export declare class BaseChannel extends Base implements BaseChannelProperties {
27
29
  subscriberCount?: string;
28
30
  /** Continuable of videos */
29
31
  videos: ChannelVideos;
32
+ /** Continuable of shorts */
33
+ shorts: ChannelShorts;
34
+ /** Continuable of live */
35
+ live: ChannelLive;
30
36
  /** Continuable of playlists */
31
37
  playlists: ChannelPlaylists;
32
38
  /** @hidden */
@@ -1,11 +1,15 @@
1
1
  import { YoutubeRawData } from "../../common";
2
2
  import { BaseChannel } from "./BaseChannel";
3
+ declare type TabType = keyof typeof BaseChannelParser.TAB_TYPE_PARAMS;
3
4
  export declare class BaseChannelParser {
4
5
  static TAB_TYPE_PARAMS: {
5
- readonly videos: "EgZ2aWRlb3M%3D";
6
- readonly playlists: "EglwbGF5bGlzdHM%3D";
6
+ readonly videos: "EgZ2aWRlb3PyBgQKAjoA";
7
+ readonly shorts: "EgZzaG9ydHPyBgUKA5oBAA%3D%3D";
8
+ readonly live: "EgdzdHJlYW1z8gYECgJ6AA%3D%3D";
9
+ readonly playlists: "EglwbGF5bGlzdHPyBgQKAkIA";
7
10
  };
8
11
  static loadBaseChannel(target: BaseChannel, data: YoutubeRawData): BaseChannel;
9
12
  /** Parse tab data from request, tab name is ignored if it's a continuation data */
10
- static parseTabData(name: "videos" | "playlists", data: YoutubeRawData): YoutubeRawData;
13
+ static parseTabData(name: TabType, data: YoutubeRawData): YoutubeRawData;
11
14
  }
15
+ export {};
@@ -0,0 +1,30 @@
1
+ import { Continuable, ContinuableConstructorParams, FetchResult } from "../Continuable";
2
+ import { VideoCompact } from "../VideoCompact";
3
+ import { BaseChannel } from "./BaseChannel";
4
+ declare type ConstructorParams = ContinuableConstructorParams & {
5
+ channel?: BaseChannel;
6
+ };
7
+ /**
8
+ * {@link Continuable} of videos inside a {@link BaseChannel}
9
+ *
10
+ * @example
11
+ * ```js
12
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
13
+ * await channel.live.next();
14
+ * console.log(channel.live.items) // first 30 live videos
15
+ *
16
+ * let newLives = await channel.videos.next();
17
+ * console.log(newLives) // 30 loaded live videos
18
+ * console.log(channel.live.items) // first 60 live videos
19
+ *
20
+ * await channel.live.next(0); // load the rest of the live videos in the channel
21
+ * ```
22
+ */
23
+ export declare class ChannelLive extends Continuable<VideoCompact> {
24
+ /** The channel this live videos belongs to */
25
+ channel?: BaseChannel;
26
+ /** @hidden */
27
+ constructor({ client, channel }: ConstructorParams);
28
+ protected fetch(): Promise<FetchResult<VideoCompact>>;
29
+ }
30
+ export {};
@@ -0,0 +1,30 @@
1
+ import { Continuable, ContinuableConstructorParams, FetchResult } from "../Continuable";
2
+ import { VideoCompact } from "../VideoCompact";
3
+ import { BaseChannel } from "./BaseChannel";
4
+ declare type ConstructorParams = ContinuableConstructorParams & {
5
+ channel?: BaseChannel;
6
+ };
7
+ /**
8
+ * {@link Continuable} of shorts inside a {@link BaseChannel}
9
+ *
10
+ * @example
11
+ * ```js
12
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
13
+ * await channel.short.next();
14
+ * console.log(channel.short.items) // first 30 shorts
15
+ *
16
+ * let newShorts = await channel.short.next();
17
+ * console.log(newShorts) // 30 loaded shorts
18
+ * console.log(channel.short.items) // first 60 shorts
19
+ *
20
+ * await channel.short.next(0); // load the rest of the shorts in the channel
21
+ * ```
22
+ */
23
+ export declare class ChannelShorts extends Continuable<VideoCompact> {
24
+ /** The channel this shorts belongs to */
25
+ channel?: BaseChannel;
26
+ /** @hidden */
27
+ constructor({ client, channel }: ConstructorParams);
28
+ protected fetch(): Promise<FetchResult<VideoCompact>>;
29
+ }
30
+ export {};
@@ -1,4 +1,6 @@
1
1
  export * from "./BaseChannel";
2
2
  export * from "./BaseChannelParser";
3
+ export * from "./ChannelLive";
3
4
  export * from "./ChannelPlaylists";
5
+ export * from "./ChannelShorts";
4
6
  export * from "./ChannelVideos";
@@ -1,44 +1,5 @@
1
- /// <reference types="node" />
1
+ import protobuf from "protobufjs";
2
2
  import { SearchOptions } from "../SearchResult";
3
3
  import { SearchProto as ProtoType } from "./SearchProto";
4
- export declare const SearchProto: {
5
- SearchOptions: {
6
- encode: (obj: {
7
- sortBy?: number | undefined;
8
- options?: {
9
- uploadDate?: number | undefined;
10
- type?: number | undefined;
11
- duration?: number | undefined;
12
- live?: number | undefined;
13
- "4k"?: number | undefined;
14
- hd?: number | undefined;
15
- subtitles?: number | undefined;
16
- creativeCommons?: number | undefined;
17
- "360"?: number | undefined;
18
- vr180?: number | undefined;
19
- "3d"?: number | undefined;
20
- hdr?: number | undefined;
21
- location?: number | undefined;
22
- } | undefined;
23
- }) => Buffer;
24
- decode: (buf: Buffer) => {
25
- sortBy?: number | undefined;
26
- options?: {
27
- uploadDate?: number | undefined;
28
- type?: number | undefined;
29
- duration?: number | undefined;
30
- live?: number | undefined;
31
- "4k"?: number | undefined;
32
- hd?: number | undefined;
33
- subtitles?: number | undefined;
34
- creativeCommons?: number | undefined;
35
- "360"?: number | undefined;
36
- vr180?: number | undefined;
37
- "3d"?: number | undefined;
38
- hdr?: number | undefined;
39
- location?: number | undefined;
40
- } | undefined;
41
- };
42
- };
43
- };
4
+ export declare const SearchProto: protobuf.Type;
44
5
  export declare const optionsToProto: (options: SearchOptions) => ProtoType["SearchOptions"];
@@ -1,16 +1,7 @@
1
- /// <reference types="node" />
1
+ import protobuf from "protobufjs";
2
2
  export declare type TranscriptParams = {
3
3
  TranscriptParams: {
4
4
  videoId: string;
5
5
  };
6
6
  };
7
- export declare const TranscriptParamsProto: {
8
- TranscriptParams: {
9
- encode: (obj: {
10
- videoId: string;
11
- }) => Buffer;
12
- decode: (buf: Buffer) => {
13
- videoId: string;
14
- };
15
- };
16
- };
7
+ export declare const TranscriptParamsProto: protobuf.Type;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
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",
@@ -63,6 +63,6 @@
63
63
  "homepage": "https://suspiciouslookingowl.github.io/youtubei",
64
64
  "dependencies": {
65
65
  "node-fetch": "2.6.7",
66
- "protocol-buffers": "5.0.0"
66
+ "protobufjs": "7.2.4"
67
67
  }
68
68
  }