mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-14 10:02:16 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e82c843928 | ||
|
|
be71d7c937 | ||
|
|
470d8d9406 | ||
|
|
2c5907f80f |
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## [4.1.1](https://github.com/LuanRT/YouTube.js/compare/v4.1.0...v4.1.1) (2023-03-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **PlayerCaptionsTracklist:** parse props only if they exist in the node ([470d8d9](https://github.com/LuanRT/YouTube.js/commit/470d8d94063f0159cd005c9eb15fd1a4a175bea0)), closes [#372](https://github.com/LuanRT/YouTube.js/issues/372)
|
||||
* **Search:** Return search results even if there are ads ([#373](https://github.com/LuanRT/YouTube.js/issues/373)) ([2c5907f](https://github.com/LuanRT/YouTube.js/commit/2c5907f80fd76452afe87d1722fe35a4f45a22e0))
|
||||
|
||||
## [4.1.0](https://github.com/LuanRT/YouTube.js/compare/v4.0.1...v4.1.0) (2023-03-24)
|
||||
|
||||
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "youtubei.js",
|
||||
"version": "4.1.0",
|
||||
"version": "4.1.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "youtubei.js",
|
||||
"version": "4.1.0",
|
||||
"version": "4.1.1",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/LuanRT"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "youtubei.js",
|
||||
"version": "4.1.0",
|
||||
"version": "4.1.1",
|
||||
"description": "A wrapper around YouTube's private API. Supports YouTube, YouTube Music, YouTube Kids and YouTube Studio (WIP).",
|
||||
"type": "module",
|
||||
"types": "./dist/src/platform/lib.d.ts",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import Text from './misc/Text.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { RawNode } from '../index.js';
|
||||
|
||||
class PlayerCaptionsTracklist extends YTNode {
|
||||
static type = 'PlayerCaptionsTracklist';
|
||||
|
||||
caption_tracks: {
|
||||
caption_tracks?: {
|
||||
base_url: string;
|
||||
name: Text;
|
||||
vss_id: string;
|
||||
@@ -13,7 +14,7 @@ class PlayerCaptionsTracklist extends YTNode {
|
||||
is_translatable: boolean;
|
||||
}[];
|
||||
|
||||
audio_tracks: {
|
||||
audio_tracks?: {
|
||||
audio_track_id: string;
|
||||
captions_initial_state: string;
|
||||
default_caption_track_index: number;
|
||||
@@ -22,39 +23,48 @@ class PlayerCaptionsTracklist extends YTNode {
|
||||
caption_track_indices: number;
|
||||
}[];
|
||||
|
||||
default_audio_track_index: number;
|
||||
default_audio_track_index?: number;
|
||||
|
||||
translation_languages: {
|
||||
translation_languages?: {
|
||||
language_code: string;
|
||||
language_name: Text;
|
||||
}[];
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.caption_tracks = data.captionTracks.map((ct: any) => ({
|
||||
base_url: ct.baseUrl,
|
||||
name: new Text(ct.name),
|
||||
vss_id: ct.vssId,
|
||||
language_code: ct.languageCode,
|
||||
kind: ct.kind,
|
||||
is_translatable: ct.isTranslatable
|
||||
}));
|
||||
|
||||
this.audio_tracks = data.audioTracks.map((at: any) => ({
|
||||
audio_track_id: at.audioTrackId,
|
||||
captions_initial_state: at.captionsInitialState,
|
||||
default_caption_track_index: at.defaultCaptionTrackIndex,
|
||||
has_default_track: at.hasDefaultTrack,
|
||||
visibility: at.visibility,
|
||||
caption_track_indices: at.captionTrackIndices
|
||||
}));
|
||||
if (Reflect.has(data, 'captionTracks')) {
|
||||
this.caption_tracks = data.captionTracks.map((ct: any) => ({
|
||||
base_url: ct.baseUrl,
|
||||
name: new Text(ct.name),
|
||||
vss_id: ct.vssId,
|
||||
language_code: ct.languageCode,
|
||||
kind: ct.kind,
|
||||
is_translatable: ct.isTranslatable
|
||||
}));
|
||||
}
|
||||
|
||||
this.default_audio_track_index = data.defaultAudioTrackIndex;
|
||||
if (Reflect.has(data, 'audioTracks')) {
|
||||
this.audio_tracks = data.audioTracks.map((at: any) => ({
|
||||
audio_track_id: at.audioTrackId,
|
||||
captions_initial_state: at.captionsInitialState,
|
||||
default_caption_track_index: at.defaultCaptionTrackIndex,
|
||||
has_default_track: at.hasDefaultTrack,
|
||||
visibility: at.visibility,
|
||||
caption_track_indices: at.captionTrackIndices
|
||||
}));
|
||||
}
|
||||
|
||||
this.translation_languages = data.translationLanguages.map((tl: any) => ({
|
||||
language_code: tl.languageCode,
|
||||
language_name: new Text(tl.languageName)
|
||||
}));
|
||||
if (Reflect.has(data, 'defaultAudioTrackIndex')) {
|
||||
this.default_audio_track_index = data.defaultAudioTrackIndex;
|
||||
}
|
||||
|
||||
if (Reflect.has(data, 'translationLanguages')) {
|
||||
this.translation_languages = data.translationLanguages.map((tl: any) => ({
|
||||
language_code: tl.languageCode,
|
||||
language_name: new Text(tl.languageName)
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ class Library extends Feed<IBrowseResponse> {
|
||||
if (!this.page.contents_memo)
|
||||
throw new InnertubeError('Page contents not found');
|
||||
|
||||
const stats = this.page.contents_memo.getType(ProfileColumnStats)?.[0];
|
||||
const user_info = this.page.contents_memo.getType(ProfileColumnUserInfo)?.[0];
|
||||
const stats = this.page.contents_memo.getType(ProfileColumnStats).first();
|
||||
const user_info = this.page.contents_memo.getType(ProfileColumnUserInfo).first();
|
||||
|
||||
this.profile = { stats, user_info };
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class Search extends Feed<ISearchResponse> {
|
||||
if (!contents)
|
||||
throw new InnertubeError('No contents found in search response');
|
||||
|
||||
this.results = contents.firstOfType(ItemSection)?.contents;
|
||||
this.results = contents.filterType(ItemSection).find((section) => section.contents && section.contents.length > 0)?.contents;
|
||||
|
||||
this.refinements = this.page.refinements || [];
|
||||
this.estimated_results = this.page.estimated_results;
|
||||
|
||||
@@ -13,7 +13,7 @@ class TimeWatched {
|
||||
contents?: ObservedArray<ItemSection>;
|
||||
|
||||
constructor(response: ApiResponse) {
|
||||
this.#page = Parser.parseResponse(response.data);
|
||||
this.#page = Parser.parseResponse<IBrowseResponse>(response.data);
|
||||
|
||||
if (!this.#page.contents)
|
||||
throw new InnertubeError('Page contents not found');
|
||||
|
||||
Reference in New Issue
Block a user