youtubei 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 newVideos = await channel.videos.next();
28
+ * console.log(newVideos) // 30 loaded videos
29
+ * console.log(channel.live.items) // first 60 live videos
30
+ *
31
+ * await channel.live.next(0); // load the rest of the 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 videos inside a {@link BaseChannel}
20
+ *
21
+ * @example
22
+ * ```js
23
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
24
+ * await channel.videos.next();
25
+ * console.log(channel.videos.items) // first 30 videos
26
+ *
27
+ * let newVideos = await channel.videos.next();
28
+ * console.log(newVideos) // 30 loaded videos
29
+ * console.log(channel.videos.items) // first 60 videos
30
+ *
31
+ * await channel.videos.next(0); // load the rest of the videos 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
  });
@@ -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.shortDescription || "";
36
35
  // related videos
37
36
  const secondaryContents = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
38
37
  .results;
@@ -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 newVideos = await channel.videos.next();
65
+ * console.log(newVideos) // 30 loaded videos
66
+ * console.log(channel.live.items) // first 60 live videos
67
+ *
68
+ * await channel.live.next(0); // load the rest of the 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 videos inside a {@link BaseChannel}
57
+ *
58
+ * @example
59
+ * ```js
60
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
61
+ * await channel.videos.next();
62
+ * console.log(channel.videos.items) // first 30 videos
63
+ *
64
+ * let newVideos = await channel.videos.next();
65
+ * console.log(newVideos) // 30 loaded videos
66
+ * console.log(channel.videos.items) // first 60 videos
67
+ *
68
+ * await channel.videos.next(0); // load the rest of the videos 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
  })];
@@ -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.shortDescription || "";
46
45
  // related videos
47
46
  var secondaryContents = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
48
47
  .results;
@@ -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 newVideos = await channel.videos.next();
17
+ * console.log(newVideos) // 30 loaded videos
18
+ * console.log(channel.live.items) // first 60 live videos
19
+ *
20
+ * await channel.live.next(0); // load the rest of the videos in the channel
21
+ * ```
22
+ */
23
+ export declare class ChannelLive extends Continuable<VideoCompact> {
24
+ /** The channel this 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 videos inside a {@link BaseChannel}
9
+ *
10
+ * @example
11
+ * ```js
12
+ * const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
13
+ * await channel.videos.next();
14
+ * console.log(channel.videos.items) // first 30 videos
15
+ *
16
+ * let newVideos = await channel.videos.next();
17
+ * console.log(newVideos) // 30 loaded videos
18
+ * console.log(channel.videos.items) // first 60 videos
19
+ *
20
+ * await channel.videos.next(0); // load the rest of the videos in the channel
21
+ * ```
22
+ */
23
+ export declare class ChannelShorts extends Continuable<VideoCompact> {
24
+ /** The channel this videos belongs to */
25
+ channel?: BaseChannel;
26
+ /** @hidden */
27
+ constructor({ client, channel }: ConstructorParams);
28
+ protected fetch(): Promise<FetchResult<VideoCompact>>;
29
+ }
30
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
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",