Compare commits

..

14 Commits

Author SHA1 Message Date
github-actions[bot]
dbfc569602 chore(main): release 4.2.0 (#377)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-04-09 03:40:01 -03:00
LuanRT
c16a967987 chore(docs): minor improvements 2023-04-09 03:38:09 -03:00
LuanRT
a07375eb20 chore(docs): rewording [skip ci] 2023-04-09 03:02:23 -03:00
LuanRT
ce9d9c56b4 feat(parser): ignore PrimetimePromo node
This node is used to display advertisements.
2023-04-09 02:51:29 -03:00
LuanRT
f50ce1a06b chore: simplify Pull Request template 2023-04-09 02:43:19 -03:00
LuanRT
3b6ccfa3d8 chore: fix cjs build 2023-04-09 02:18:53 -03:00
LuanRT
878488d1b3 chore: clean up README.md 2023-04-09 01:20:27 -03:00
LuanRT
3c94c9da4b deps: bump Jinter to v1.0.0 2023-04-08 23:53:59 -03:00
absidue
0b301de6a1 feat: Enable importHelpers in tsconfig to reduce output size (#378) 2023-04-08 20:19:20 -03:00
absidue
c9135e66d3 feat(PlaylistVideo): Extract video_info and accessibility_label texts (#376) 2023-04-07 20:43:20 -03:00
github-actions[bot]
e82c843928 chore(main): release 4.1.1 (#374)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-03-28 22:29:08 -03:00
LuanRT
be71d7c937 chore: fix some inconsistencies 2023-03-28 21:22:12 -03:00
LuanRT
470d8d9406 fix(PlayerCaptionsTracklist): parse props only if they exist in the node
Fixes #372
2023-03-28 20:50:50 -03:00
absidue
2c5907f80f fix(Search): Return search results even if there are ads (#373) 2023-03-27 15:00:57 -03:00
13 changed files with 172 additions and 128 deletions

View File

@@ -1,27 +1,6 @@
# Pull Request Template
## Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
## Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
## Checklist:
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] I have checked my code and corrected any misspellings
<!-- Thank you for submitting a Pull Request! Please:
* Read our contributing guidelines: https://github.com/LuanRT/YouTube.js/blob/main/CONTRIBUTING.md
* Add "Fixes #<issue_number>" to the PR description if you are fixing an issue.
* Ensure that the code is up-to-date with the `main` branch.
* Include a description of the proposed changes and how to test them.
-->

View File

@@ -1,5 +1,22 @@
# Changelog
## [4.2.0](https://github.com/LuanRT/YouTube.js/compare/v4.1.1...v4.2.0) (2023-04-09)
### Features
* Enable importHelpers in tsconfig to reduce output size ([#378](https://github.com/LuanRT/YouTube.js/issues/378)) ([0b301de](https://github.com/LuanRT/YouTube.js/commit/0b301de6a1e1352a64881c1751a84360922a77cd))
* **parser:** ignore PrimetimePromo node ([ce9d9c5](https://github.com/LuanRT/YouTube.js/commit/ce9d9c56b4f45c0139d74edc95c295ecfd1ee4b1))
* **PlaylistVideo:** Extract video_info and accessibility_label texts ([#376](https://github.com/LuanRT/YouTube.js/issues/376)) ([c9135e6](https://github.com/LuanRT/YouTube.js/commit/c9135e66d3c9c72b8d063eedcf3cc2123800946d))
## [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)

View File

@@ -3,14 +3,12 @@
[versions]: https://www.npmjs.com/package/youtubei.js?activeTab=versions
[codefactor]: https://www.codefactor.io/repository/github/luanrt/youtube.js
[actions]: https://github.com/LuanRT/YouTube.js/actions
[say-thanks]: https://saythanks.io/to/LuanRT
[collaborators]: https://github.com/LuanRT/YouTube.js/blob/main/COLLABORATORS.md
<!-- OTHER LINKS -->
[project]: https://github.com/LuanRT/YouTube.js
[twitter]: https://twitter.com/thesciencephile
[discord]: https://discord.gg/syDu7Yks54
[nodejs]: https://nodejs.org
<h1 align=center>YouTube.js</h1>
@@ -23,33 +21,28 @@
[![Codefactor](https://www.codefactor.io/repository/github/luanrt/youtube.js/badge)][codefactor]
[![Downloads](https://img.shields.io/npm/dt/youtubei.js)][npm]
[![Discord](https://img.shields.io/badge/discord-online-brightgreen.svg)][discord]
[![Say thanks](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)][say-thanks]
<br>
[![Donate](https://img.shields.io/badge/donate-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#white)][collaborators]
</div>
<p align="center">
<a><sub>Special thanks to:<sub></a>
</p>
<table align="center">
<body>
<tr>
<td align="center">
<a href="https://serpapi.com/" target="_blank">
<img width="80" alt="SerpApi" src="https://luanrt.is-a.dev/assets/img/serpapi.svg" />
<br>
<b>
<sub>
Scrape Google and other search engines from a fast, easy and complete API.
</sub>
</b>
</a>
</td>
</tr>
</body>
</table>
<div align="center">
<p>
<sup>Special thanks to:</sup>
<br>
<br>
<a href="https://serpapi.com#gh-light-mode-only" target="_blank">
<img width="80" alt="SerpApi" src="https://luanrt.is-a.dev/assets/img/serpapi.svg" />
<br>
<sub>
API to get search engine results with ease.
</sub>
</a>
</p>
</div>
<br>
<hr>
<br>
## Table of Contents
<ol>
@@ -249,7 +242,7 @@ const yt = await Innertube.create({
* `Innertube`
<details>
<summary>Objects</summary>
<summary>Properties</summary>
<p>
* [.session](https://github.com/LuanRT/YouTube.js/blob/main/docs/API/session.md)
@@ -293,7 +286,7 @@ const yt = await Innertube.create({
</details>
<a name="getinfo"></a>
### getInfo(target, client?)
### `getInfo(target, client?)`
Retrieves video info.
@@ -357,7 +350,7 @@ Retrieves video info.
</details>
<a name="getbasicinfo"></a>
### getBasicInfo(video_id, client?)
### `getBasicInfo(video_id, client?)`
Suitable for cases where you only need basic video metadata. Also, it is faster than [`getInfo()`](#getinfo).
@@ -369,7 +362,7 @@ Suitable for cases where you only need basic video metadata. Also, it is faster
| client? | `InnerTubeClient` | `WEB`, `ANDROID`, `YTMUSIC_ANDROID`, `YTMUSIC`, `TV_EMBEDDED` |
<a name="search"></a>
### search(query, filters?)
### `search(query, filters?)`
Searches the given query on YouTube.
@@ -414,7 +407,7 @@ Searches the given query on YouTube.
</details>
<a name="getsearchsuggestions"></a>
### getSearchSuggestions(query)
### `getSearchSuggestions(query)`
Retrieves search suggestions for given query.
**Returns**: `Promise<string[]>`
@@ -424,7 +417,7 @@ Retrieves search suggestions for given query.
| query | `string` | The search query |
<a name="getcomments"></a>
### getComments(video_id, sort_by?)
### `getComments(video_id, sort_by?)`
Retrieves comments for given video.
**Returns**: `Promise<Comments>`
@@ -437,7 +430,7 @@ Retrieves comments for given video.
See [`./examples/comments`](https://github.com/LuanRT/YouTube.js/blob/main/examples/comments) for examples.
<a name="gethomefeed"></a>
### getHomeFeed()
### `getHomeFeed()`
Retrieves YouTube's home feed.
**Returns**: `Promise<HomeFeed>`
@@ -471,13 +464,13 @@ Retrieves YouTube's home feed.
</details>
<a name="getguide"></a>
### getGuide()
### `getGuide()`
Retrieves YouTube's content guide.
**Returns**: `Promise<Guide>`
<a name="getlibrary"></a>
### getLibrary()
### `getLibrary()`
Retrieves the account's library.
**Returns**: `Promise<Library>`
@@ -499,7 +492,7 @@ Retrieves the account's library.
</details>
<a name="gethistory"></a>
### getHistory()
### `getHistory()`
Retrieves watch history.
**Returns**: `Promise<History>`
@@ -518,19 +511,19 @@ Retrieves watch history.
</details>
<a name="gettrending"></a>
### getTrending()
### `getTrending()`
Retrieves trending content.
**Returns**: `Promise<TabbedFeed<IBrowseResponse>>`
<a name="getsubscriptionsfeed"></a>
### getSubscriptionsFeed()
### `getSubscriptionsFeed()`
Retrieves the subscriptions feed.
**Returns**: `Promise<Feed<IBrowseResponse>>`
<a name="getchannel"></a>
### getChannel(id)
### `getChannel(id)`
Retrieves contents for a given channel.
**Returns**: `Promise<Channel>`
@@ -570,7 +563,7 @@ Retrieves contents for a given channel.
See [`./examples/channel`](https://github.com/LuanRT/YouTube.js/blob/main/examples/channel) for examples.
<a name="getnotifications"></a>
### getNotifications()
### `getNotifications()`
Retrieves notifications.
**Returns**: `Promise<NotificationsMenu>`
@@ -586,13 +579,13 @@ Retrieves notifications.
</details>
<a name="getunseennotificationscount"></a>
### getUnseenNotificationsCount()
### `getUnseenNotificationsCount()`
Retrieves unseen notifications count.
**Returns**: `Promise<number>`
<a name="getplaylist"></a>
### getPlaylist(id)
### `getPlaylist(id)`
Retrieves playlist contents.
**Returns**: `Promise<Playlist>`
@@ -615,7 +608,7 @@ Retrieves playlist contents.
</details>
<a name="gethashtag"></a>
### getHashtag(hashtag)
### `getHashtag(hashtag)`
Retrieves a given hashtag's page.
**Returns**: `Promise<HashtagFeed>`
@@ -640,7 +633,7 @@ Retrieves a given hashtag's page.
</details>
<a name="getstreamingdata"></a>
### getStreamingData(video_id, options)
### `getStreamingData(video_id, options)`
Returns deciphered streaming data.
> **Note**
@@ -666,7 +659,7 @@ console.info('Playback url:', url);
| options | `FormatOptions` | Format options |
<a name="download"></a>
### download(video_id, options?)
### `download(video_id, options?)`
Downloads a given video.
**Returns**: `Promise<ReadableStream<Uint8Array>>`
@@ -679,7 +672,7 @@ Downloads a given video.
See [`./examples/download`](https://github.com/LuanRT/YouTube.js/blob/main/examples/download) for examples.
<a name="resolveurl"></a>
### resolveURL(url)
### `resolveURL(url)`
Resolves a given url.
**Returns**: `Promise<NavigationEndpoint>`
@@ -689,7 +682,7 @@ Resolves a given url.
| url | `string` | Url to resolve |
<a name="call"></a>
### call(endpoint, args?)
### `call(endpoint, args?)`
Utility to call navigation endpoints.
**Returns**: `Promise<T extends IParsedResponse | IParsedResponse | ApiResponse>`

75
package-lock.json generated
View File

@@ -1,19 +1,20 @@
{
"name": "youtubei.js",
"version": "4.1.0",
"version": "4.2.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "youtubei.js",
"version": "4.1.0",
"version": "4.2.0",
"funding": [
"https://github.com/sponsors/LuanRT"
],
"license": "MIT",
"dependencies": {
"jintr": "^0.4.1",
"jintr": "^1.0.0",
"linkedom": "^0.14.12",
"tslib": "^2.5.0",
"undici": "^5.19.1"
},
"devDependencies": {
@@ -1574,6 +1575,12 @@
"node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
}
},
"node_modules/@yarnpkg/fslib/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"node_modules/@yarnpkg/libzip": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/@yarnpkg/libzip/-/libzip-2.2.4.tgz",
@@ -1587,6 +1594,12 @@
"node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
}
},
"node_modules/@yarnpkg/libzip/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"node_modules/acorn": {
"version": "8.8.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
@@ -4394,9 +4407,9 @@
}
},
"node_modules/jintr": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/jintr/-/jintr-0.4.1.tgz",
"integrity": "sha512-R42VuIoTjsGbZuEmtT7WqyErd9JQuuV17Cg05wQwRWkQbmQNm2zO519Af1Ib7P7SBATqSMbhyu2/VcTnb3TcOg==",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/jintr/-/jintr-1.0.0.tgz",
"integrity": "sha512-Kbyb5jiIzmTrbhbdjQGt+jjVzn9BPluvL3mZU5ihFQIEGjCHUA4+rsXE2PNDKmg1UlfdTn3947aSwWOVnc5UIw==",
"funding": [
"https://github.com/sponsors/LuanRT"
],
@@ -6193,10 +6206,9 @@
}
},
"node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
},
"node_modules/tsutils": {
"version": "3.21.0",
@@ -6213,6 +6225,12 @@
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
}
},
"node_modules/tsutils/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@@ -7641,6 +7659,14 @@
"requires": {
"@yarnpkg/libzip": "^2.2.4",
"tslib": "^1.13.0"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
}
}
},
"@yarnpkg/libzip": {
@@ -7651,6 +7677,14 @@
"requires": {
"@types/emscripten": "^1.38.0",
"tslib": "^1.13.0"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
}
}
},
"acorn": {
@@ -9619,9 +9653,9 @@
}
},
"jintr": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/jintr/-/jintr-0.4.1.tgz",
"integrity": "sha512-R42VuIoTjsGbZuEmtT7WqyErd9JQuuV17Cg05wQwRWkQbmQNm2zO519Af1Ib7P7SBATqSMbhyu2/VcTnb3TcOg==",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/jintr/-/jintr-1.0.0.tgz",
"integrity": "sha512-Kbyb5jiIzmTrbhbdjQGt+jjVzn9BPluvL3mZU5ihFQIEGjCHUA4+rsXE2PNDKmg1UlfdTn3947aSwWOVnc5UIw==",
"requires": {
"acorn": "^8.8.0"
}
@@ -10930,10 +10964,9 @@
}
},
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
},
"tsutils": {
"version": "3.21.0",
@@ -10942,6 +10975,14 @@
"dev": true,
"requires": {
"tslib": "^1.8.1"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
}
}
},
"type-check": {

View File

@@ -1,6 +1,6 @@
{
"name": "youtubei.js",
"version": "4.1.0",
"version": "4.2.0",
"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",
@@ -72,7 +72,7 @@
"build:proto": "npx pb-gen-ts --entry-path=\"src/proto\" --out-dir=\"src/proto/generated\" --ext-in-import=\".js\"",
"build:esm": "npx tsc",
"build:deno": "npx cpy ./src ./deno && npx cpy ./package.json ./deno && npx replace \".js';\" \".ts';\" ./deno -r && npx replace '.js\";' '.ts\";' ./deno -r && npx replace \"'linkedom';\" \"'https://esm.sh/linkedom';\" ./deno -r && npx replace \"'jintr';\" \"'https://esm.sh/jintr';\" ./deno -r && npx replace \"new Jinter.default\" \"new Jinter\" ./deno -r",
"bundle:node": "npx esbuild ./dist/src/platform/node.js --bundle --target=node10 --keep-names --format=cjs --platform=node --outfile=./bundle/node.cjs --external:jintr --external:undici --external:linkedom --sourcemap --banner:js=\"/* eslint-disable */\"",
"bundle:node": "npx esbuild ./dist/src/platform/node.js --bundle --target=node10 --keep-names --format=cjs --platform=node --outfile=./bundle/node.cjs --external:jintr --external:undici --external:linkedom --external:tslib --sourcemap --banner:js=\"/* eslint-disable */\"",
"bundle:browser": "npx esbuild ./dist/src/platform/web.js --banner:js=\"/* eslint-disable */\" --bundle --target=chrome58 --keep-names --format=esm --sourcemap --define:global=globalThis --outfile=./bundle/browser.js --platform=browser",
"bundle:browser:prod": "npm run bundle:browser -- --outfile=./bundle/browser.min.js --minify",
"prepare": "npm run build",
@@ -84,8 +84,9 @@
},
"license": "MIT",
"dependencies": {
"jintr": "^0.4.1",
"jintr": "^1.0.0",
"linkedom": "^0.14.12",
"tslib": "^2.5.0",
"undici": "^5.19.1"
},
"devDependencies": {

View File

@@ -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)
}));
}
}
}

View File

@@ -22,6 +22,8 @@ class PlaylistVideo extends YTNode {
is_playable: boolean;
menu: Menu | null;
upcoming;
video_info: Text;
accessibility_label?: string;
duration: {
text: string;
@@ -40,6 +42,8 @@ class PlaylistVideo extends YTNode {
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
this.is_playable = data.isPlayable;
this.menu = Parser.parseItem(data.menu, Menu);
this.video_info = new Text(data.videoInfo);
this.accessibility_label = data.title.accessibility.accessibilityData.label;
const upcoming = data.upcomingEventData && Number(`${data.upcomingEventData.startTime}000`);
if (upcoming) {

View File

@@ -497,6 +497,7 @@ export default class Parser {
'DisplayAd',
'SearchPyv',
'MealbarPromo',
'PrimetimePromo',
'BackgroundPromo',
'PromotedSparklesWeb',
'RunAttestationCommand',

View File

@@ -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 };

View File

@@ -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;

View File

@@ -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');

View File

@@ -1,8 +1,8 @@
import Jinter from 'jintr';
import { Jinter } from 'jintr';
import { VMPrimative } from '../../types/PlatformShim.js';
export default function evaluate(code: string, env: Record<string, VMPrimative>) {
const runtime = new Jinter.default(code);
const runtime = new Jinter(code);
for (const [ key, value ] of Object.entries(env)) {
runtime.scope.set(key, value);
}

View File

@@ -52,7 +52,7 @@
"outDir": "./dist", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
"importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
@@ -102,9 +102,7 @@
},
"include": [
"src/**/*.ts",
"src/**/*.js",
"index.ts",
"browser.ts"
"src/**/*.js"
],
"exclude": [
"node_modules",