mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-14 10:02:16 +00:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ecfb08772 | ||
|
|
2029aec90d | ||
|
|
d589365ea2 | ||
|
|
45f33d8c04 | ||
|
|
92117eaaa0 | ||
|
|
39725374e3 | ||
|
|
213d78b1ab | ||
|
|
28f53a698d | ||
|
|
776a156f65 | ||
|
|
4a9bd32fd7 | ||
|
|
3170659880 | ||
|
|
e6f1f078a8 | ||
|
|
900f557202 | ||
|
|
7ca2a0c3e4 | ||
|
|
f95283b236 | ||
|
|
f6a7bcc44a | ||
|
|
c444843799 | ||
|
|
5fe91d6642 | ||
|
|
bff65f8889 | ||
|
|
dac5eb712d | ||
|
|
2068dfb73e | ||
|
|
3e84775fd3 | ||
|
|
89fa3b27a8 | ||
|
|
ab7201f0cc | ||
|
|
b21eb9f33d | ||
|
|
0751793380 | ||
|
|
5c91c2af4a | ||
|
|
47cad4c6e1 | ||
|
|
4fb9dff0f2 | ||
|
|
81dd5d3288 | ||
|
|
c7f42220db | ||
|
|
5204b29e81 | ||
|
|
cbaa838cee | ||
|
|
379e63d2f6 | ||
|
|
e86a0daf45 | ||
|
|
7fbc37f9d1 | ||
|
|
2e710dc9f7 | ||
|
|
fed3512461 | ||
|
|
6dd03e1658 | ||
|
|
2073aa910a | ||
|
|
f7b7bbd47a | ||
|
|
04d55d04c7 | ||
|
|
6082b4a52e | ||
|
|
3980f97b8f | ||
|
|
59f4cfb4db | ||
|
|
254f77944f | ||
|
|
586bb5f139 | ||
|
|
562e6a20f0 | ||
|
|
b7cacc34f3 | ||
|
|
8f07e49512 | ||
|
|
abd8a82cd0 | ||
|
|
7ffd0fc25e |
@@ -14,6 +14,7 @@ overrides:
|
||||
-
|
||||
files:
|
||||
- '**/*.js'
|
||||
- '**/*.mjs'
|
||||
rules:
|
||||
'tsdoc/syntax': 'off'
|
||||
rules:
|
||||
|
||||
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -13,6 +13,6 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
1
.github/workflows/stale.yml
vendored
1
.github/workflows/stale.yml
vendored
@@ -13,5 +13,6 @@ jobs:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
|
||||
stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity. Remove the stale label or comment or this will be closed in 2 days'
|
||||
any-of-issue-labels: 'needs-more-info,cannot-reproduce,question,help-wanted'
|
||||
days-before-stale: 60
|
||||
days-before-close: 4
|
||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -13,6 +13,6 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
- run: npm ci
|
||||
- run: npm run test
|
||||
80
CHANGELOG.md
80
CHANGELOG.md
@@ -1,5 +1,85 @@
|
||||
# Changelog
|
||||
|
||||
## [9.2.0](https://github.com/LuanRT/YouTube.js/compare/v9.1.0...v9.2.0) (2024-03-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add support of cloudflare workers ([#596](https://github.com/LuanRT/YouTube.js/issues/596)) ([2029aec](https://github.com/LuanRT/YouTube.js/commit/2029aec90de3c0fdb022094d7b704a2feed4133b))
|
||||
* **parser:** Support CommentView nodes ([#614](https://github.com/LuanRT/YouTube.js/issues/614)) ([900f557](https://github.com/LuanRT/YouTube.js/commit/900f5572021d348e7012909f2080e52eac06adae))
|
||||
* **parser:** Support LockupView and it's child nodes ([#609](https://github.com/LuanRT/YouTube.js/issues/609)) ([7ca2a0c](https://github.com/LuanRT/YouTube.js/commit/7ca2a0c3e43ebd4b9443e69b7432f302b09e9c7a))
|
||||
* **Text:** Support formatting and emojis in `fromAttributed` ([#615](https://github.com/LuanRT/YouTube.js/issues/615)) ([e6f1f07](https://github.com/LuanRT/YouTube.js/commit/e6f1f078a828f8ea5db1fe7aec9f677bc53694e3))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **Cache:** handle the value read from the db correctly according to its type ([#620](https://github.com/LuanRT/YouTube.js/issues/620)) ([3170659](https://github.com/LuanRT/YouTube.js/commit/317065988007c860bf6173b0ac3c3d685ed81d20))
|
||||
* **PlayerEndpoint:** Workaround for "The following content is not available on this app" (Android) ([#624](https://github.com/LuanRT/YouTube.js/issues/624)) ([d589365](https://github.com/LuanRT/YouTube.js/commit/d589365ea27f540ff36e33a65362c932cd28c274))
|
||||
|
||||
## [9.1.0](https://github.com/LuanRT/YouTube.js/compare/v9.0.2...v9.1.0) (2024-02-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **Format:** Support caption tracks in adaptive formats ([#598](https://github.com/LuanRT/YouTube.js/issues/598)) ([bff65f8](https://github.com/LuanRT/YouTube.js/commit/bff65f8889c32813ec05bd187f3a4386fc6127c0))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **Playlist:** `items` getter failing if a playlist contains Shorts ([89fa3b2](https://github.com/LuanRT/YouTube.js/commit/89fa3b27a839d98aaf8bd70dd75220ee309c2bea))
|
||||
* **Session:** Don't try to extract api version from service worker ([2068dfb](https://github.com/LuanRT/YouTube.js/commit/2068dfb73eefc0e40157421d4e5b4096c0c8429c))
|
||||
|
||||
## [9.0.2](https://github.com/LuanRT/YouTube.js/compare/v9.0.1...v9.0.2) (2024-01-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **VideoInfo:** Fix error because of typo in getWatchNextContinuation ([#590](https://github.com/LuanRT/YouTube.js/issues/590)) ([b21eb9f](https://github.com/LuanRT/YouTube.js/commit/b21eb9f33d956e130bac98712384125ae04ace47))
|
||||
|
||||
## [9.0.1](https://github.com/LuanRT/YouTube.js/compare/v9.0.0...v9.0.1) (2024-01-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **build:** Circular imports causing issues with webpack ([81dd5d3](https://github.com/LuanRT/YouTube.js/commit/81dd5d3288771132e7fb904b620e58277f639ccc))
|
||||
|
||||
## [9.0.0](https://github.com/LuanRT/YouTube.js/compare/v8.2.0...v9.0.0) (2024-01-25)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **toDash:** Add support for generating manifests for Post Live DVR videos ([#580](https://github.com/LuanRT/YouTube.js/issues/580))
|
||||
|
||||
### Features
|
||||
|
||||
* **Channel:** Support getting about with PageHeader ([#581](https://github.com/LuanRT/YouTube.js/issues/581)) ([2e710dc](https://github.com/LuanRT/YouTube.js/commit/2e710dc9f7e206627f189df19be17009b270bc8b))
|
||||
* **Channel:** Support PageHeader being used on user channels ([#577](https://github.com/LuanRT/YouTube.js/issues/577)) ([6082b4a](https://github.com/LuanRT/YouTube.js/commit/6082b4a52ee07a622735e6e9128a0531a5ae3bfb))
|
||||
* **Format:** Add `max_dvr_duration_sec` and `target_duration_dec` ([#570](https://github.com/LuanRT/YouTube.js/issues/570)) ([586bb5f](https://github.com/LuanRT/YouTube.js/commit/586bb5f1398d68bfabfb9449f527e53c398c3767))
|
||||
* **parser:** Add `ImageBannerView` ([#583](https://github.com/LuanRT/YouTube.js/issues/583)) ([2073aa9](https://github.com/LuanRT/YouTube.js/commit/2073aa910a0e441a8ec1a9ba0434051ec0e2e6a9))
|
||||
* **toDash:** Add support for generating manifests for Post Live DVR videos ([#580](https://github.com/LuanRT/YouTube.js/issues/580)) ([6dd03e1](https://github.com/LuanRT/YouTube.js/commit/6dd03e1658036c2fba0696de81033b5e16abb379))
|
||||
* **VideoDetails:** Add `is_live_dvr_enabled`, `is_low_latency_live_stream` and `live_chunk_readahead` ([#569](https://github.com/LuanRT/YouTube.js/issues/569)) ([254f779](https://github.com/LuanRT/YouTube.js/commit/254f77944fcd398cc19cb62b82b0fdfbe6ed70ed))
|
||||
* **VideoInfo:** Add live stream `end_timestamp` ([#571](https://github.com/LuanRT/YouTube.js/issues/571)) ([562e6a2](https://github.com/LuanRT/YouTube.js/commit/562e6a20f06ef5302af427861355215630d91edc))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **DecoratedAvatarView:** Fix parsing and optional properties ([#584](https://github.com/LuanRT/YouTube.js/issues/584)) ([fed3512](https://github.com/LuanRT/YouTube.js/commit/fed3512461277b7fc41e26c770e2bd3d4a7d5eb5))
|
||||
* **PlayerCaptionTracklist:** Fix `captions_tracks[].kind` type ([#586](https://github.com/LuanRT/YouTube.js/issues/586)) ([7fbc37f](https://github.com/LuanRT/YouTube.js/commit/7fbc37f9d1c109e448085d5736326dce82ca2c9a))
|
||||
* **proto:** Fix visitor data base64url decoding ([#576](https://github.com/LuanRT/YouTube.js/issues/576)) ([3980f97](https://github.com/LuanRT/YouTube.js/commit/3980f97b8fca05f95cda1ab347db9402c55b8b3c))
|
||||
* **toDash:** Add missing transfer characteristics for h264 streams ([#573](https://github.com/LuanRT/YouTube.js/issues/573)) ([59f4cfb](https://github.com/LuanRT/YouTube.js/commit/59f4cfb4db6184d47f0a6634832055e9ce71f644))
|
||||
|
||||
## [8.2.0](https://github.com/LuanRT/YouTube.js/compare/v8.1.0...v8.2.0) (2024-01-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **OAuth:** Allow passing custom client identity ([#566](https://github.com/LuanRT/YouTube.js/issues/566)) ([7ffd0fc](https://github.com/LuanRT/YouTube.js/commit/7ffd0fc25edef99a938e7986b1c74af05b8f954e))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **Parser:** Add `SortFilterHeader` ([#563](https://github.com/LuanRT/YouTube.js/issues/563)) ([8f07e49](https://github.com/LuanRT/YouTube.js/commit/8f07e49512c59eb72debc80a9d9623ca62330858))
|
||||
|
||||
## [8.1.0](https://github.com/LuanRT/YouTube.js/compare/v8.0.0...v8.1.0) (2023-12-27)
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
# Authentication via OAuth
|
||||
# OAuth2
|
||||
|
||||
## Usage
|
||||
## Custom OAuth2 Credentials
|
||||
Just like the official Data API, YouTube.js supports using your own OAuth2 credentials. A working example can be found [here](https://github.com/LuanRT/YouTube.js/blob/main/examples/auth/custom-oauth2-creds).
|
||||
|
||||
Before using any methods which require authentication, you have to authenticate the session:
|
||||
## YouTube TV OAuth2
|
||||
|
||||
The library supports signing in using YouTube TV's client id. This is the recommended way to sign in as it doesn't require you to create your own OAuth2 credentials.
|
||||
|
||||
```js
|
||||
// 'auth-pending' is fired with the info needed to sign in via OAuth.
|
||||
@@ -25,9 +28,11 @@ yt.session.on('update-credentials', ({ credentials }) => {
|
||||
await yt.session.signIn(/* credentials */);
|
||||
```
|
||||
|
||||
### Cache Credentials
|
||||
A working example can be found [here](https://github.com/LuanRT/YouTube.js/blob/main/examples/auth/yttv-oauth2.js).
|
||||
|
||||
If you don't wish to sign in every time you start the session, you can cache the credentials. Note that this SHOULD NOT be used in production, save your credentials in a database/file instead and pass them to `Session#signIn(creds?)` when signing in.
|
||||
## Cache Credentials
|
||||
|
||||
If you don't want to start the sign in flow every time you initialize the session, you can cache the credentials. Note that this SHOULD NOT be used in production, save your credentials in a database/file instead and pass them to `Session#signIn(creds?)` when signing in.
|
||||
|
||||
```js
|
||||
// If you use this, the next call to signIn won't fire 'auth-pending' instead just 'auth'
|
||||
@@ -36,9 +41,9 @@ await yt.session.oauth.cacheCredentials();
|
||||
|
||||
**Note:** When using cached credentials, you are still required to make a call to `Session#signIn()`.
|
||||
|
||||
### Sign Out
|
||||
## Sign Out
|
||||
|
||||
The sign out method may be used to sign out of the current session. This should also remove the cached credentials.
|
||||
The sign out method may be used to sign out of the current session. This removes and revokes the credentials.
|
||||
|
||||
```js
|
||||
await yt.session.signOut();
|
||||
@@ -47,3 +52,14 @@ await yt.session.signOut();
|
||||
// and only want to delete the cached credentials, use:
|
||||
await yt.session.oauth.removeCache();
|
||||
```
|
||||
|
||||
# Cookies
|
||||
|
||||
> **Note**
|
||||
> This is not as reliable as OAuth2 as cookies expire and can be completely revoked at any time.
|
||||
|
||||
```js
|
||||
const yt = await Innertube.create({
|
||||
cookie: '...'
|
||||
});
|
||||
```
|
||||
141
examples/auth/custom-oauth2-creds/index.ts
Normal file
141
examples/auth/custom-oauth2-creds/index.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
import express from 'express';
|
||||
import { Innertube, UniversalCache, YTNodes } from 'youtubei.js';
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
|
||||
const app = express();
|
||||
|
||||
let innertube: Innertube | undefined;
|
||||
let oAuth2Client: OAuth2Client | undefined;
|
||||
|
||||
/**
|
||||
* To get your own client id and secret, visit https://console.developers.google.com/, create a new project,
|
||||
* and create an OAuth 2.0 Client ID (Web application) under the Credentials tab.
|
||||
*
|
||||
* Don't forget to add http://localhost:3000/login as an authorized redirect URI.
|
||||
*/
|
||||
const clientId = 'YOUR_OAUTH2_CLIENT_ID';
|
||||
const clientSecret = 'YOUR_OAUTH2_CLIENT_SECRET';
|
||||
const redirectUri = 'http://localhost:3000/login';
|
||||
|
||||
const port = 3000;
|
||||
|
||||
let authorizationUrl: string | undefined;
|
||||
|
||||
app.use(express.static('public'))
|
||||
app.use(express.urlencoded({ extended: true, limit: '3mb' }))
|
||||
|
||||
const cache = new UniversalCache(true);
|
||||
|
||||
console.info("Cache dir:", cache.cache_dir);
|
||||
|
||||
app.get('/', async (_req, res) => {
|
||||
if (!innertube) {
|
||||
console.info('Creating innertube instance.');
|
||||
innertube = await Innertube.create({ cache });
|
||||
|
||||
innertube.session.on("update-credentials", async (_credentials) => {
|
||||
console.info('Credentials updated.');
|
||||
await innertube?.session.oauth.cacheCredentials();
|
||||
});
|
||||
}
|
||||
|
||||
if (await cache.get('youtubei_oauth_credentials')) {
|
||||
await innertube.session.signIn();
|
||||
}
|
||||
|
||||
if (innertube.session.logged_in) {
|
||||
console.info('Innertube instance is logged in.');
|
||||
|
||||
const userInfo = await innertube.account.getInfo();
|
||||
const library = await innertube.getLibrary();
|
||||
|
||||
const html = `
|
||||
<p>Hello ${userInfo.contents?.contents.first().account_name.text}! You have ${userInfo.contents?.contents.first().account_byline.text} on your YouTube channel.</p>
|
||||
<p>Email: ${userInfo.contents?.contents.first().endpoint.payload.directSigninUserProfile.email}</p>
|
||||
<p>Obfuscated Gaia ID: ${userInfo.contents?.contents.first().endpoint.payload.directSigninIdentity.effectiveObfuscatedGaiaId}</p>
|
||||
<p>Channel URL: <a href="https://www.youtube.com/channel/${userInfo.footers?.endpoint.payload.browseId}">https://www.youtube.com/channel/${userInfo.footers?.endpoint.payload.browseId}</a></p>
|
||||
<p>Profile Picture:</p>
|
||||
<img src="${userInfo.contents?.contents.first().account_photo[0].url}" />
|
||||
<p>Recently watched videos:</p>
|
||||
<ul>
|
||||
${library.videos.map((video) => `<li><a href="${video.as(YTNodes.GridVideo).endpoint.toURL()}">${video.title.toString()}</a> by ${video.as(YTNodes.GridVideo).author.name.toString()} - ${video.as(YTNodes.GridVideo).duration?.text}</li>`).join('')}
|
||||
</ul>
|
||||
<button onclick="window.location.href = '/logout'">Logout</button>
|
||||
`;
|
||||
|
||||
return res.send(html);
|
||||
}
|
||||
|
||||
if (!oAuth2Client) {
|
||||
console.info('Creating OAuth2 client.');
|
||||
|
||||
oAuth2Client = new OAuth2Client(
|
||||
clientId,
|
||||
clientSecret,
|
||||
redirectUri
|
||||
);
|
||||
|
||||
authorizationUrl = oAuth2Client.generateAuthUrl({
|
||||
access_type: 'offline',
|
||||
scope: [
|
||||
"http://gdata.youtube.com",
|
||||
"https://www.googleapis.com/auth/youtube-paid-content"
|
||||
],
|
||||
include_granted_scopes: true,
|
||||
prompt: 'consent',
|
||||
});
|
||||
|
||||
console.info('Redirecting to authorization URL...');
|
||||
|
||||
res.redirect(authorizationUrl);
|
||||
} else if (authorizationUrl) {
|
||||
console.info('OAuth2 client already exists. Redirecting to authorization URL...');
|
||||
res.redirect(authorizationUrl);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/login', async (req, res) => {
|
||||
const { code } = req.query;
|
||||
|
||||
if (!code) {
|
||||
return res.send('No code provided.');
|
||||
}
|
||||
|
||||
if (!oAuth2Client || !innertube) {
|
||||
return res.send('OAuth2 client or innertube instance is not initialized.');
|
||||
}
|
||||
|
||||
const { tokens } = await oAuth2Client.getToken(code as string);
|
||||
|
||||
if (tokens.access_token && tokens.refresh_token && tokens.expiry_date) {
|
||||
await innertube.session.signIn({
|
||||
access_token: tokens.access_token,
|
||||
refresh_token: tokens.refresh_token,
|
||||
expires: new Date(tokens.expiry_date),
|
||||
client_id: clientId,
|
||||
client_secret: clientSecret,
|
||||
});
|
||||
|
||||
await innertube.session.oauth.cacheCredentials();
|
||||
|
||||
console.log('Logged in successfully. Redirecting to home page...');
|
||||
|
||||
res.redirect('/');
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/logout', async (_req, res) => {
|
||||
if (!innertube) {
|
||||
return res.send('Innertube instance is not initialized.');
|
||||
}
|
||||
|
||||
await innertube.session.signOut();
|
||||
|
||||
console.log('Logged out successfully. Redirecting to home page...');
|
||||
|
||||
res.redirect('/');
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is running on port ${port}`);
|
||||
});
|
||||
20
examples/auth/custom-oauth2-creds/package.json
Normal file
20
examples/auth/custom-oauth2-creds/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "yt-oauth-example",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"google-auth-library": "^9.4.1",
|
||||
"youtubei.js": "^8.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21"
|
||||
}
|
||||
}
|
||||
109
examples/auth/custom-oauth2-creds/tsconfig.json
Normal file
109
examples/auth/custom-oauth2-creds/tsconfig.json
Normal file
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
||||
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
||||
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
||||
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
||||
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
// "outDir": "./", /* 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. */
|
||||
// "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. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
}
|
||||
}
|
||||
18
examples/cloudflare-worker/package.json
Normal file
18
examples/cloudflare-worker/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "cf-worker",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"deploy": "wrangler deploy",
|
||||
"dev": "wrangler dev",
|
||||
"start": "wrangler dev"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20240208.0",
|
||||
"typescript": "^5.0.4",
|
||||
"wrangler": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"youtubei.js": "latest"
|
||||
}
|
||||
}
|
||||
19
examples/cloudflare-worker/src/index.ts
Normal file
19
examples/cloudflare-worker/src/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Innertube } from "youtubei.js/cf-worker";
|
||||
|
||||
export interface Env {}
|
||||
|
||||
export default {
|
||||
async fetch(
|
||||
request: Request,
|
||||
env: Env,
|
||||
ctx: ExecutionContext
|
||||
): Promise<Response> {
|
||||
// cannot initialize Innertube in global scope as it makes fetch requests
|
||||
const yt = await Innertube.create();
|
||||
|
||||
const video = await yt.getInfo("jNQXAC9IVRw");
|
||||
console.log("Video title is", video.basic_info.title);
|
||||
|
||||
return new Response("Hello World!");
|
||||
},
|
||||
};
|
||||
19
examples/cloudflare-worker/tsconfig.json
Normal file
19
examples/cloudflare-worker/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2021",
|
||||
"lib": ["es2021"],
|
||||
"jsx": "react",
|
||||
"module": "es2022",
|
||||
"moduleResolution": "node",
|
||||
"types": ["@cloudflare/workers-types/2023-07-01"],
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"checkJs": false,
|
||||
"noEmit": true,
|
||||
"isolatedModules": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
3
examples/cloudflare-worker/wrangler.toml
Normal file
3
examples/cloudflare-worker/wrangler.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
name = "cf-worker-youtubei"
|
||||
main = "src/index.ts"
|
||||
compatibility_date = "2024-02-08"
|
||||
@@ -62,4 +62,4 @@ Returns original InnerTube response (sanitized).
|
||||
**Returns:** `ParsedResponse`
|
||||
|
||||
## Example
|
||||
See [`index.ts`]('./index.ts').
|
||||
See [`index.ts`](./index.ts).
|
||||
@@ -109,4 +109,4 @@ Sends a message.
|
||||
**Returns:** `Promise<ObservedArray<AddChatItemAction>>`
|
||||
|
||||
## Example
|
||||
See [`index.ts`]('./index.ts').
|
||||
See [`index.ts`](./index.ts).
|
||||
|
||||
13
package-lock.json
generated
13
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "youtubei.js",
|
||||
"version": "8.1.0",
|
||||
"version": "9.2.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "youtubei.js",
|
||||
"version": "8.1.0",
|
||||
"version": "9.2.0",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/LuanRT"
|
||||
],
|
||||
@@ -5498,8 +5498,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "5.27.0",
|
||||
"license": "MIT",
|
||||
"version": "5.28.3",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.3.tgz",
|
||||
"integrity": "sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==",
|
||||
"dependencies": {
|
||||
"@fastify/busboy": "^2.0.0"
|
||||
},
|
||||
@@ -9138,7 +9139,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"undici": {
|
||||
"version": "5.27.0",
|
||||
"version": "5.28.3",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.3.tgz",
|
||||
"integrity": "sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==",
|
||||
"requires": {
|
||||
"@fastify/busboy": "^2.0.0"
|
||||
}
|
||||
|
||||
12
package.json
12
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "youtubei.js",
|
||||
"version": "8.1.0",
|
||||
"version": "9.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",
|
||||
@@ -17,6 +17,9 @@
|
||||
],
|
||||
"web.bundle.min": [
|
||||
"./dist/src/platform/lib.d.ts"
|
||||
],
|
||||
"cf-worker": [
|
||||
"./dist/src/platform/lib.d.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -46,6 +49,10 @@
|
||||
"./web.bundle.min": {
|
||||
"types": "./dist/src/platform/lib.d.ts",
|
||||
"default": "./bundle/browser.min.js"
|
||||
},
|
||||
"./cf-worker": {
|
||||
"types": "./dist/src/platform/lib.d.ts",
|
||||
"default": "./dist/src/platform/cf-worker.js"
|
||||
}
|
||||
},
|
||||
"author": "LuanRT <luan.lrt4@gmail.com> (https://github.com/LuanRT)",
|
||||
@@ -68,7 +75,7 @@
|
||||
"test": "npx jest --verbose",
|
||||
"lint": "npx eslint ./src",
|
||||
"lint:fix": "npx eslint --fix ./src",
|
||||
"build": "npm run build:parser-map && npm run build:proto && npm run build:esm && npm run bundle:node && npm run bundle:browser && npm run bundle:browser:prod",
|
||||
"build": "npm run build:parser-map && npm run build:proto && npm run build:esm && npm run bundle:node && npm run bundle:browser && npm run bundle:browser:prod && npm run bundle:cf-worker",
|
||||
"build:parser-map": "node ./scripts/gen-parser-map.mjs",
|
||||
"build:proto": "npx pb-gen-ts --entry-path=\"src/proto\" --out-dir=\"src/proto/generated\" --ext-in-import=\".js\"",
|
||||
"build:esm": "npx tspc",
|
||||
@@ -76,6 +83,7 @@
|
||||
"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 --conditions=module --outfile=./bundle/browser.js --platform=browser",
|
||||
"bundle:browser:prod": "npm run bundle:browser -- --outfile=./bundle/browser.min.js --minify",
|
||||
"bundle:cf-worker": "npx esbuild ./dist/src/platform/cf-worker.js --banner:js=\"/* eslint-disable */\" --bundle --target=es2020 --keep-names --format=esm --sourcemap --define:global=globalThis --conditions=module --outfile=./bundle/cf-worker.js --platform=node",
|
||||
"prepare": "npm run build",
|
||||
"watch": "npx tsc --watch"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import glob from "glob";
|
||||
import glob from 'glob';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import url from 'url';
|
||||
|
||||
@@ -1,29 +1,8 @@
|
||||
import type { SessionOptions } from './core/Session.js';
|
||||
import Session from './core/Session.js';
|
||||
|
||||
import NavigationEndpoint from './parser/classes/NavigationEndpoint.js';
|
||||
import type Format from './parser/classes/misc/Format.js';
|
||||
import Channel from './parser/youtube/Channel.js';
|
||||
import Comments from './parser/youtube/Comments.js';
|
||||
import Guide from './parser/youtube/Guide.js';
|
||||
import HashtagFeed from './parser/youtube/HashtagFeed.js';
|
||||
import History from './parser/youtube/History.js';
|
||||
import HomeFeed from './parser/youtube/HomeFeed.js';
|
||||
import Library from './parser/youtube/Library.js';
|
||||
import NotificationsMenu from './parser/youtube/NotificationsMenu.js';
|
||||
import Playlist from './parser/youtube/Playlist.js';
|
||||
import Search from './parser/youtube/Search.js';
|
||||
import VideoInfo from './parser/youtube/VideoInfo.js';
|
||||
import ShortsVideoInfo from './parser/ytshorts/VideoInfo.js';
|
||||
|
||||
import { Kids, Music, Studio } from './core/clients/index.js';
|
||||
import { AccountManager, InteractionManager, PlaylistManager } from './core/managers/index.js';
|
||||
import { Feed, TabbedFeed } from './core/mixins/index.js';
|
||||
|
||||
import * as Proto from './proto/index.js';
|
||||
import * as Constants from './utils/Constants.js';
|
||||
import { InnertubeError, generateRandomString, throwIfMissing } from './utils/Utils.js';
|
||||
|
||||
import {
|
||||
BrowseEndpoint,
|
||||
GetNotificationMenuEndpoint,
|
||||
@@ -32,16 +11,39 @@ import {
|
||||
PlayerEndpoint,
|
||||
ResolveURLEndpoint,
|
||||
SearchEndpoint,
|
||||
Reel
|
||||
Reel,
|
||||
Notification
|
||||
} from './core/endpoints/index.js';
|
||||
|
||||
import { GetUnseenCountEndpoint } from './core/endpoints/notification/index.js';
|
||||
import {
|
||||
Channel,
|
||||
Comments,
|
||||
Guide,
|
||||
HashtagFeed,
|
||||
History,
|
||||
HomeFeed,
|
||||
Library,
|
||||
NotificationsMenu,
|
||||
Playlist,
|
||||
Search,
|
||||
VideoInfo
|
||||
} from './parser/youtube/index.js';
|
||||
|
||||
import { VideoInfo as ShortsVideoInfo } from './parser/ytshorts/index.js';
|
||||
|
||||
import NavigationEndpoint from './parser/classes/NavigationEndpoint.js';
|
||||
|
||||
import * as Proto from './proto/index.js';
|
||||
import * as Constants from './utils/Constants.js';
|
||||
import { InnertubeError, generateRandomString, throwIfMissing } from './utils/Utils.js';
|
||||
|
||||
|
||||
import type { ApiResponse } from './core/Actions.js';
|
||||
import { type IBrowseResponse, type IParsedResponse } from './parser/types/index.js';
|
||||
import type { INextRequest } from './types/index.js';
|
||||
import type { IBrowseResponse, IParsedResponse } from './parser/types/index.js';
|
||||
import type { DownloadOptions, FormatOptions } from './types/FormatUtils.js';
|
||||
import { encodeReelSequence } from './proto/index.js';
|
||||
import type { SessionOptions } from './core/Session.js';
|
||||
import type Format from './parser/classes/misc/Format.js';
|
||||
|
||||
export type InnertubeConfig = SessionOptions;
|
||||
|
||||
@@ -151,7 +153,7 @@ export default class Innertube {
|
||||
|
||||
const sequenceResponse = this.actions.execute(
|
||||
Reel.WatchSequenceEndpoint.PATH, Reel.WatchSequenceEndpoint.build({
|
||||
sequenceParams: encodeReelSequence(short_id)
|
||||
sequenceParams: Proto.encodeReelSequence(short_id)
|
||||
})
|
||||
);
|
||||
|
||||
@@ -261,7 +263,7 @@ export default class Innertube {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves trending content.
|
||||
* Retrieves Trending content.
|
||||
*/
|
||||
async getTrending(): Promise<TabbedFeed<IBrowseResponse>> {
|
||||
const response = await this.actions.execute(
|
||||
@@ -271,7 +273,7 @@ export default class Innertube {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves subscriptions feed.
|
||||
* Retrieves Subscriptions feed.
|
||||
*/
|
||||
async getSubscriptionsFeed(): Promise<Feed<IBrowseResponse>> {
|
||||
const response = await this.actions.execute(
|
||||
@@ -281,7 +283,7 @@ export default class Innertube {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves channels feed.
|
||||
* Retrieves Channels feed.
|
||||
*/
|
||||
async getChannelsFeed(): Promise<Feed<IBrowseResponse>> {
|
||||
const response = await this.actions.execute(
|
||||
@@ -318,7 +320,7 @@ export default class Innertube {
|
||||
* Retrieves unseen notifications count.
|
||||
*/
|
||||
async getUnseenNotificationsCount(): Promise<number> {
|
||||
const response = await this.actions.execute(GetUnseenCountEndpoint.PATH);
|
||||
const response = await this.actions.execute(Notification.GetUnseenCountEndpoint.PATH);
|
||||
// TODO: properly parse this
|
||||
return response.data?.unseenCount || response.data?.actions?.[0].updateNotificationsUnseenCountAction?.unseenCount || 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Parser, NavigateAction } from '../parser/index.js';
|
||||
import { InnertubeError } from '../utils/Utils.js';
|
||||
|
||||
import type Session from './Session.js';
|
||||
import type { Session } from './index.js';
|
||||
|
||||
import type {
|
||||
IBrowseResponse, IGetNotificationsMenuResponse,
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import * as Constants from '../utils/Constants.js';
|
||||
import { Log, Constants } from '../utils/index.js';
|
||||
import { OAuthError, Platform } from '../utils/Utils.js';
|
||||
import type Session from './Session.js';
|
||||
|
||||
/**
|
||||
* Represents the credentials used for authentication.
|
||||
*/
|
||||
export interface Credentials {
|
||||
/**
|
||||
* Token used to sign in.
|
||||
@@ -15,6 +18,14 @@ export interface Credentials {
|
||||
* Access token's expiration date, which is usually 24hrs-ish.
|
||||
*/
|
||||
expires: Date;
|
||||
/**
|
||||
* Optional client ID.
|
||||
*/
|
||||
client_id?: string;
|
||||
/**
|
||||
* Optional client secret.
|
||||
*/
|
||||
client_secret?: string;
|
||||
}
|
||||
|
||||
// TODO: actual type info for this.
|
||||
@@ -28,7 +39,14 @@ export type OAuthAuthEventHandler = (data: {
|
||||
export type OAuthAuthPendingEventHandler = (data: OAuthAuthPendingData) => any;
|
||||
export type OAuthAuthErrorEventHandler = (err: OAuthError) => any;
|
||||
|
||||
export type OAuthClientIdentity = {
|
||||
client_id: string;
|
||||
client_secret: string;
|
||||
};
|
||||
|
||||
export default class OAuth {
|
||||
static TAG = 'OAuth';
|
||||
|
||||
#identity?: Record<string, string>;
|
||||
#session: Session;
|
||||
#credentials?: Credentials;
|
||||
@@ -71,6 +89,8 @@ export default class OAuth {
|
||||
this.#credentials = {
|
||||
access_token: credentials.access_token,
|
||||
refresh_token: credentials.refresh_token,
|
||||
client_id: credentials.client_id,
|
||||
client_secret: credentials.client_secret,
|
||||
expires: new Date(credentials.expires)
|
||||
};
|
||||
|
||||
@@ -157,6 +177,8 @@ export default class OAuth {
|
||||
this.#credentials = {
|
||||
access_token: response_data.access_token,
|
||||
refresh_token: response_data.refresh_token,
|
||||
client_id: this.#identity?.client_id,
|
||||
client_secret: this.#identity?.client_secret,
|
||||
expires: expiration_date
|
||||
};
|
||||
|
||||
@@ -206,6 +228,8 @@ export default class OAuth {
|
||||
this.#credentials = {
|
||||
access_token: response_data.access_token,
|
||||
refresh_token: response_data.refresh_token || this.#credentials.refresh_token,
|
||||
client_id: this.#identity.client_id,
|
||||
client_secret: this.#identity.client_secret,
|
||||
expires: expiration_date
|
||||
};
|
||||
|
||||
@@ -226,7 +250,15 @@ export default class OAuth {
|
||||
/**
|
||||
* Retrieves client identity from YouTube TV.
|
||||
*/
|
||||
async #getClientIdentity(): Promise<{ [key: string]: string; }> {
|
||||
async #getClientIdentity(): Promise<OAuthClientIdentity> {
|
||||
if (this.#credentials?.client_id && this.credentials?.client_secret) {
|
||||
Log.info(OAuth.TAG, 'Using custom OAuth2 credentials.\n');
|
||||
return {
|
||||
client_id: this.#credentials.client_id,
|
||||
client_secret: this.credentials.client_secret
|
||||
};
|
||||
}
|
||||
|
||||
const response = await this.#session.http.fetch_function(new URL('/tv', Constants.URLS.YT_BASE), { headers: Constants.OAUTH.HEADERS });
|
||||
|
||||
const response_data = await response.text();
|
||||
@@ -235,17 +267,21 @@ export default class OAuth {
|
||||
if (!url_body)
|
||||
throw new OAuthError('Could not obtain script url.', { status: 'FAILED' });
|
||||
|
||||
Log.info(OAuth.TAG, `Got YouTubeTV script URL (${url_body})`);
|
||||
|
||||
const script = await this.#session.http.fetch(url_body, { baseURL: Constants.URLS.YT_BASE });
|
||||
|
||||
const client_identity = (await script.text())
|
||||
.replace(/\n/g, '')
|
||||
.match(Constants.OAUTH.REGEX.CLIENT_IDENTITY);
|
||||
|
||||
const groups = client_identity?.groups;
|
||||
const groups = client_identity?.groups as OAuthClientIdentity | null;
|
||||
|
||||
if (!groups)
|
||||
throw new OAuthError('Could not obtain client identity.', { status: 'FAILED' });
|
||||
|
||||
Log.info(OAuth.TAG, 'OAuth2 credentials retrieved.\n', groups);
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { Log, Constants } from '../utils/index.js';
|
||||
import { Platform, getRandomUserAgent, getStringBetweenStrings, PlayerError } from '../utils/Utils.js';
|
||||
|
||||
import * as Constants from '../utils/Constants.js';
|
||||
|
||||
import type { ICache } from '../types/Cache.js';
|
||||
import type { FetchFunction } from '../types/PlatformShim.js';
|
||||
import type { ICache, FetchFunction } from '../types/index.js';
|
||||
|
||||
/**
|
||||
* Represents YouTube's player script. This is required to decipher signatures.
|
||||
*/
|
||||
export default class Player {
|
||||
static TAG = 'Player';
|
||||
|
||||
#nsig_sc;
|
||||
#sig_sc;
|
||||
#sig_sc_timestamp;
|
||||
@@ -17,9 +16,7 @@ export default class Player {
|
||||
constructor(signature_timestamp: number, sig_sc: string, nsig_sc: string, player_id: string) {
|
||||
this.#nsig_sc = nsig_sc;
|
||||
this.#sig_sc = sig_sc;
|
||||
|
||||
this.#sig_sc_timestamp = signature_timestamp;
|
||||
|
||||
this.#player_id = player_id;
|
||||
}
|
||||
|
||||
@@ -34,11 +31,14 @@ export default class Player {
|
||||
|
||||
const player_id = getStringBetweenStrings(js, 'player\\/', '\\/');
|
||||
|
||||
Log.info(Player.TAG, `Got player id (${player_id}). Checking for cached players..`);
|
||||
|
||||
if (!player_id)
|
||||
throw new PlayerError('Failed to get player id');
|
||||
|
||||
// We have the playerID now we can check if we have a cached player
|
||||
// We have the player id, now we can check if we have a cached player.
|
||||
if (cache) {
|
||||
Log.info(Player.TAG, 'Found a cached player.');
|
||||
const cached_player = await Player.fromCache(cache, player_id);
|
||||
if (cached_player)
|
||||
return cached_player;
|
||||
@@ -46,6 +46,8 @@ export default class Player {
|
||||
|
||||
const player_url = new URL(`/s/player/${player_id}/player_ias.vflset/en_US/base.js`, Constants.URLS.YT_BASE);
|
||||
|
||||
Log.info(Player.TAG, `Could not find any cached player. Will download a new player from ${player_url}.`);
|
||||
|
||||
const player_res = await fetch(player_url, {
|
||||
headers: {
|
||||
'user-agent': getRandomUserAgent('desktop')
|
||||
@@ -59,10 +61,11 @@ export default class Player {
|
||||
const player_js = await player_res.text();
|
||||
|
||||
const sig_timestamp = this.extractSigTimestamp(player_js);
|
||||
|
||||
const sig_sc = this.extractSigSourceCode(player_js);
|
||||
const nsig_sc = this.extractNSigSourceCode(player_js);
|
||||
|
||||
Log.info(Player.TAG, `Got signature timestamp (${sig_timestamp}) and algorithms needed to decipher signatures.`);
|
||||
|
||||
return await Player.fromSource(cache, sig_timestamp, sig_sc, nsig_sc, player_id);
|
||||
}
|
||||
|
||||
@@ -80,6 +83,8 @@ export default class Player {
|
||||
sig: args.get('s')
|
||||
});
|
||||
|
||||
Log.info(Player.TAG, `Transformed signature ${args.get('s')} to ${signature}.`);
|
||||
|
||||
if (typeof signature !== 'string')
|
||||
throw new PlayerError('Failed to decipher signature');
|
||||
|
||||
@@ -102,11 +107,13 @@ export default class Player {
|
||||
nsig: n
|
||||
});
|
||||
|
||||
Log.info(Player.TAG, `Transformed nsig ${n} to ${nsig}.`);
|
||||
|
||||
if (typeof nsig !== 'string')
|
||||
throw new PlayerError('Failed to decipher nsig');
|
||||
|
||||
if (nsig.startsWith('enhanced_except_')) {
|
||||
console.warn('Warning:\nCould not transform nsig, download may be throttled.\nChanging the InnerTube client to "ANDROID" might help!');
|
||||
Log.warn(Player.TAG, 'Could not transform nsig, download may be throttled.\nChanging the InnerTube client to "ANDROID" might help!');
|
||||
} else if (this_response_nsig_cache) {
|
||||
this_response_nsig_cache.set(n, nsig);
|
||||
}
|
||||
@@ -138,6 +145,10 @@ export default class Player {
|
||||
break;
|
||||
}
|
||||
|
||||
const result = url_components.toString();
|
||||
|
||||
Log.info(Player.TAG, `Full deciphered URL: ${result}`);
|
||||
|
||||
return url_components.toString();
|
||||
}
|
||||
|
||||
@@ -204,7 +215,7 @@ export default class Player {
|
||||
const functions = getStringBetweenStrings(data, `var ${obj_name}={`, '};');
|
||||
|
||||
if (!functions || !calls)
|
||||
console.warn(new PlayerError('Failed to extract signature decipher algorithm'));
|
||||
Log.warn(Player.TAG, 'Failed to extract signature decipher algorithm.');
|
||||
|
||||
return `function descramble_sig(a) { a = a.split(""); let ${obj_name}={${functions}}${calls} return a.join("") } descramble_sig(sig);`;
|
||||
}
|
||||
@@ -213,7 +224,7 @@ export default class Player {
|
||||
const sc = `function descramble_nsig(a) { let b=a.split("")${getStringBetweenStrings(data, 'b=a.split("")', '}return b.join("")}')}} return b.join(""); } descramble_nsig(nsig)`;
|
||||
|
||||
if (!sc)
|
||||
console.warn(new PlayerError('Failed to extract n-token decipher algorithm'));
|
||||
Log.warn(Player.TAG, 'Failed to extract n-token decipher algorithm');
|
||||
|
||||
return sc;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import OAuth from './OAuth.js';
|
||||
import { Log, EventEmitter, HTTPClient } from '../utils/index.js';
|
||||
import * as Constants from '../utils/Constants.js';
|
||||
import EventEmitterLike from '../utils/EventEmitterLike.js';
|
||||
import * as Proto from '../proto/index.js';
|
||||
import Actions from './Actions.js';
|
||||
import Player from './Player.js';
|
||||
|
||||
import * as Proto from '../proto/index.js';
|
||||
import type { ICache } from '../types/Cache.js';
|
||||
import type { FetchFunction } from '../types/PlatformShim.js';
|
||||
import HTTPClient from '../utils/HTTPClient.js';
|
||||
import {
|
||||
generateRandomString, getRandomUserAgent,
|
||||
InnertubeError, Platform, SessionError
|
||||
} from '../utils/Utils.js';
|
||||
|
||||
import type { DeviceCategory } from '../utils/Utils.js';
|
||||
import { generateRandomString, getRandomUserAgent, InnertubeError, Platform, SessionError } from '../utils/Utils.js';
|
||||
import type { Credentials, OAuthAuthErrorEventHandler, OAuthAuthEventHandler, OAuthAuthPendingEventHandler } from './OAuth.js';
|
||||
import OAuth from './OAuth.js';
|
||||
import type { FetchFunction, ICache } from '../types/index.js';
|
||||
import type {
|
||||
Credentials, OAuthAuthErrorEventHandler,
|
||||
OAuthAuthEventHandler, OAuthAuthPendingEventHandler
|
||||
} from './OAuth.js';
|
||||
|
||||
export enum ClientType {
|
||||
WEB = 'WEB',
|
||||
@@ -28,25 +33,25 @@ export interface Context {
|
||||
hl: string;
|
||||
gl: string;
|
||||
remoteHost?: string;
|
||||
screenDensityFloat: number;
|
||||
screenHeightPoints: number;
|
||||
screenPixelDensity: number;
|
||||
screenWidthPoints: number;
|
||||
visitorData: string;
|
||||
screenDensityFloat?: number;
|
||||
screenHeightPoints?: number;
|
||||
screenPixelDensity?: number;
|
||||
screenWidthPoints?: number;
|
||||
visitorData?: string;
|
||||
clientName: string;
|
||||
clientVersion: string;
|
||||
clientScreen?: string,
|
||||
androidSdkVersion?: string;
|
||||
androidSdkVersion?: number;
|
||||
osName: string;
|
||||
osVersion: string;
|
||||
platform: string;
|
||||
clientFormFactor: string;
|
||||
userInterfaceTheme: string;
|
||||
userInterfaceTheme?: string;
|
||||
timeZone: string;
|
||||
userAgent?: string;
|
||||
browserName?: string;
|
||||
browserVersion?: string;
|
||||
originalUrl: string;
|
||||
originalUrl?: string;
|
||||
deviceMake: string;
|
||||
deviceModel: string;
|
||||
utcOffsetMinutes: number;
|
||||
@@ -68,6 +73,10 @@ export interface Context {
|
||||
thirdParty?: {
|
||||
embedUrl: string;
|
||||
};
|
||||
request?: {
|
||||
useSsl: boolean;
|
||||
internalExperimentFlags: any[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface SessionOptions {
|
||||
@@ -140,10 +149,23 @@ export interface SessionData {
|
||||
api_version: string;
|
||||
}
|
||||
|
||||
export type SessionArgs = {
|
||||
lang: string;
|
||||
location: string;
|
||||
time_zone: string;
|
||||
device_category: DeviceCategory;
|
||||
client_name: ClientType;
|
||||
enable_safety_mode: boolean;
|
||||
visitor_data: string;
|
||||
on_behalf_of_user: string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an InnerTube session. This holds all the data needed to make requests to YouTube.
|
||||
*/
|
||||
export default class Session extends EventEmitterLike {
|
||||
export default class Session extends EventEmitter {
|
||||
static TAG = 'Session';
|
||||
|
||||
#api_version: string;
|
||||
#key: string;
|
||||
#context: Context;
|
||||
@@ -226,6 +248,8 @@ export default class Session extends EventEmitterLike {
|
||||
|
||||
const session_args = { lang, location, time_zone: tz, device_category, client_name, enable_safety_mode, visitor_data, on_behalf_of_user };
|
||||
|
||||
Log.info(Session.TAG, 'Retrieving InnerTube session.');
|
||||
|
||||
if (generate_session_locally) {
|
||||
session_data = this.#generateSessionData(session_args);
|
||||
} else {
|
||||
@@ -233,30 +257,29 @@ export default class Session extends EventEmitterLike {
|
||||
// This can fail if the data changes or the request is blocked for some reason.
|
||||
session_data = await this.#retrieveSessionData(session_args, fetch);
|
||||
} catch (err) {
|
||||
Log.error(Session.TAG, 'Failed to retrieve session data from server. Will try to generate it locally.');
|
||||
session_data = this.#generateSessionData(session_args);
|
||||
}
|
||||
}
|
||||
|
||||
Log.info(Session.TAG, 'Got session data.\n', session_data);
|
||||
|
||||
return { ...session_data, account_index };
|
||||
}
|
||||
|
||||
static async #retrieveSessionData(options: {
|
||||
lang: string;
|
||||
location: string;
|
||||
time_zone: string;
|
||||
device_category: string;
|
||||
client_name: string;
|
||||
enable_safety_mode: boolean;
|
||||
visitor_data: string;
|
||||
on_behalf_of_user?: string;
|
||||
}, fetch: FetchFunction = Platform.shim.fetch): Promise<SessionData> {
|
||||
static #getVisitorID(visitor_data: string) {
|
||||
const decoded_visitor_data = Proto.decodeVisitorData(visitor_data);
|
||||
Log.info(Session.TAG, 'Custom visitor data decoded successfully.\n', decoded_visitor_data);
|
||||
return decoded_visitor_data.id;
|
||||
}
|
||||
|
||||
static async #retrieveSessionData(options: SessionArgs, fetch: FetchFunction = Platform.shim.fetch): Promise<SessionData> {
|
||||
const url = new URL('/sw.js_data', Constants.URLS.YT_BASE);
|
||||
|
||||
let visitor_id = generateRandomString(11);
|
||||
|
||||
if (options.visitor_data) {
|
||||
const decoded_visitor_data = Proto.decodeVisitorData(options.visitor_data);
|
||||
visitor_id = decoded_visitor_data.id;
|
||||
visitor_id = this.#getVisitorID(options.visitor_data);
|
||||
}
|
||||
|
||||
const res = await fetch(url, {
|
||||
@@ -277,7 +300,7 @@ export default class Session extends EventEmitterLike {
|
||||
|
||||
const ytcfg = data[0][2];
|
||||
|
||||
const api_version = `v${ytcfg[0][0][6]}`;
|
||||
const api_version = Constants.CLIENTS.WEB.API_VERSION;
|
||||
|
||||
const [ [ device_info ], api_key ] = ytcfg;
|
||||
|
||||
@@ -308,29 +331,25 @@ export default class Session extends EventEmitterLike {
|
||||
},
|
||||
user: {
|
||||
enableSafetyMode: options.enable_safety_mode,
|
||||
lockedSafetyMode: false,
|
||||
onBehalfOfUser: options.on_behalf_of_user
|
||||
lockedSafetyMode: false
|
||||
},
|
||||
request: {
|
||||
useSsl: true,
|
||||
internalExperimentFlags: []
|
||||
}
|
||||
};
|
||||
|
||||
if (options.on_behalf_of_user)
|
||||
context.user.onBehalfOfUser = options.on_behalf_of_user;
|
||||
|
||||
return { context, api_key, api_version };
|
||||
}
|
||||
|
||||
static #generateSessionData(options: {
|
||||
lang: string;
|
||||
location: string;
|
||||
time_zone: string;
|
||||
device_category: DeviceCategory;
|
||||
client_name: string;
|
||||
enable_safety_mode: boolean;
|
||||
visitor_data: string;
|
||||
on_behalf_of_user?: string;
|
||||
}): SessionData {
|
||||
static #generateSessionData(options: SessionArgs): SessionData {
|
||||
let visitor_id = generateRandomString(11);
|
||||
|
||||
if (options.visitor_data) {
|
||||
const decoded_visitor_data = Proto.decodeVisitorData(options.visitor_data);
|
||||
visitor_id = decoded_visitor_data.id;
|
||||
visitor_id = this.#getVisitorID(options.visitor_data);
|
||||
}
|
||||
|
||||
const context: Context = {
|
||||
@@ -357,11 +376,17 @@ export default class Session extends EventEmitterLike {
|
||||
},
|
||||
user: {
|
||||
enableSafetyMode: options.enable_safety_mode,
|
||||
lockedSafetyMode: false,
|
||||
onBehalfOfUser: options.on_behalf_of_user
|
||||
lockedSafetyMode: false
|
||||
},
|
||||
request: {
|
||||
useSsl: true,
|
||||
internalExperimentFlags: []
|
||||
}
|
||||
};
|
||||
|
||||
if (options.on_behalf_of_user)
|
||||
context.user.onBehalfOfUser = options.on_behalf_of_user;
|
||||
|
||||
return { context, api_key: Constants.CLIENTS.WEB.API_KEY, api_version: Constants.CLIENTS.WEB.API_VERSION };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import { Parser } from '../../parser/index.js';
|
||||
import Channel from '../../parser/ytkids/Channel.js';
|
||||
import HomeFeed from '../../parser/ytkids/HomeFeed.js';
|
||||
import Search from '../../parser/ytkids/Search.js';
|
||||
import VideoInfo from '../../parser/ytkids/VideoInfo.js';
|
||||
import type Session from '../Session.js';
|
||||
import { type ApiResponse } from '../Actions.js';
|
||||
|
||||
import { Channel, HomeFeed, Search, VideoInfo } from '../../parser/ytkids/index.js';
|
||||
import { InnertubeError, generateRandomString } from '../../utils/Utils.js';
|
||||
import KidsBlocklistPickerItem from '../../parser/classes/ytkids/KidsBlocklistPickerItem.js';
|
||||
|
||||
import {
|
||||
BrowseEndpoint, NextEndpoint,
|
||||
@@ -15,7 +10,7 @@ import {
|
||||
|
||||
import { BlocklistPickerEndpoint } from '../endpoints/kids/index.js';
|
||||
|
||||
import KidsBlocklistPickerItem from '../../parser/classes/ytkids/KidsBlocklistPickerItem.js';
|
||||
import type { Session, ApiResponse } from '../index.js';
|
||||
|
||||
export default class Kids {
|
||||
#session: Session;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import Album from '../../parser/ytmusic/Album.js';
|
||||
import Artist from '../../parser/ytmusic/Artist.js';
|
||||
import Explore from '../../parser/ytmusic/Explore.js';
|
||||
import HomeFeed from '../../parser/ytmusic/HomeFeed.js';
|
||||
import Library from '../../parser/ytmusic/Library.js';
|
||||
import Playlist from '../../parser/ytmusic/Playlist.js';
|
||||
import Recap from '../../parser/ytmusic/Recap.js';
|
||||
import Search from '../../parser/ytmusic/Search.js';
|
||||
import TrackInfo from '../../parser/ytmusic/TrackInfo.js';
|
||||
import * as Proto from '../../proto/index.js';
|
||||
import { InnertubeError, generateRandomString, throwIfMissing } from '../../utils/Utils.js';
|
||||
|
||||
import {
|
||||
Album, Artist, Explore,
|
||||
HomeFeed, Library, Playlist,
|
||||
Recap, Search, TrackInfo
|
||||
} from '../../parser/ytmusic/index.js';
|
||||
|
||||
import AutomixPreviewVideo from '../../parser/classes/AutomixPreviewVideo.js';
|
||||
import Message from '../../parser/classes/Message.js';
|
||||
@@ -18,13 +17,6 @@ import PlaylistPanel from '../../parser/classes/PlaylistPanel.js';
|
||||
import SearchSuggestionsSection from '../../parser/classes/SearchSuggestionsSection.js';
|
||||
import SectionList from '../../parser/classes/SectionList.js';
|
||||
import Tab from '../../parser/classes/Tab.js';
|
||||
import * as Proto from '../../proto/index.js';
|
||||
|
||||
import type { ObservedArray } from '../../parser/helpers.js';
|
||||
import type { MusicSearchFilters } from '../../types/index.js';
|
||||
import { InnertubeError, generateRandomString, throwIfMissing } from '../../utils/Utils.js';
|
||||
import type Actions from '../Actions.js';
|
||||
import type Session from '../Session.js';
|
||||
|
||||
import {
|
||||
BrowseEndpoint,
|
||||
@@ -35,6 +27,10 @@ import {
|
||||
|
||||
import { GetSearchSuggestionsEndpoint } from '../endpoints/music/index.js';
|
||||
|
||||
import type { ObservedArray } from '../../parser/helpers.js';
|
||||
import type { MusicSearchFilters } from '../../types/index.js';
|
||||
import type { Actions, Session } from '../index.js';
|
||||
|
||||
export default class Music {
|
||||
#session: Session;
|
||||
#actions: Actions;
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import * as Proto from '../../proto/index.js';
|
||||
import * as Constants from '../../utils/Constants.js';
|
||||
import { Constants } from '../../utils/index.js';
|
||||
import { InnertubeError, MissingParamError, Platform } from '../../utils/Utils.js';
|
||||
import { CreateVideoEndpoint } from '../endpoints/upload/index.js';
|
||||
|
||||
import type { UpdateVideoMetadataOptions, UploadedVideoMetadataOptions } from '../../types/Clients.js';
|
||||
import type { ApiResponse } from '../Actions.js';
|
||||
import type Session from '../Session.js';
|
||||
|
||||
import { CreateVideoEndpoint } from '../endpoints/upload/index.js';
|
||||
import type { ApiResponse, Session } from '../index.js';
|
||||
|
||||
interface UploadResult {
|
||||
status: string;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { encodeShortsParam } from '../../proto/index.js';
|
||||
import type { IPlayerRequest, PlayerEndpointOptions } from '../../types/index.js';
|
||||
|
||||
export const PATH = '/player';
|
||||
@@ -43,7 +44,7 @@ export function build(opts: PlayerEndpointOptions): IPlayerRequest {
|
||||
client: opts.client,
|
||||
playlistId: opts.playlist_id,
|
||||
// Workaround streaming URLs returning 403 or getting throttled when using Android based clients.
|
||||
params: is_android ? '2AMBCgIQBg' : opts.params
|
||||
params: is_android ? encodeShortsParam() : opts.params
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { Actions, ApiResponse } from '../index.js';
|
||||
|
||||
import AccountInfo from '../../parser/youtube/AccountInfo.js';
|
||||
import Analytics from '../../parser/youtube/Analytics.js';
|
||||
import Settings from '../../parser/youtube/Settings.js';
|
||||
@@ -7,9 +9,6 @@ import * as Proto from '../../proto/index.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import { Account, BrowseEndpoint, Channel } from '../endpoints/index.js';
|
||||
|
||||
import type Actions from '../Actions.js';
|
||||
import type { ApiResponse } from '../Actions.js';
|
||||
|
||||
export default class AccountManager {
|
||||
#actions: Actions;
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import * as Proto from '../../proto/index.js';
|
||||
import type Actions from '../Actions.js';
|
||||
import type { ApiResponse } from '../Actions.js';
|
||||
|
||||
import { throwIfMissing } from '../../utils/Utils.js';
|
||||
import { LikeEndpoint, DislikeEndpoint, RemoveLikeEndpoint } from '../endpoints/like/index.js';
|
||||
@@ -8,6 +6,8 @@ import { SubscribeEndpoint, UnsubscribeEndpoint } from '../endpoints/subscriptio
|
||||
import { CreateCommentEndpoint, PerformCommentActionEndpoint } from '../endpoints/comment/index.js';
|
||||
import { ModifyChannelPreferenceEndpoint } from '../endpoints/notification/index.js';
|
||||
|
||||
import type { Actions, ApiResponse } from '../index.js';
|
||||
|
||||
export default class InteractionManager {
|
||||
#actions: Actions;
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import Playlist from '../../parser/youtube/Playlist.js';
|
||||
import type Actions from '../Actions.js';
|
||||
import type Feed from '../mixins/Feed.js';
|
||||
|
||||
import type { EditPlaylistEndpointOptions } from '../../types/index.js';
|
||||
import { InnertubeError, throwIfMissing } from '../../utils/Utils.js';
|
||||
import { EditPlaylistEndpoint } from '../endpoints/browse/index.js';
|
||||
import { BrowseEndpoint } from '../endpoints/index.js';
|
||||
import { CreateEndpoint, DeleteEndpoint } from '../endpoints/playlist/index.js';
|
||||
import Playlist from '../../parser/youtube/Playlist.js';
|
||||
|
||||
import type { Actions } from '../index.js';
|
||||
import type { Feed } from '../mixins/index.js';
|
||||
import type { EditPlaylistEndpointOptions } from '../../types/index.js';
|
||||
|
||||
export default class PlaylistManager {
|
||||
#actions: Actions;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import type { Memo, ObservedArray, SuperParsedResult, YTNode } from '../../parser/helpers.js';
|
||||
import { Parser, ReloadContinuationItemsCommand } from '../../parser/index.js';
|
||||
import { concatMemos, InnertubeError } from '../../utils/Utils.js';
|
||||
import type Actions from '../Actions.js';
|
||||
|
||||
import BackstagePost from '../../parser/classes/BackstagePost.js';
|
||||
import SharedPost from '../../parser/classes/SharedPost.js';
|
||||
@@ -10,6 +8,7 @@ import CompactVideo from '../../parser/classes/CompactVideo.js';
|
||||
import GridChannel from '../../parser/classes/GridChannel.js';
|
||||
import GridPlaylist from '../../parser/classes/GridPlaylist.js';
|
||||
import GridVideo from '../../parser/classes/GridVideo.js';
|
||||
import LockupView from '../../parser/classes/LockupView.js';
|
||||
import Playlist from '../../parser/classes/Playlist.js';
|
||||
import PlaylistPanelVideo from '../../parser/classes/PlaylistPanelVideo.js';
|
||||
import PlaylistVideo from '../../parser/classes/PlaylistVideo.js';
|
||||
@@ -27,12 +26,15 @@ import TwoColumnBrowseResults from '../../parser/classes/TwoColumnBrowseResults.
|
||||
import TwoColumnSearchResults from '../../parser/classes/TwoColumnSearchResults.js';
|
||||
import WatchCardCompactVideo from '../../parser/classes/WatchCardCompactVideo.js';
|
||||
|
||||
import type { ApiResponse, Actions } from '../index.js';
|
||||
import type {
|
||||
Memo, ObservedArray,
|
||||
SuperParsedResult, YTNode
|
||||
} from '../../parser/helpers.js';
|
||||
import type MusicQueue from '../../parser/classes/MusicQueue.js';
|
||||
import type RichGrid from '../../parser/classes/RichGrid.js';
|
||||
import type SectionList from '../../parser/classes/SectionList.js';
|
||||
|
||||
import type { IParsedResponse } from '../../parser/types/index.js';
|
||||
import type { ApiResponse } from '../Actions.js';
|
||||
|
||||
export default class Feed<T extends IParsedResponse = IParsedResponse> {
|
||||
#page: T;
|
||||
@@ -87,7 +89,18 @@ export default class Feed<T extends IParsedResponse = IParsedResponse> {
|
||||
* Get all playlists on a given page via memo
|
||||
*/
|
||||
static getPlaylistsFromMemo(memo: Memo) {
|
||||
return memo.getType(Playlist, GridPlaylist);
|
||||
const playlists: ObservedArray<Playlist | GridPlaylist | LockupView> = memo.getType(Playlist, GridPlaylist);
|
||||
|
||||
const lockup_views = memo.getType(LockupView)
|
||||
.filter((lockup) => {
|
||||
return [ 'PLAYLIST', 'ALBUM', 'PODCAST' ].includes(lockup.content_type);
|
||||
});
|
||||
|
||||
if (lockup_views.length > 0) {
|
||||
playlists.push(...lockup_views);
|
||||
}
|
||||
|
||||
return playlists;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,10 +225,10 @@ export default class Feed<T extends IParsedResponse = IParsedResponse> {
|
||||
#getBodyContinuations(): ObservedArray<ContinuationItem> {
|
||||
if (this.#page.header_memo) {
|
||||
const header_continuations = this.#page.header_memo.getType(ContinuationItem);
|
||||
|
||||
return this.#memo.getType(ContinuationItem).filter((continuation) => !header_continuations.includes(continuation)) as ObservedArray<ContinuationItem>;
|
||||
return this.#memo.getType(ContinuationItem).filter(
|
||||
(continuation) => !header_continuations.includes(continuation)
|
||||
) as ObservedArray<ContinuationItem>;
|
||||
}
|
||||
|
||||
return this.#memo.getType(ContinuationItem);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
import Feed from './Feed.js';
|
||||
import ChipCloudChip from '../../parser/classes/ChipCloudChip.js';
|
||||
import FeedFilterChipBar from '../../parser/classes/FeedFilterChipBar.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import Feed from './Feed.js';
|
||||
|
||||
import type { ObservedArray } from '../../parser/helpers.js';
|
||||
import type { IParsedResponse } from '../../parser/types/ParsedResponse.js';
|
||||
import type Actions from '../Actions.js';
|
||||
import type { ApiResponse } from '../Actions.js';
|
||||
import type { IParsedResponse } from '../../parser/types/index.js';
|
||||
import type { ApiResponse, Actions } from '../index.js';
|
||||
|
||||
export default class FilterableFeed<T extends IParsedResponse> extends Feed<T> {
|
||||
#chips?: ObservedArray<ChipCloudChip>;
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import type { ApiResponse } from '../Actions.js';
|
||||
import type Actions from '../Actions.js';
|
||||
import * as Constants from '../../utils/Constants.js';
|
||||
import type { DownloadOptions, FormatFilter, FormatOptions, URLTransformer } from '../../types/FormatUtils.js';
|
||||
import * as FormatUtils from '../../utils/FormatUtils.js';
|
||||
import { Constants, FormatUtils } from '../../utils/index.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import type Format from '../../parser/classes/misc/Format.js';
|
||||
import type { INextResponse, IPlayerConfig, IPlayerResponse } from '../../parser/index.js';
|
||||
import { Parser } from '../../parser/index.js';
|
||||
import type { DashOptions } from '../../types/DashOptions.js';
|
||||
import PlayerStoryboardSpec from '../../parser/classes/PlayerStoryboardSpec.js';
|
||||
import { getStreamingInfo } from '../../utils/StreamingInfo.js';
|
||||
|
||||
import { Parser } from '../../parser/index.js';
|
||||
import { TranscriptInfo } from '../../parser/youtube/index.js';
|
||||
import ContinuationItem from '../../parser/classes/ContinuationItem.js';
|
||||
import TranscriptInfo from '../../parser/youtube/TranscriptInfo.js';
|
||||
|
||||
import type { ApiResponse, Actions } from '../index.js';
|
||||
import type { INextResponse, IPlayerConfig, IPlayerResponse } from '../../parser/index.js';
|
||||
import type { DownloadOptions, FormatFilter, FormatOptions, URLTransformer } from '../../types/FormatUtils.js';
|
||||
import type Format from '../../parser/classes/misc/Format.js';
|
||||
import type { DashOptions } from '../../types/DashOptions.js';
|
||||
|
||||
export default class MediaInfo {
|
||||
#page: [IPlayerResponse, INextResponse?];
|
||||
@@ -50,17 +49,17 @@ export default class MediaInfo {
|
||||
async toDash(url_transformer?: URLTransformer, format_filter?: FormatFilter, options: DashOptions = { include_thumbnails: false }): Promise<string> {
|
||||
const player_response = this.#page[0];
|
||||
|
||||
if (player_response.video_details && (player_response.video_details.is_live || player_response.video_details.is_post_live_dvr)) {
|
||||
throw new InnertubeError('Generating DASH manifests for live and Post-Live-DVR videos is not supported. Please use the DASH and HLS manifests provided by YouTube in `streaming_data.dash_manifest_url` and `streaming_data.hls_manifest_url` instead.');
|
||||
if (player_response.video_details && (player_response.video_details.is_live)) {
|
||||
throw new InnertubeError('Generating DASH manifests for live videos is not supported. Please use the DASH and HLS manifests provided by YouTube in `streaming_data.dash_manifest_url` and `streaming_data.hls_manifest_url` instead.');
|
||||
}
|
||||
|
||||
let storyboards;
|
||||
|
||||
if (options.include_thumbnails && player_response.storyboards?.is(PlayerStoryboardSpec)) {
|
||||
if (options.include_thumbnails && player_response.storyboards) {
|
||||
storyboards = player_response.storyboards;
|
||||
}
|
||||
|
||||
return FormatUtils.toDash(this.streaming_data, url_transformer, format_filter, this.#cpn, this.#actions.session.player, this.#actions, storyboards);
|
||||
return FormatUtils.toDash(this.streaming_data, this.page[0].video_details?.is_post_live_dvr, url_transformer, format_filter, this.#cpn, this.#actions.session.player, this.#actions, storyboards);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,12 +68,13 @@ export default class MediaInfo {
|
||||
getStreamingInfo(url_transformer?: URLTransformer, format_filter?: FormatFilter) {
|
||||
return getStreamingInfo(
|
||||
this.streaming_data,
|
||||
this.page[0].video_details?.is_post_live_dvr,
|
||||
url_transformer,
|
||||
format_filter,
|
||||
this.cpn,
|
||||
this.#actions.session.player,
|
||||
this.#actions,
|
||||
this.#page[0].storyboards?.is(PlayerStoryboardSpec) ? this.#page[0].storyboards : undefined
|
||||
this.#page[0].storyboards ? this.#page[0].storyboards : undefined
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import Tab from '../../parser/classes/Tab.js';
|
||||
import Feed from './Feed.js';
|
||||
import { Feed } from './index.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import Tab from '../../parser/classes/Tab.js';
|
||||
|
||||
import type Actions from '../Actions.js';
|
||||
import type { Actions, ApiResponse } from '../index.js';
|
||||
import type { ObservedArray } from '../../parser/helpers.js';
|
||||
import type { IParsedResponse } from '../../parser/types/ParsedResponse.js';
|
||||
import type { ApiResponse } from '../Actions.js';
|
||||
|
||||
export default class TabbedFeed<T extends IParsedResponse> extends Feed<T> {
|
||||
#tabs?: ObservedArray<Tab>;
|
||||
|
||||
17
src/parser/classes/AttributionView.ts
Normal file
17
src/parser/classes/AttributionView.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
|
||||
export default class AttributionView extends YTNode {
|
||||
static type = 'AttributionView';
|
||||
|
||||
text: Text;
|
||||
suffix: Text;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.text = Text.fromAttributed(data.text);
|
||||
this.suffix = Text.fromAttributed(data.suffix);
|
||||
}
|
||||
}
|
||||
@@ -5,24 +5,20 @@ import { Thumbnail } from '../misc.js';
|
||||
export default class AvatarView extends YTNode {
|
||||
static type = 'AvatarView';
|
||||
|
||||
image: {
|
||||
sources: Thumbnail[],
|
||||
processor: {
|
||||
border_image_processor: {
|
||||
circular: boolean
|
||||
}
|
||||
image: Thumbnail[];
|
||||
image_processor: {
|
||||
border_image_processor: {
|
||||
circular: boolean
|
||||
}
|
||||
};
|
||||
avatar_image_size: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.image = {
|
||||
sources: data.image.sources.map((x: any) => new Thumbnail(x)).sort((a: Thumbnail, b: Thumbnail) => b.width - a.width),
|
||||
processor: {
|
||||
border_image_processor: {
|
||||
circular: data.image.processor.borderImageProcessor.circular
|
||||
}
|
||||
this.image = Thumbnail.fromResponse(data.image);
|
||||
this.image_processor = {
|
||||
border_image_processor: {
|
||||
circular: data.image.processor.borderImageProcessor.circular
|
||||
}
|
||||
};
|
||||
this.avatar_image_size = data.avatarImageSize;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Log } from '../../utils/index.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import Button from './Button.js';
|
||||
@@ -44,6 +45,7 @@ export default class Channel extends YTNode {
|
||||
* Please use {@link Channel.subscriber_count} instead.
|
||||
*/
|
||||
get subscribers(): Text {
|
||||
Log.warnOnce(Channel.type, 'Channel#subscribers is deprecated. Please use Channel#subscriber_count instead.');
|
||||
return this.subscriber_count;
|
||||
}
|
||||
|
||||
@@ -53,6 +55,7 @@ export default class Channel extends YTNode {
|
||||
* Please use {@link Channel.video_count} instead.
|
||||
*/
|
||||
get videos(): Text {
|
||||
Log.warnOnce(Channel.type, 'Channel#videos is deprecated. Please use Channel#video_count instead.');
|
||||
return this.video_count;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Log } from '../../utils/index.js';
|
||||
import { YTNode, type ObservedArray } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import Button from './Button.js';
|
||||
@@ -55,6 +56,7 @@ export default class ChannelAboutFullMetadata extends YTNode {
|
||||
* Please use {@link Channel.view_count} instead.
|
||||
*/
|
||||
get views() {
|
||||
Log.warnOnce(ChannelAboutFullMetadata.type, 'ChannelAboutFullMetadata#views is deprecated. Please use ChannelAboutFullMetadata#view_count instead.');
|
||||
return this.view_count;
|
||||
}
|
||||
|
||||
@@ -64,6 +66,7 @@ export default class ChannelAboutFullMetadata extends YTNode {
|
||||
* Please use {@link Channel.joined_date} instead.
|
||||
*/
|
||||
get joined(): Text {
|
||||
Log.warnOnce(ChannelAboutFullMetadata.type, 'ChannelAboutFullMetadata#joined is deprecated. Please use ChannelAboutFullMetadata#joined_date instead.');
|
||||
return this.joined_date;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import Text from './misc/Text.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import { Log } from '../../utils/index.js';
|
||||
|
||||
export default class ChannelVideoPlayer extends YTNode {
|
||||
static type = 'ChannelVideoPlayer';
|
||||
@@ -26,6 +27,7 @@ export default class ChannelVideoPlayer extends YTNode {
|
||||
* Please use {@link ChannelVideoPlayer.view_count} instead.
|
||||
*/
|
||||
get views(): Text {
|
||||
Log.warnOnce(ChannelVideoPlayer.type, 'ChannelVideoPlayer#views is deprecated. Please use ChannelVideoPlayer#view_count instead.');
|
||||
return this.view_count;
|
||||
}
|
||||
|
||||
@@ -35,6 +37,7 @@ export default class ChannelVideoPlayer extends YTNode {
|
||||
* Please use {@link ChannelVideoPlayer.published_time} instead.
|
||||
*/
|
||||
get published(): Text {
|
||||
Log.warnOnce(ChannelVideoPlayer.type, 'ChannelVideoPlayer#published is deprecated. Please use ChannelVideoPlayer#published_time instead.');
|
||||
return this.published_time;
|
||||
}
|
||||
}
|
||||
23
src/parser/classes/CollectionThumbnailView.ts
Normal file
23
src/parser/classes/CollectionThumbnailView.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import ThumbnailView from './ThumbnailView.js';
|
||||
|
||||
export default class CollectionThumbnailView extends YTNode {
|
||||
static type = 'CollectionThumbnailView';
|
||||
|
||||
primary_thumbnail: ThumbnailView | null;
|
||||
stack_color: {
|
||||
light_theme: number;
|
||||
dark_theme: number;
|
||||
};
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.primary_thumbnail = Parser.parseItem(data.primaryThumbnail, ThumbnailView);
|
||||
this.stack_color = {
|
||||
light_theme: data.stackColor.lightTheme,
|
||||
dark_theme: data.stackColor.darkTheme
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import type { RawNode } from '../index.js';
|
||||
import { Text } from '../misc.js';
|
||||
|
||||
export type MetadataRow = {
|
||||
metadata_parts: {
|
||||
metadata_parts?: {
|
||||
text: Text;
|
||||
}[];
|
||||
};
|
||||
@@ -17,7 +17,7 @@ export default class ContentMetadataView extends YTNode {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.metadata_rows = data.metadataRows.map((row: RawNode) => ({
|
||||
metadata_parts: row.metadataParts.map((part: RawNode) => ({
|
||||
metadata_parts: row.metadataParts?.map((part: RawNode) => ({
|
||||
text: Text.fromAttributed(part.text)
|
||||
}))
|
||||
}));
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import NavigationEndpoint from './NavigationEndpoint.js';
|
||||
import AvatarView from './AvatarView.js';
|
||||
|
||||
export default class DecoratedAvatarView extends YTNode {
|
||||
static type = 'DecoratedAvatarView';
|
||||
|
||||
avatar: AvatarView;
|
||||
avatar: AvatarView | null;
|
||||
a11y_label: string;
|
||||
on_tap_endpoint: NavigationEndpoint;
|
||||
on_tap_endpoint?: NavigationEndpoint;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.avatar = new AvatarView(data.avatar.avatarViewModel);
|
||||
this.avatar = Parser.parseItem(data.avatar, AvatarView);
|
||||
this.a11y_label = data.a11yLabel;
|
||||
this.on_tap_endpoint = new NavigationEndpoint(data.rendererContext.commandContext.onTap.innertubeCommand);
|
||||
if (data.rendererContext?.commandContext?.onTap) {
|
||||
this.on_tap_endpoint = new NavigationEndpoint(data.rendererContext.commandContext.onTap);
|
||||
}
|
||||
}
|
||||
}
|
||||
47
src/parser/classes/DescriptionPreviewView.ts
Normal file
47
src/parser/classes/DescriptionPreviewView.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import EngagementPanelSectionList from './EngagementPanelSectionList.js';
|
||||
import Text from './misc/Text.js';
|
||||
|
||||
export default class DescriptionPreviewView extends YTNode {
|
||||
static type = 'DescriptionPreviewView';
|
||||
|
||||
description: Text;
|
||||
max_lines: number;
|
||||
truncation_text: Text;
|
||||
always_show_truncation_text: boolean;
|
||||
more_endpoint?: {
|
||||
show_engagement_panel_endpoint: {
|
||||
engagement_panel: EngagementPanelSectionList | null,
|
||||
engagement_panel_popup_type: string;
|
||||
identifier: {
|
||||
surface: string,
|
||||
tag: string
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.description = Text.fromAttributed(data.description);
|
||||
this.max_lines = parseInt(data.maxLines);
|
||||
this.truncation_text = Text.fromAttributed(data.truncationText);
|
||||
this.always_show_truncation_text = !!data.alwaysShowTruncationText;
|
||||
|
||||
if (data.rendererContext.commandContext?.onTap?.innertubeCommand?.showEngagementPanelEndpoint) {
|
||||
const endpoint = data.rendererContext.commandContext?.onTap?.innertubeCommand?.showEngagementPanelEndpoint;
|
||||
|
||||
this.more_endpoint = {
|
||||
show_engagement_panel_endpoint: {
|
||||
engagement_panel: Parser.parseItem(endpoint.engagementPanel, EngagementPanelSectionList),
|
||||
engagement_panel_popup_type: endpoint.engagementPanelPresentationConfigs.engagementPanelPopupPresentationConfig.popupType,
|
||||
identifier: {
|
||||
surface: endpoint.identifier.surface,
|
||||
tag: endpoint.identifier.tag
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
|
||||
export default class DynamicTextView extends YTNode {
|
||||
static type = 'DynamicTextView';
|
||||
|
||||
text: string;
|
||||
text: Text;
|
||||
max_lines: number;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.text = data.text.content;
|
||||
this.text = Text.fromAttributed(data.text);
|
||||
this.max_lines = parseInt(data.maxLines);
|
||||
}
|
||||
}
|
||||
16
src/parser/classes/ImageBannerView.ts
Normal file
16
src/parser/classes/ImageBannerView.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import Thumbnail from './misc/Thumbnail.js';
|
||||
|
||||
export default class ImageBannerView extends YTNode {
|
||||
static type = 'ImageBannerView';
|
||||
|
||||
image: Thumbnail[];
|
||||
style: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.image = Thumbnail.fromResponse(data.image);
|
||||
this.style = data.style;
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,19 @@ import { Parser, type RawNode } from '../index.js';
|
||||
import ItemSectionHeader from './ItemSectionHeader.js';
|
||||
import ItemSectionTabbedHeader from './ItemSectionTabbedHeader.js';
|
||||
import CommentsHeader from './comments/CommentsHeader.js';
|
||||
import SortFilterHeader from './SortFilterHeader.js';
|
||||
|
||||
export default class ItemSection extends YTNode {
|
||||
static type = 'ItemSection';
|
||||
|
||||
header: CommentsHeader | ItemSectionHeader | ItemSectionTabbedHeader | null;
|
||||
header: CommentsHeader | ItemSectionHeader | ItemSectionTabbedHeader | SortFilterHeader | null;
|
||||
contents: ObservedArray<YTNode>;
|
||||
target_id?: string;
|
||||
continuation?: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.header = Parser.parseItem(data.header, [ CommentsHeader, ItemSectionHeader, ItemSectionTabbedHeader ]);
|
||||
this.header = Parser.parseItem(data.header, [ CommentsHeader, ItemSectionHeader, ItemSectionTabbedHeader, SortFilterHeader ]);
|
||||
this.contents = Parser.parseArray(data.contents);
|
||||
|
||||
if (data.targetId || data.sectionIdentifier) {
|
||||
|
||||
18
src/parser/classes/LockupMetadataView.ts
Normal file
18
src/parser/classes/LockupMetadataView.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import ContentMetadataView from './ContentMetadataView.js';
|
||||
import Text from './misc/Text.js';
|
||||
|
||||
export default class LockupMetadataView extends YTNode {
|
||||
static type = 'LockupMetadataView';
|
||||
|
||||
title: Text;
|
||||
metadata: ContentMetadataView | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.title = Text.fromAttributed(data.title);
|
||||
this.metadata = Parser.parseItem(data.metadata, ContentMetadataView);
|
||||
}
|
||||
}
|
||||
25
src/parser/classes/LockupView.ts
Normal file
25
src/parser/classes/LockupView.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import CollectionThumbnailView from './CollectionThumbnailView.js';
|
||||
import LockupMetadataView from './LockupMetadataView.js';
|
||||
import NavigationEndpoint from './NavigationEndpoint.js';
|
||||
|
||||
export default class LockupView extends YTNode {
|
||||
static type = 'LockupView';
|
||||
|
||||
content_image: CollectionThumbnailView | null;
|
||||
metadata: LockupMetadataView | null;
|
||||
content_id: string;
|
||||
content_type: 'SOURCE' | 'PLAYLIST' | 'ALBUM' | 'PODCAST' | 'SHOPPING_COLLECTION' | 'SHORT' | 'GAME' | 'PRODUCT';
|
||||
on_tap_endpoint: NavigationEndpoint;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.content_image = Parser.parseItem(data.contentImage, CollectionThumbnailView);
|
||||
this.metadata = Parser.parseItem(data.metadata, LockupMetadataView);
|
||||
this.content_id = data.contentId;
|
||||
this.content_type = data.contentType.replace('LOCKUP_CONTENT_TYPE_', '');
|
||||
this.on_tap_endpoint = new NavigationEndpoint(data.rendererContext.commandContext.onTap);
|
||||
}
|
||||
}
|
||||
19
src/parser/classes/ModalWithTitleAndButton.ts
Normal file
19
src/parser/classes/ModalWithTitleAndButton.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import Button from './Button.js';
|
||||
import Text from './misc/Text.js';
|
||||
|
||||
export default class ModalWithTitleAndButton extends YTNode {
|
||||
static type = 'ModalWithTitleAndButton';
|
||||
|
||||
title: Text;
|
||||
content: Text;
|
||||
button: Button | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.content = new Text(data.content);
|
||||
this.button = Parser.parseItem(data.button, Button);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { YTNode } from '../helpers.js';
|
||||
import { isTextRun, timeToSeconds } from '../../utils/Utils.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import type TextRun from './misc/TextRun.js';
|
||||
|
||||
import { Parser } from '../index.js';
|
||||
import MusicItemThumbnailOverlay from './MusicItemThumbnailOverlay.js';
|
||||
@@ -25,7 +26,7 @@ export default class MusicResponsiveListItem extends YTNode {
|
||||
};
|
||||
|
||||
endpoint?: NavigationEndpoint;
|
||||
item_type: 'album' | 'playlist' | 'artist' | 'library_artist' | 'non_music_track' | 'video' | 'song' | 'endpoint' | 'unknown' | undefined;
|
||||
item_type: 'album' | 'playlist' | 'artist' | 'library_artist' | 'non_music_track' | 'video' | 'song' | 'endpoint' | 'unknown' | 'podcast_show' | undefined;
|
||||
index?: Text;
|
||||
thumbnail?: MusicThumbnail | null;
|
||||
badges;
|
||||
@@ -120,6 +121,10 @@ export default class MusicResponsiveListItem extends YTNode {
|
||||
this.item_type = 'non_music_track';
|
||||
this.#parseNonMusicTrack();
|
||||
break;
|
||||
case 'MUSIC_PAGE_TYPE_PODCAST_SHOW_DETAIL_PAGE':
|
||||
this.item_type = 'podcast_show';
|
||||
this.#parsePodcastShow();
|
||||
break;
|
||||
default:
|
||||
if (this.flex_columns[1]) {
|
||||
this.#parseVideoOrSong();
|
||||
@@ -160,13 +165,19 @@ export default class MusicResponsiveListItem extends YTNode {
|
||||
}
|
||||
|
||||
#parseVideoOrSong() {
|
||||
const is_video = this.flex_columns.at(1)?.title.runs?.some((run) => run.text.match(/(.*?) views/));
|
||||
if (is_video) {
|
||||
this.item_type = 'video';
|
||||
this.#parseVideo();
|
||||
} else {
|
||||
this.item_type = 'song';
|
||||
this.#parseSong();
|
||||
const music_video_type = (this.flex_columns.at(0)?.title.runs?.at(0) as TextRun)?.endpoint?.payload?.watchEndpointMusicSupportedConfigs?.watchEndpointMusicConfig?.musicVideoType;
|
||||
switch (music_video_type) {
|
||||
case 'MUSIC_VIDEO_TYPE_UGC':
|
||||
case 'MUSIC_VIDEO_TYPE_OMV':
|
||||
this.item_type = 'video';
|
||||
this.#parseVideo();
|
||||
break;
|
||||
case 'MUSIC_VIDEO_TYPE_ATV':
|
||||
this.item_type = 'song';
|
||||
this.#parseSong();
|
||||
break;
|
||||
default:
|
||||
this.#parseOther();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +278,11 @@ export default class MusicResponsiveListItem extends YTNode {
|
||||
this.title = this.flex_columns.first().title.toString();
|
||||
}
|
||||
|
||||
#parsePodcastShow() {
|
||||
this.id = this.endpoint?.payload?.browseId;
|
||||
this.title = this.flex_columns.first().title.toString();
|
||||
}
|
||||
|
||||
#parseAlbum() {
|
||||
this.id = this.endpoint?.payload?.browseId;
|
||||
this.title = this.flex_columns.first().title.toString();
|
||||
|
||||
@@ -4,6 +4,7 @@ import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import type { IParsedResponse } from '../types/ParsedResponse.js';
|
||||
import CreatePlaylistDialog from './CreatePlaylistDialog.js';
|
||||
import type ModalWithTitleAndButton from './ModalWithTitleAndButton.js';
|
||||
import OpenPopupAction from './actions/OpenPopupAction.js';
|
||||
|
||||
export default class NavigationEndpoint extends YTNode {
|
||||
@@ -11,8 +12,11 @@ export default class NavigationEndpoint extends YTNode {
|
||||
|
||||
payload;
|
||||
dialog?: CreatePlaylistDialog | YTNode | null;
|
||||
modal?: ModalWithTitleAndButton | YTNode | null;
|
||||
open_popup?: OpenPopupAction | null;
|
||||
|
||||
next_endpoint?: NavigationEndpoint;
|
||||
|
||||
metadata: {
|
||||
url?: string;
|
||||
api_url?: string;
|
||||
@@ -41,6 +45,13 @@ export default class NavigationEndpoint extends YTNode {
|
||||
this.dialog = Parser.parseItem(this.payload.dialog || this.payload.content);
|
||||
}
|
||||
|
||||
if (Reflect.has(this.payload, 'modal')) {
|
||||
this.modal = Parser.parseItem(this.payload.modal);
|
||||
}
|
||||
|
||||
if (Reflect.has(this.payload, 'nextEndpoint')) {
|
||||
this.next_endpoint = new NavigationEndpoint(this.payload.nextEndpoint);
|
||||
}
|
||||
|
||||
if (data?.serviceEndpoint) {
|
||||
data = data.serviceEndpoint;
|
||||
|
||||
@@ -5,6 +5,9 @@ import ContentPreviewImageView from './ContentPreviewImageView.js';
|
||||
import DecoratedAvatarView from './DecoratedAvatarView.js';
|
||||
import DynamicTextView from './DynamicTextView.js';
|
||||
import FlexibleActionsView from './FlexibleActionsView.js';
|
||||
import DescriptionPreviewView from './DescriptionPreviewView.js';
|
||||
import AttributionView from './AttributionView.js';
|
||||
import ImageBannerView from './ImageBannerView.js';
|
||||
|
||||
export default class PageHeaderView extends YTNode {
|
||||
static type = 'PageHeaderView';
|
||||
@@ -13,6 +16,9 @@ export default class PageHeaderView extends YTNode {
|
||||
image: ContentPreviewImageView | DecoratedAvatarView | null;
|
||||
metadata: ContentMetadataView | null;
|
||||
actions: FlexibleActionsView | null;
|
||||
description: DescriptionPreviewView | null;
|
||||
attributation: AttributionView | null;
|
||||
banner: ImageBannerView | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
@@ -20,5 +26,8 @@ export default class PageHeaderView extends YTNode {
|
||||
this.image = Parser.parseItem(data.image, [ ContentPreviewImageView, DecoratedAvatarView ]);
|
||||
this.metadata = Parser.parseItem(data.metadata, ContentMetadataView);
|
||||
this.actions = Parser.parseItem(data.actions, FlexibleActionsView);
|
||||
this.description = Parser.parseItem(data.description, DescriptionPreviewView);
|
||||
this.attributation = Parser.parseItem(data.attributation, AttributionView);
|
||||
this.banner = Parser.parseItem(data.banner, ImageBannerView);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ export default class PlayerCaptionsTracklist extends YTNode {
|
||||
name: Text;
|
||||
vss_id: string;
|
||||
language_code: string;
|
||||
kind: string;
|
||||
kind?: 'asr' | 'frc';
|
||||
is_translatable: boolean;
|
||||
}[];
|
||||
|
||||
|
||||
@@ -1,11 +1,32 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
|
||||
export interface LiveStoryboardData {
|
||||
type: 'live',
|
||||
template_url: string,
|
||||
thumbnail_width: number,
|
||||
thumbnail_height: number,
|
||||
columns: number,
|
||||
rows: number
|
||||
}
|
||||
|
||||
export default class PlayerLiveStoryboardSpec extends YTNode {
|
||||
static type = 'PlayerLiveStoryboardSpec';
|
||||
|
||||
constructor() {
|
||||
board: LiveStoryboardData;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
// TODO: A little bit different from PlayerLiveStoryboardSpec
|
||||
// https://i.ytimg.com/sb/5qap5aO4i9A/storyboard_live_90_2x2_b2/M$M.jpg?rs=AOn4CLC9s6IeOsw_gKvEbsbU9y-e2FVRTw#159#90#2#2
|
||||
|
||||
const [ template_url, thumbnail_width, thumbnail_height, columns, rows ] = data.spec.split('#');
|
||||
|
||||
this.board = {
|
||||
type: 'live',
|
||||
template_url,
|
||||
thumbnail_width: parseInt(thumbnail_width, 10),
|
||||
thumbnail_height: parseInt(thumbnail_height, 10),
|
||||
columns: parseInt(columns, 10),
|
||||
rows: parseInt(rows, 10)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ export default class PlayerMicroformat extends YTNode {
|
||||
upload_date: string;
|
||||
available_countries: string[];
|
||||
start_timestamp: Date | null;
|
||||
end_timestamp: Date | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
@@ -70,5 +71,6 @@ export default class PlayerMicroformat extends YTNode {
|
||||
this.upload_date = data.uploadDate;
|
||||
this.available_countries = data.availableCountries;
|
||||
this.start_timestamp = data.liveBroadcastDetails?.startTimestamp ? new Date(data.liveBroadcastDetails.startTimestamp) : null;
|
||||
this.end_timestamp = data.liveBroadcastDetails?.endTimestamp ? new Date(data.liveBroadcastDetails.endTimestamp) : null;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
|
||||
export interface StoryboardData {
|
||||
type: 'vod'
|
||||
template_url: string;
|
||||
thumbnail_width: number;
|
||||
thumbnail_height: number;
|
||||
@@ -31,6 +32,7 @@ export default class PlayerStoryboardSpec extends YTNode {
|
||||
const storyboard_count = Math.ceil(parseInt(thumbnail_count, 10) / (parseInt(columns, 10) * parseInt(rows, 10)));
|
||||
|
||||
return {
|
||||
type: 'vod',
|
||||
template_url: url.toString().replace('$L', i).replace('$N', name),
|
||||
thumbnail_width: parseInt(thumbnail_width, 10),
|
||||
thumbnail_height: parseInt(thumbnail_height, 10),
|
||||
|
||||
@@ -23,6 +23,7 @@ export default class PlaylistVideo extends YTNode {
|
||||
upcoming?: Date;
|
||||
video_info: Text;
|
||||
accessibility_label?: string;
|
||||
style?: string;
|
||||
|
||||
duration: {
|
||||
text: string;
|
||||
@@ -44,6 +45,10 @@ export default class PlaylistVideo extends YTNode {
|
||||
this.video_info = new Text(data.videoInfo);
|
||||
this.accessibility_label = data.title.accessibility.accessibilityData.label;
|
||||
|
||||
if (Reflect.has(data, 'style')) {
|
||||
this.style = data.style;
|
||||
}
|
||||
|
||||
const upcoming = data.upcomingEventData && Number(`${data.upcomingEventData.startTime}000`);
|
||||
if (upcoming) {
|
||||
this.upcoming = new Date(upcoming);
|
||||
|
||||
13
src/parser/classes/SortFilterHeader.ts
Normal file
13
src/parser/classes/SortFilterHeader.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, YTNodes, type RawNode } from '../index.js';
|
||||
|
||||
export default class SortFilterHeader extends YTNode {
|
||||
static type = 'SortFilterHeader';
|
||||
|
||||
filter_menu: YTNodes.SortFilterSubMenu | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.filter_menu = Parser.parseItem(data.filterMenu, YTNodes.SortFilterSubMenu);
|
||||
}
|
||||
}
|
||||
26
src/parser/classes/ThumbnailBadgeView.ts
Normal file
26
src/parser/classes/ThumbnailBadgeView.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
|
||||
export default class ThumbnailBadgeView extends YTNode {
|
||||
static type = 'ThumbnailBadgeView';
|
||||
|
||||
icon_name: string;
|
||||
text: string;
|
||||
badge_style: string;
|
||||
background_color: {
|
||||
light_theme: number;
|
||||
dark_theme: number;
|
||||
};
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.icon_name = data.icon.sources[0].clientResource.imageName;
|
||||
this.text = data.text;
|
||||
this.badge_style = data.badgeStyle;
|
||||
this.background_color = {
|
||||
light_theme: data.backgroundColor.lightTheme,
|
||||
dark_theme: data.backgroundColor.darkTheme
|
||||
};
|
||||
}
|
||||
}
|
||||
19
src/parser/classes/ThumbnailHoverOverlayView.ts
Normal file
19
src/parser/classes/ThumbnailHoverOverlayView.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
|
||||
export default class ThumbnailHoverOverlayView extends YTNode {
|
||||
static type = 'ThumbnailHoverOverlayView';
|
||||
|
||||
icon_name: string;
|
||||
text: Text;
|
||||
style: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.icon_name = data.icon.sources[0].clientResource.imageName;
|
||||
this.text = Text.fromAttributed(data.text);
|
||||
this.style = data.style;
|
||||
}
|
||||
}
|
||||
17
src/parser/classes/ThumbnailOverlayBadgeView.ts
Normal file
17
src/parser/classes/ThumbnailOverlayBadgeView.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import ThumbnailBadgeView from './ThumbnailBadgeView.js';
|
||||
|
||||
export default class ThumbnailOverlayBadgeView extends YTNode {
|
||||
static type = 'ThumbnailOverlayBadgeView';
|
||||
|
||||
badges: ThumbnailBadgeView[];
|
||||
position: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.badges = Parser.parseArray(data.thumbnailBadges, ThumbnailBadgeView);
|
||||
this.position = data.position;
|
||||
}
|
||||
}
|
||||
27
src/parser/classes/ThumbnailView.ts
Normal file
27
src/parser/classes/ThumbnailView.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { Parser, type RawNode } from '../index.js';
|
||||
import ThumbnailHoverOverlayView from './ThumbnailHoverOverlayView.js';
|
||||
import ThumbnailOverlayBadgeView from './ThumbnailOverlayBadgeView.js';
|
||||
import Thumbnail from './misc/Thumbnail.js';
|
||||
|
||||
export default class ThumbnailView extends YTNode {
|
||||
static type = 'ThumbnailView';
|
||||
|
||||
image: Thumbnail[];
|
||||
overlays: (ThumbnailOverlayBadgeView | ThumbnailHoverOverlayView)[];
|
||||
background_color: {
|
||||
light_theme: number;
|
||||
dark_theme: number;
|
||||
};
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.image = Thumbnail.fromResponse(data.image);
|
||||
this.overlays = Parser.parseArray(data.overlays, [ ThumbnailOverlayBadgeView, ThumbnailHoverOverlayView ]);
|
||||
this.background_color = {
|
||||
light_theme: data.backgroundColor.lightTheme,
|
||||
dark_theme: data.backgroundColor.darkTheme
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { Parser } from '../../index.js';
|
||||
import Button from '../Button.js';
|
||||
import ContinuationItem from '../ContinuationItem.js';
|
||||
import Comment from './Comment.js';
|
||||
import CommentView from './CommentView.js';
|
||||
import CommentReplies from './CommentReplies.js';
|
||||
|
||||
import { InnertubeError } from '../../../utils/Utils.js';
|
||||
@@ -17,15 +18,20 @@ export default class CommentThread extends YTNode {
|
||||
#actions?: Actions;
|
||||
#continuation?: ContinuationItem;
|
||||
|
||||
comment: Comment | null;
|
||||
replies?: ObservedArray<Comment>;
|
||||
comment: Comment | CommentView | null;
|
||||
replies?: ObservedArray<Comment | CommentView>;
|
||||
comment_replies_data: CommentReplies | null;
|
||||
is_moderated_elq_comment: boolean;
|
||||
has_replies: boolean;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.comment = Parser.parseItem(data.comment, Comment);
|
||||
|
||||
if (Reflect.has(data, 'commentViewModel')) {
|
||||
this.comment = Parser.parseItem(data.commentViewModel, CommentView);
|
||||
} else {
|
||||
this.comment = Parser.parseItem(data.comment, Comment);
|
||||
}
|
||||
this.comment_replies_data = Parser.parseItem(data.replies, CommentReplies);
|
||||
this.is_moderated_elq_comment = data.isModeratedElqComment;
|
||||
this.has_replies = !!this.comment_replies_data;
|
||||
@@ -51,7 +57,7 @@ export default class CommentThread extends YTNode {
|
||||
if (!response.on_response_received_endpoints_memo)
|
||||
throw new InnertubeError('Unexpected response.', response);
|
||||
|
||||
this.replies = observe(response.on_response_received_endpoints_memo.getType(Comment).map((comment) => {
|
||||
this.replies = observe(response.on_response_received_endpoints_memo.getType(Comment, CommentView).map((comment) => {
|
||||
comment.setActions(this.#actions);
|
||||
return comment;
|
||||
}));
|
||||
|
||||
88
src/parser/classes/comments/CommentView.ts
Normal file
88
src/parser/classes/comments/CommentView.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { YTNode } from '../../helpers.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
|
||||
import type Actions from '../../../core/Actions.js';
|
||||
import Author from '../misc/Author.js';
|
||||
import Text from '../misc/Text.js';
|
||||
|
||||
export default class CommentView extends YTNode {
|
||||
static type = 'CommentView';
|
||||
|
||||
#actions?: Actions;
|
||||
|
||||
comment_id: string;
|
||||
is_pinned: boolean;
|
||||
keys: {
|
||||
comment: string;
|
||||
comment_surface: string;
|
||||
toolbar_state: string;
|
||||
toolbar_surface: string;
|
||||
shared: string;
|
||||
};
|
||||
|
||||
content?: Text;
|
||||
published_time?: string;
|
||||
author_is_channel_owner?: boolean;
|
||||
like_count?: string;
|
||||
reply_count?: string;
|
||||
is_member?: boolean;
|
||||
member_badge?: {
|
||||
url: string,
|
||||
a11y: string;
|
||||
};
|
||||
author?: Author;
|
||||
|
||||
is_liked?: boolean;
|
||||
is_disliked?: boolean;
|
||||
is_hearted?: boolean;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.comment_id = data.commentId;
|
||||
this.is_pinned = !!data.pinnedText;
|
||||
|
||||
this.keys = {
|
||||
comment: data.commentKey,
|
||||
comment_surface: data.commentSurfaceKey,
|
||||
toolbar_state: data.toolbarStateKey,
|
||||
toolbar_surface: data.toolbarSurfaceKey,
|
||||
shared: data.sharedKey
|
||||
};
|
||||
}
|
||||
|
||||
applyMutations(comment?: RawNode, toolbar_state?: RawNode) {
|
||||
if (comment) {
|
||||
this.content = Text.fromAttributed(comment.properties.content);
|
||||
this.published_time = comment.properties.publishedTime;
|
||||
this.author_is_channel_owner = !!comment.author.isCreator;
|
||||
|
||||
this.like_count = comment.toolbar.likeCountNotliked ? comment.toolbar.likeCountNotliked : '0';
|
||||
this.reply_count = comment.toolbar.replyCount ? comment.toolbar.replyCount : '0';
|
||||
|
||||
this.is_member = !!comment.author.sponsorBadgeUrl;
|
||||
|
||||
if (Reflect.has(comment.author, 'sponsorBadgeUrl')) {
|
||||
this.member_badge = {
|
||||
url: comment.author.sponsorBadgeUrl,
|
||||
a11y: comment.author.A11y
|
||||
};
|
||||
}
|
||||
|
||||
this.author = new Author({
|
||||
simpleText: comment.author.displayName,
|
||||
navigationEndpoint: comment.avatar.endpoint
|
||||
}, comment.author, comment.avatar.image, comment.author.channelId);
|
||||
}
|
||||
|
||||
if (toolbar_state) {
|
||||
this.is_hearted = toolbar_state.heartState === 'TOOLBAR_HEART_STATE_HEARTED';
|
||||
this.is_liked = toolbar_state.likeState === 'TOOLBAR_LIKE_STATE_LIKED';
|
||||
this.is_disliked = toolbar_state.likeState === 'TOOLBAR_HEART_STATE_DISLIKED';
|
||||
}
|
||||
}
|
||||
|
||||
setActions(actions: Actions | undefined) {
|
||||
this.#actions = actions;
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,21 @@ export default class Author {
|
||||
this.name = nav_text?.text || 'N/A';
|
||||
this.thumbnails = thumbs ? Thumbnail.fromResponse(thumbs) : [];
|
||||
this.endpoint = ((nav_text?.runs?.[0] as TextRun) as TextRun)?.endpoint || nav_text?.endpoint;
|
||||
this.badges = Array.isArray(badges) ? Parser.parseArray(badges) : observe([] as YTNode[]);
|
||||
this.is_moderator = this.badges?.some((badge: any) => badge.icon_type == 'MODERATOR');
|
||||
this.is_verified = this.badges?.some((badge: any) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED');
|
||||
this.is_verified_artist = this.badges?.some((badge: any) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED_ARTIST');
|
||||
|
||||
if (badges) {
|
||||
if (Array.isArray(badges)) {
|
||||
this.badges = Parser.parseArray(badges);
|
||||
this.is_moderator = this.badges?.some((badge: any) => badge.icon_type == 'MODERATOR');
|
||||
this.is_verified = this.badges?.some((badge: any) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED');
|
||||
this.is_verified_artist = this.badges?.some((badge: any) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED_ARTIST');
|
||||
} else {
|
||||
this.badges = observe([] as YTNode[]);
|
||||
this.is_verified = !!badges.isVerified;
|
||||
this.is_verified_artist = !!badges.isArtist;
|
||||
}
|
||||
} else {
|
||||
this.badges = observe([] as YTNode[]);
|
||||
}
|
||||
|
||||
// @TODO: Refactor this mess.
|
||||
this.url =
|
||||
|
||||
@@ -16,6 +16,7 @@ export default class EmojiRun implements Run {
|
||||
this.text =
|
||||
data.emoji?.emojiId ||
|
||||
data.emoji?.shortcuts?.[0] ||
|
||||
data.text ||
|
||||
'';
|
||||
|
||||
this.emoji = {
|
||||
|
||||
@@ -41,8 +41,11 @@ export default class Format {
|
||||
audio_sample_rate?: number;
|
||||
audio_channels?: number;
|
||||
loudness_db?: number;
|
||||
max_dvr_duration_sec?: number;
|
||||
target_duration_dec?: number;
|
||||
has_audio: boolean;
|
||||
has_video: boolean;
|
||||
has_text: boolean;
|
||||
language?: string | null;
|
||||
is_dubbed?: boolean;
|
||||
is_descriptive?: boolean;
|
||||
@@ -54,6 +57,14 @@ export default class Format {
|
||||
matrix_coefficients?: string;
|
||||
};
|
||||
|
||||
caption_track?: {
|
||||
display_name: string;
|
||||
vss_id: string;
|
||||
language_code: string;
|
||||
kind?: 'asr' | 'frc';
|
||||
id: string;
|
||||
};
|
||||
|
||||
constructor(data: RawNode, this_response_nsig_cache?: Map<string, string>) {
|
||||
if (this_response_nsig_cache) {
|
||||
this.#this_response_nsig_cache = this_response_nsig_cache;
|
||||
@@ -90,8 +101,11 @@ export default class Format {
|
||||
this.audio_sample_rate = parseInt(data.audioSampleRate);
|
||||
this.audio_channels = data.audioChannels;
|
||||
this.loudness_db = data.loudnessDb;
|
||||
this.max_dvr_duration_sec = data.maxDvrDurationSec;
|
||||
this.target_duration_dec = data.targetDurationSec;
|
||||
this.has_audio = !!data.audioBitrate || !!data.audioQuality;
|
||||
this.has_video = !!data.qualityLabel;
|
||||
this.has_text = !!data.captionTrack;
|
||||
|
||||
this.color_info = data.colorInfo ? {
|
||||
primaries: data.colorInfo.primaries?.replace('COLOR_PRIMARIES_', ''),
|
||||
@@ -99,25 +113,42 @@ export default class Format {
|
||||
matrix_coefficients: data.colorInfo.matrixCoefficients?.replace('COLOR_MATRIX_COEFFICIENTS_', '')
|
||||
} : undefined;
|
||||
|
||||
if (this.has_audio) {
|
||||
if (Reflect.has(data, 'audioTrack')) {
|
||||
this.audio_track = {
|
||||
audio_is_default: data.audioTrack.audioIsDefault,
|
||||
display_name: data.audioTrack.displayName,
|
||||
id: data.audioTrack.id
|
||||
};
|
||||
}
|
||||
|
||||
if (Reflect.has(data, 'captionTrack')) {
|
||||
this.caption_track = {
|
||||
display_name: data.captionTrack.displayName,
|
||||
vss_id: data.captionTrack.vssId,
|
||||
language_code: data.captionTrack.languageCode,
|
||||
kind: data.captionTrack.kind,
|
||||
id: data.captionTrack.id
|
||||
};
|
||||
}
|
||||
|
||||
if (this.has_audio || this.has_text) {
|
||||
const args = new URLSearchParams(this.cipher || this.signature_cipher);
|
||||
const url_components = new URLSearchParams(args.get('url') || this.url);
|
||||
|
||||
const xtags = url_components.get('xtags')?.split(':');
|
||||
|
||||
const audio_content = xtags?.find((x) => x.startsWith('acont='))?.split('=')[1];
|
||||
|
||||
this.language = xtags?.find((x: string) => x.startsWith('lang='))?.split('=')[1] || null;
|
||||
this.is_dubbed = audio_content === 'dubbed';
|
||||
this.is_descriptive = audio_content === 'descriptive';
|
||||
this.is_original = audio_content === 'original' || (!this.is_dubbed && !this.is_descriptive);
|
||||
|
||||
if (Reflect.has(data, 'audioTrack')) {
|
||||
this.audio_track = {
|
||||
audio_is_default: data.audioTrack.audioIsDefault,
|
||||
display_name: data.audioTrack.displayName,
|
||||
id: data.audioTrack.id
|
||||
};
|
||||
if (this.has_audio) {
|
||||
const audio_content = xtags?.find((x) => x.startsWith('acont='))?.split('=')[1];
|
||||
this.is_dubbed = audio_content === 'dubbed';
|
||||
this.is_descriptive = audio_content === 'descriptive';
|
||||
this.is_original = audio_content === 'original' || (!this.is_dubbed && !this.is_descriptive);
|
||||
}
|
||||
|
||||
// Some text tracks don't have xtags while others do
|
||||
if (this.has_text && !this.language && this.caption_track) {
|
||||
this.language = this.caption_track.language_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Log } from '../../../utils/index.js';
|
||||
import type { RawNode } from '../../index.js';
|
||||
import NavigationEndpoint from '../NavigationEndpoint.js';
|
||||
import EmojiRun from './EmojiRun.js';
|
||||
@@ -18,6 +19,10 @@ export function escape(text: string) {
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
// Place this here, instead of in a private static property,
|
||||
// To avoid the performance penalty of the private field polyfill
|
||||
const TAG = 'Text';
|
||||
|
||||
export default class Text {
|
||||
text?: string;
|
||||
runs?: (EmojiRun | TextRun)[];
|
||||
@@ -46,73 +51,132 @@ export default class Text {
|
||||
}
|
||||
}
|
||||
|
||||
static fromAttributed(data: RawNode): Text {
|
||||
const runs: {
|
||||
text: string,
|
||||
navigationEndpoint?: RawNode,
|
||||
attachment?: RawNode
|
||||
}[] = [];
|
||||
static fromAttributed(data: AttributedText) {
|
||||
const {
|
||||
content,
|
||||
styleRuns: style_runs,
|
||||
commandRuns: command_runs,
|
||||
attachmentRuns: attachment_runs
|
||||
} = data;
|
||||
|
||||
const content = data.content;
|
||||
const command_runs = data.commandRuns;
|
||||
const runs: RawRun[] = [
|
||||
{
|
||||
text: content,
|
||||
startIndex: 0
|
||||
}
|
||||
];
|
||||
|
||||
// Haven't found an actually useful one yet, but they look like this:
|
||||
// [ { startIndex: 0, length: 19 } ] (for a string that is 19 characters long)
|
||||
// Const style_runs = data.styleRuns;
|
||||
if (style_runs || command_runs || attachment_runs) {
|
||||
if (style_runs) {
|
||||
for (const style_run of style_runs) {
|
||||
if (
|
||||
style_run.italic ||
|
||||
style_run.strikethrough === 'LINE_STYLE_SINGLE' ||
|
||||
style_run.weightLabel === 'FONT_WEIGHT_MEDIUM' ||
|
||||
style_run.weightLabel === 'FONT_WEIGHT_BOLD'
|
||||
) {
|
||||
const matching_run = findMatchingRun(runs, style_run);
|
||||
|
||||
let last_end_index = 0;
|
||||
if (!matching_run) {
|
||||
Log.warn(TAG, 'Unable to find matching run for style run. Skipping...', {
|
||||
style_run,
|
||||
input_data: data,
|
||||
// For performance reasons, web browser consoles only expand an object, when the user clicks on it,
|
||||
// So if we log the original runs object, it might have changed by the time the user looks at it.
|
||||
// Deep clone, so that we log the exact state of the runs at this point.
|
||||
parsed_runs: JSON.parse(JSON.stringify(runs))
|
||||
});
|
||||
|
||||
if (command_runs) {
|
||||
for (const item of command_runs) {
|
||||
const length: number = item.length;
|
||||
const start_index: number = item.startIndex;
|
||||
|
||||
if (start_index > last_end_index) {
|
||||
runs.push({
|
||||
text: content.slice(last_end_index, start_index)
|
||||
});
|
||||
}
|
||||
|
||||
if (Reflect.has(item, 'onTap')) {
|
||||
let attachment = null;
|
||||
|
||||
if (Reflect.has(data, 'attachmentRuns')) {
|
||||
const attachment_runs = data.attachmentRuns;
|
||||
|
||||
for (const attatchment_run of attachment_runs) {
|
||||
if ((attatchment_run.startIndex - 2) == start_index) {
|
||||
attachment = attatchment_run;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (attachment) {
|
||||
runs.push({
|
||||
text: content.slice(start_index, start_index + length),
|
||||
navigationEndpoint: item.onTap,
|
||||
attachment
|
||||
// Comments use MEDIUM for bold text and video descriptions use BOLD for bold text
|
||||
insertSubRun(runs, matching_run, style_run, {
|
||||
bold: style_run.weightLabel === 'FONT_WEIGHT_MEDIUM' || style_run.weightLabel === 'FONT_WEIGHT_BOLD',
|
||||
italics: style_run.italic,
|
||||
strikethrough: style_run.strikethrough === 'LINE_STYLE_SINGLE'
|
||||
});
|
||||
} else {
|
||||
runs.push({
|
||||
text: content.slice(start_index, start_index + length),
|
||||
navigationEndpoint: item.onTap
|
||||
Log.debug(TAG, 'Skipping style run as it is doesn\'t have any information that we parse.', {
|
||||
style_run,
|
||||
input_data: data
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
last_end_index = start_index + length;
|
||||
}
|
||||
|
||||
if (last_end_index < content.length) {
|
||||
runs.push({
|
||||
text: content.slice(last_end_index)
|
||||
});
|
||||
if (command_runs) {
|
||||
for (const command_run of command_runs) {
|
||||
if (command_run.onTap) {
|
||||
const matching_run = findMatchingRun(runs, command_run);
|
||||
|
||||
if (!matching_run) {
|
||||
Log.warn(TAG, 'Unable to find matching run for command run. Skipping...', {
|
||||
command_run,
|
||||
input_data: data,
|
||||
// For performance reasons, web browser consoles only expand an object, when the user clicks on it,
|
||||
// So if we log the original runs object, it might have changed by the time the user looks at it.
|
||||
// Deep clone, so that we log the exact state of the runs at this point.
|
||||
parsed_runs: JSON.parse(JSON.stringify(runs))
|
||||
});
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
insertSubRun(runs, matching_run, command_run, {
|
||||
navigationEndpoint: command_run.onTap
|
||||
});
|
||||
} else {
|
||||
Log.debug(TAG, 'Skipping command run as it is missing the "doTap" property.', {
|
||||
command_run,
|
||||
input_data: data
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attachment_runs) {
|
||||
for (const attachment_run of attachment_runs) {
|
||||
const matching_run = findMatchingRun(runs, attachment_run);
|
||||
|
||||
if (!matching_run) {
|
||||
Log.warn(TAG, 'Unable to find matching run for attachment run. Skipping...', {
|
||||
attachment_run,
|
||||
input_data: data,
|
||||
// For performance reasons, web browser consoles only expand an object, when the user clicks on it,
|
||||
// So if we log the original runs object, it might have changed by the time the user looks at it.
|
||||
// Deep clone, so that we log the exact state of the runs at this point.
|
||||
parsed_runs: JSON.parse(JSON.stringify(runs))
|
||||
});
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attachment_run.length === 0) {
|
||||
matching_run.attachment = attachment_run;
|
||||
} else {
|
||||
const offset_start_index = attachment_run.startIndex - matching_run.startIndex;
|
||||
|
||||
const text = matching_run.text.substring(offset_start_index, offset_start_index + attachment_run.length);
|
||||
|
||||
const is_custom_emoji = (/^:[^:]+:$/).test(text);
|
||||
|
||||
if (attachment_run.element?.type?.imageType?.image && (is_custom_emoji || (/^(?:\p{Emoji}|\u200d)+$/u).test(text))) {
|
||||
const emoji = {
|
||||
image: attachment_run.element.type.imageType.image,
|
||||
isCustomEmoji: is_custom_emoji,
|
||||
shortcuts: is_custom_emoji ? [ text ] : undefined
|
||||
};
|
||||
|
||||
insertSubRun(runs, matching_run, attachment_run, { emoji });
|
||||
} else {
|
||||
insertSubRun(runs, matching_run, attachment_run, {
|
||||
attachment: attachment_run
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
runs.push({
|
||||
text: content
|
||||
});
|
||||
}
|
||||
|
||||
return new Text({ runs });
|
||||
@@ -141,4 +205,100 @@ export default class Text {
|
||||
toString(): string {
|
||||
return this.text || 'N/A';
|
||||
}
|
||||
}
|
||||
|
||||
function findMatchingRun(runs: RawRun[], response_run: ResponseRun) {
|
||||
return runs.find((run) => {
|
||||
return run.startIndex <= response_run.startIndex &&
|
||||
response_run.startIndex + response_run.length <= run.startIndex + run.text.length;
|
||||
});
|
||||
}
|
||||
|
||||
function insertSubRun(runs: RawRun[], original_run: RawRun, response_run: ResponseRun, properties_to_add: Omit<RawRun, 'text' | 'startIndex'>) {
|
||||
const replace_index = runs.indexOf(original_run);
|
||||
const replacement_runs = [];
|
||||
|
||||
const offset_start_index = response_run.startIndex - original_run.startIndex;
|
||||
|
||||
// Stuff before the run
|
||||
if (response_run.startIndex > original_run.startIndex) {
|
||||
replacement_runs.push({
|
||||
...original_run,
|
||||
text: original_run.text.substring(0, offset_start_index)
|
||||
});
|
||||
}
|
||||
|
||||
replacement_runs.push({
|
||||
...original_run,
|
||||
text: original_run.text.substring(offset_start_index, offset_start_index + response_run.length),
|
||||
startIndex: response_run.startIndex,
|
||||
...properties_to_add
|
||||
});
|
||||
|
||||
// Stuff after the run
|
||||
if (response_run.startIndex + response_run.length < original_run.startIndex + original_run.text.length) {
|
||||
replacement_runs.push({
|
||||
...original_run,
|
||||
text: original_run.text.substring(offset_start_index + response_run.length),
|
||||
startIndex: response_run.startIndex + response_run.length
|
||||
});
|
||||
}
|
||||
|
||||
runs.splice(replace_index, 1, ...replacement_runs);
|
||||
}
|
||||
|
||||
interface RawRun {
|
||||
text: string,
|
||||
bold?: boolean;
|
||||
italics?: boolean;
|
||||
strikethrough?: boolean;
|
||||
navigationEndpoint?: RawNode;
|
||||
attachment?: RawNode;
|
||||
emoji?: RawNode;
|
||||
startIndex: number;
|
||||
}
|
||||
|
||||
interface AttributedText {
|
||||
content: string;
|
||||
styleRuns?: StyleRun[];
|
||||
commandRuns?: CommandRun[];
|
||||
attachmentRuns?: AttachmentRun[];
|
||||
decorationRuns?: ResponseRun[];
|
||||
}
|
||||
|
||||
interface ResponseRun {
|
||||
startIndex: number;
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface StyleRun extends ResponseRun {
|
||||
italic?: boolean;
|
||||
weightLabel?: string;
|
||||
strikethrough?: string;
|
||||
fontFamilyName?: string;
|
||||
styleRunExtensions?: {
|
||||
styleRunColorMapExtension?: {
|
||||
colorMap?: {
|
||||
key: string,
|
||||
value: number
|
||||
}[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface CommandRun extends ResponseRun {
|
||||
onTap?: RawNode;
|
||||
}
|
||||
|
||||
interface AttachmentRun extends ResponseRun {
|
||||
alignment?: string;
|
||||
element?: {
|
||||
type?: {
|
||||
imageType?: {
|
||||
image: RawNode,
|
||||
playbackState?: string;
|
||||
}
|
||||
};
|
||||
properties?: RawNode
|
||||
};
|
||||
}
|
||||
@@ -16,9 +16,12 @@ export default class VideoDetails {
|
||||
is_private: boolean;
|
||||
is_live: boolean;
|
||||
is_live_content: boolean;
|
||||
is_live_dvr_enabled: boolean;
|
||||
is_upcoming: boolean;
|
||||
is_crawlable: boolean;
|
||||
is_post_live_dvr: boolean;
|
||||
is_low_latency_live_stream: boolean;
|
||||
live_chunk_readahead?: number;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
this.id = data.videoId;
|
||||
@@ -35,8 +38,11 @@ export default class VideoDetails {
|
||||
this.is_private = !!data.isPrivate;
|
||||
this.is_live = !!data.isLive;
|
||||
this.is_live_content = !!data.isLiveContent;
|
||||
this.is_live_dvr_enabled = !!data.isLiveDvrEnabled;
|
||||
this.is_low_latency_live_stream = !!data.isLowLatencyLiveStream;
|
||||
this.is_upcoming = !!data.isUpcoming;
|
||||
this.is_post_live_dvr = !!data.isPostLiveDvr;
|
||||
this.is_crawlable = !!data.isCrawlable;
|
||||
this.live_chunk_readahead = data.liveChunkReadahead;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import type { ObservedArray } from './helpers.js';
|
||||
import { YTNode, observe } from './helpers.js';
|
||||
import type { RawNode } from './index.js';
|
||||
import { Thumbnail } from './misc.js';
|
||||
import { NavigationEndpoint, LiveChatItemList, LiveChatHeader, LiveChatParticipantsList, Message } from './nodes.js';
|
||||
import * as Parser from './parser.js';
|
||||
|
||||
import type { RawNode } from './index.js';
|
||||
import type { ObservedArray } from './helpers.js';
|
||||
|
||||
export class ItemSectionContinuation extends YTNode {
|
||||
static readonly type = 'itemSectionContinuation';
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
/* eslint-disable no-cond-assign */
|
||||
import { YTNode } from './helpers.js';
|
||||
import * as Parser from './parser.js';
|
||||
import { InnertubeError } from '../utils/Utils.js';
|
||||
|
||||
import Author from './classes/misc/Author.js';
|
||||
import Text from './classes/misc/Text.js';
|
||||
import Thumbnail from './classes/misc/Thumbnail.js';
|
||||
import NavigationEndpoint from './classes/NavigationEndpoint.js';
|
||||
|
||||
import type { YTNodeConstructor } from './helpers.js';
|
||||
import { YTNode } from './helpers.js';
|
||||
import * as Parser from './parser.js';
|
||||
|
||||
export type MiscInferenceType = {
|
||||
type: 'misc',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import Log from '../utils/Log.js';
|
||||
import { deepCompare, ParsingError } from '../utils/Utils.js';
|
||||
|
||||
const isObserved = Symbol('ObservedArray.isObserved');
|
||||
@@ -62,6 +63,7 @@ export class YTNode {
|
||||
}
|
||||
|
||||
export class Maybe {
|
||||
#TAG = 'Maybe';
|
||||
#value;
|
||||
|
||||
constructor (value: any) {
|
||||
@@ -275,10 +277,11 @@ export class Maybe {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This call is not meant to be used outside of debugging. Please use the specific type getter instead.
|
||||
* @deprecated
|
||||
* This call is not meant to be used outside of debugging. Please use the specific type getter instead.
|
||||
*/
|
||||
any(): any {
|
||||
console.warn('This call is not meant to be used outside of debugging. Please use the specific type getter instead.');
|
||||
Log.warn(this.#TAG, 'This call is not meant to be used outside of debugging. Please use the specific type getter instead.');
|
||||
return this.#value;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ export { default as AnalyticsVodCarouselCard } from './classes/analytics/Analyti
|
||||
export { default as CtaGoToCreatorStudio } from './classes/analytics/CtaGoToCreatorStudio.js';
|
||||
export { default as DataModelSection } from './classes/analytics/DataModelSection.js';
|
||||
export { default as StatRow } from './classes/analytics/StatRow.js';
|
||||
export { default as AttributionView } from './classes/AttributionView.js';
|
||||
export { default as AudioOnlyPlayability } from './classes/AudioOnlyPlayability.js';
|
||||
export { default as AutomixPreviewVideo } from './classes/AutomixPreviewVideo.js';
|
||||
export { default as AvatarView } from './classes/AvatarView.js';
|
||||
@@ -63,6 +64,7 @@ export { default as ClipCreationTextInput } from './classes/ClipCreationTextInpu
|
||||
export { default as ClipSection } from './classes/ClipSection.js';
|
||||
export { default as CollaboratorInfoCardContent } from './classes/CollaboratorInfoCardContent.js';
|
||||
export { default as CollageHeroImage } from './classes/CollageHeroImage.js';
|
||||
export { default as CollectionThumbnailView } from './classes/CollectionThumbnailView.js';
|
||||
export { default as Command } from './classes/Command.js';
|
||||
export { default as AuthorCommentBadge } from './classes/comments/AuthorCommentBadge.js';
|
||||
export { default as Comment } from './classes/comments/Comment.js';
|
||||
@@ -76,6 +78,7 @@ export { default as CommentsHeader } from './classes/comments/CommentsHeader.js'
|
||||
export { default as CommentSimplebox } from './classes/comments/CommentSimplebox.js';
|
||||
export { default as CommentsSimplebox } from './classes/comments/CommentsSimplebox.js';
|
||||
export { default as CommentThread } from './classes/comments/CommentThread.js';
|
||||
export { default as CommentView } from './classes/comments/CommentView.js';
|
||||
export { default as CreatorHeart } from './classes/comments/CreatorHeart.js';
|
||||
export { default as EmojiPicker } from './classes/comments/EmojiPicker.js';
|
||||
export { default as PdgCommentChip } from './classes/comments/PdgCommentChip.js';
|
||||
@@ -97,6 +100,7 @@ export { default as CreatePlaylistDialog } from './classes/CreatePlaylistDialog.
|
||||
export { default as DecoratedAvatarView } from './classes/DecoratedAvatarView.js';
|
||||
export { default as DecoratedPlayerBar } from './classes/DecoratedPlayerBar.js';
|
||||
export { default as DefaultPromoPanel } from './classes/DefaultPromoPanel.js';
|
||||
export { default as DescriptionPreviewView } from './classes/DescriptionPreviewView.js';
|
||||
export { default as DidYouMean } from './classes/DidYouMean.js';
|
||||
export { default as DislikeButtonView } from './classes/DislikeButtonView.js';
|
||||
export { default as DownloadButton } from './classes/DownloadButton.js';
|
||||
@@ -151,6 +155,7 @@ export { default as HorizontalCardList } from './classes/HorizontalCardList.js';
|
||||
export { default as HorizontalList } from './classes/HorizontalList.js';
|
||||
export { default as HorizontalMovieList } from './classes/HorizontalMovieList.js';
|
||||
export { default as IconLink } from './classes/IconLink.js';
|
||||
export { default as ImageBannerView } from './classes/ImageBannerView.js';
|
||||
export { default as IncludingResultsFor } from './classes/IncludingResultsFor.js';
|
||||
export { default as InfoPanelContainer } from './classes/InfoPanelContainer.js';
|
||||
export { default as InfoPanelContent } from './classes/InfoPanelContent.js';
|
||||
@@ -207,6 +212,8 @@ export { default as LiveChatItemList } from './classes/LiveChatItemList.js';
|
||||
export { default as LiveChatMessageInput } from './classes/LiveChatMessageInput.js';
|
||||
export { default as LiveChatParticipant } from './classes/LiveChatParticipant.js';
|
||||
export { default as LiveChatParticipantsList } from './classes/LiveChatParticipantsList.js';
|
||||
export { default as LockupMetadataView } from './classes/LockupMetadataView.js';
|
||||
export { default as LockupView } from './classes/LockupView.js';
|
||||
export { default as MacroMarkersInfoItem } from './classes/MacroMarkersInfoItem.js';
|
||||
export { default as MacroMarkersList } from './classes/MacroMarkersList.js';
|
||||
export { default as MacroMarkersListItem } from './classes/MacroMarkersListItem.js';
|
||||
@@ -231,6 +238,7 @@ export { default as MetadataRowHeader } from './classes/MetadataRowHeader.js';
|
||||
export { default as MetadataScreen } from './classes/MetadataScreen.js';
|
||||
export { default as MicroformatData } from './classes/MicroformatData.js';
|
||||
export { default as Mix } from './classes/Mix.js';
|
||||
export { default as ModalWithTitleAndButton } from './classes/ModalWithTitleAndButton.js';
|
||||
export { default as Movie } from './classes/Movie.js';
|
||||
export { default as MovingThumbnail } from './classes/MovingThumbnail.js';
|
||||
export { default as MultiMarkersPlayerBar } from './classes/MultiMarkersPlayerBar.js';
|
||||
@@ -351,6 +359,7 @@ export { default as SingleColumnMusicWatchNextResults } from './classes/SingleCo
|
||||
export { default as SingleHeroImage } from './classes/SingleHeroImage.js';
|
||||
export { default as SlimOwner } from './classes/SlimOwner.js';
|
||||
export { default as SlimVideoMetadata } from './classes/SlimVideoMetadata.js';
|
||||
export { default as SortFilterHeader } from './classes/SortFilterHeader.js';
|
||||
export { default as SortFilterSubMenu } from './classes/SortFilterSubMenu.js';
|
||||
export { default as StructuredDescriptionContent } from './classes/StructuredDescriptionContent.js';
|
||||
export { default as StructuredDescriptionPlaylistLockup } from './classes/StructuredDescriptionPlaylistLockup.js';
|
||||
@@ -362,7 +371,10 @@ export { default as Tab } from './classes/Tab.js';
|
||||
export { default as Tabbed } from './classes/Tabbed.js';
|
||||
export { default as TabbedSearchResults } from './classes/TabbedSearchResults.js';
|
||||
export { default as TextHeader } from './classes/TextHeader.js';
|
||||
export { default as ThumbnailBadgeView } from './classes/ThumbnailBadgeView.js';
|
||||
export { default as ThumbnailHoverOverlayView } from './classes/ThumbnailHoverOverlayView.js';
|
||||
export { default as ThumbnailLandscapePortrait } from './classes/ThumbnailLandscapePortrait.js';
|
||||
export { default as ThumbnailOverlayBadgeView } from './classes/ThumbnailOverlayBadgeView.js';
|
||||
export { default as ThumbnailOverlayBottomPanel } from './classes/ThumbnailOverlayBottomPanel.js';
|
||||
export { default as ThumbnailOverlayEndorsement } from './classes/ThumbnailOverlayEndorsement.js';
|
||||
export { default as ThumbnailOverlayHoverText } from './classes/ThumbnailOverlayHoverText.js';
|
||||
@@ -375,6 +387,7 @@ export { default as ThumbnailOverlayResumePlayback } from './classes/ThumbnailOv
|
||||
export { default as ThumbnailOverlaySidePanel } from './classes/ThumbnailOverlaySidePanel.js';
|
||||
export { default as ThumbnailOverlayTimeStatus } from './classes/ThumbnailOverlayTimeStatus.js';
|
||||
export { default as ThumbnailOverlayToggleButton } from './classes/ThumbnailOverlayToggleButton.js';
|
||||
export { default as ThumbnailView } from './classes/ThumbnailView.js';
|
||||
export { default as TimedMarkerDecoration } from './classes/TimedMarkerDecoration.js';
|
||||
export { default as TitleAndButtonListHeader } from './classes/TitleAndButtonListHeader.js';
|
||||
export { default as ToggleButton } from './classes/ToggleButton.js';
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
import * as YTNodes from './nodes.js';
|
||||
import { InnertubeError, ParsingError, Platform } from '../utils/Utils.js';
|
||||
import { Memo, observe, SuperParsedResult } from './helpers.js';
|
||||
import { camelToSnake, generateRuntimeClass, generateTypescriptClass } from './generator.js';
|
||||
import { Log } from '../utils/index.js';
|
||||
|
||||
import {
|
||||
Continuation, ItemSectionContinuation, SectionListContinuation,
|
||||
LiveChatContinuation, MusicPlaylistShelfContinuation, MusicShelfContinuation,
|
||||
GridContinuation, PlaylistPanelContinuation, NavigateAction, ShowMiniplayerCommand,
|
||||
ReloadContinuationItemsCommand, ContinuationCommand
|
||||
} from './continuations.js';
|
||||
|
||||
import AudioOnlyPlayability from './classes/AudioOnlyPlayability.js';
|
||||
import CardCollection from './classes/CardCollection.js';
|
||||
import Endscreen from './classes/Endscreen.js';
|
||||
@@ -8,27 +21,17 @@ import PlayerStoryboardSpec from './classes/PlayerStoryboardSpec.js';
|
||||
import Alert from './classes/Alert.js';
|
||||
import AlertWithButton from './classes/AlertWithButton.js';
|
||||
import EngagementPanelSectionList from './classes/EngagementPanelSectionList.js';
|
||||
|
||||
import type { IParsedResponse, IRawResponse, RawData, RawNode } from './types/index.js';
|
||||
|
||||
import MusicMultiSelectMenuItem from './classes/menus/MusicMultiSelectMenuItem.js';
|
||||
import Format from './classes/misc/Format.js';
|
||||
import VideoDetails from './classes/misc/VideoDetails.js';
|
||||
import NavigationEndpoint from './classes/NavigationEndpoint.js';
|
||||
import CommentView from './classes/comments/CommentView.js';
|
||||
|
||||
import { InnertubeError, ParsingError, Platform } from '../utils/Utils.js';
|
||||
import type { ObservedArray, YTNodeConstructor, YTNode } from './helpers.js';
|
||||
import { Memo, observe, SuperParsedResult } from './helpers.js';
|
||||
import * as YTNodes from './nodes.js';
|
||||
import type { KeyInfo } from './generator.js';
|
||||
import { camelToSnake, generateRuntimeClass, generateTypescriptClass } from './generator.js';
|
||||
import type { ObservedArray, YTNodeConstructor, YTNode } from './helpers.js';
|
||||
import type { IParsedResponse, IRawResponse, RawData, RawNode } from './types/index.js';
|
||||
|
||||
import {
|
||||
Continuation, ItemSectionContinuation, SectionListContinuation,
|
||||
LiveChatContinuation, MusicPlaylistShelfContinuation, MusicShelfContinuation,
|
||||
GridContinuation, PlaylistPanelContinuation, NavigateAction, ShowMiniplayerCommand,
|
||||
ReloadContinuationItemsCommand, ContinuationCommand
|
||||
} from './continuations.js';
|
||||
const TAG = 'Parser';
|
||||
|
||||
export type ParserError = {
|
||||
classname: string,
|
||||
@@ -41,7 +44,8 @@ export type ParserError = {
|
||||
classdata: RawNode,
|
||||
error: unknown
|
||||
} | {
|
||||
error_type: 'mutation_data_missing'
|
||||
error_type: 'mutation_data_missing',
|
||||
classname: string
|
||||
} | {
|
||||
error_type: 'mutation_data_invalid',
|
||||
total: number,
|
||||
@@ -85,7 +89,7 @@ let ERROR_HANDLER: ParserErrorHandler = ({ classname, ...context }: ParserError)
|
||||
switch (context.error_type) {
|
||||
case 'parse':
|
||||
if (context.error instanceof Error) {
|
||||
console.warn(
|
||||
Log.warn(TAG,
|
||||
new InnertubeError(
|
||||
`Something went wrong at ${classname}!\n` +
|
||||
`This is a bug, please report it at ${Platform.shim.info.bugs_url}`, {
|
||||
@@ -96,7 +100,7 @@ let ERROR_HANDLER: ParserErrorHandler = ({ classname, ...context }: ParserError)
|
||||
}
|
||||
break;
|
||||
case 'typecheck':
|
||||
console.warn(
|
||||
Log.warn(TAG,
|
||||
new ParsingError(
|
||||
`Type mismatch, got ${classname} expected ${Array.isArray(context.expected) ? context.expected.join(' | ') : context.expected}.`,
|
||||
context.classdata
|
||||
@@ -104,15 +108,15 @@ let ERROR_HANDLER: ParserErrorHandler = ({ classname, ...context }: ParserError)
|
||||
);
|
||||
break;
|
||||
case 'mutation_data_missing':
|
||||
console.warn(
|
||||
Log.warn(TAG,
|
||||
new InnertubeError(
|
||||
'Mutation data required for processing MusicMultiSelectMenuItems, but none found.\n' +
|
||||
`Mutation data required for processing ${classname}, but none found.\n` +
|
||||
`This is a bug, please report it at ${Platform.shim.info.bugs_url}`
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'mutation_data_invalid':
|
||||
console.warn(
|
||||
Log.warn(TAG,
|
||||
new InnertubeError(
|
||||
`Mutation data missing or invalid for ${context.failed} out of ${context.total} MusicMultiSelectMenuItems. ` +
|
||||
`The titles of the failed items are: ${context.titles.join(', ')}.\n` +
|
||||
@@ -121,7 +125,7 @@ let ERROR_HANDLER: ParserErrorHandler = ({ classname, ...context }: ParserError)
|
||||
);
|
||||
break;
|
||||
case 'class_not_found':
|
||||
console.warn(
|
||||
Log.warn(TAG,
|
||||
new InnertubeError(
|
||||
`${classname} not found!\n` +
|
||||
`This is a bug, want to help us fix it? Follow the instructions at ${Platform.shim.info.repo_url}/blob/main/docs/updating-the-parser.md or report it at ${Platform.shim.info.bugs_url}!\n` +
|
||||
@@ -130,14 +134,14 @@ let ERROR_HANDLER: ParserErrorHandler = ({ classname, ...context }: ParserError)
|
||||
);
|
||||
break;
|
||||
case 'class_changed':
|
||||
console.warn(
|
||||
Log.warn(TAG,
|
||||
`${classname} changed!\n` +
|
||||
`The following keys where altered: ${context.changed_keys.map(([ key ]) => camelToSnake(key)).join(', ')}\n` +
|
||||
`The class has changed to:\n${generateTypescriptClass(classname, context.key_info)}`
|
||||
);
|
||||
break;
|
||||
default:
|
||||
console.warn(
|
||||
Log.warn(TAG,
|
||||
'Unreachable code reached at ParserErrorHandler'
|
||||
);
|
||||
break;
|
||||
@@ -314,14 +318,18 @@ export function parseResponse<T extends IParsedResponse = IParsedResponse>(data:
|
||||
|
||||
applyMutations(contents_memo, data.frameworkUpdates?.entityBatchUpdate?.mutations);
|
||||
|
||||
if (on_response_received_endpoints_memo) {
|
||||
applyCommentsMutations(on_response_received_endpoints_memo, data.frameworkUpdates?.entityBatchUpdate?.mutations);
|
||||
}
|
||||
|
||||
const continuation = data.continuation ? parseC(data.continuation) : null;
|
||||
if (continuation) {
|
||||
parsed_data.continuation = continuation;
|
||||
}
|
||||
|
||||
const continuationEndpoint = data.continuationEndpoint ? parseLC(data.continuationEndpoint) : null;
|
||||
if (continuationEndpoint) {
|
||||
parsed_data.continuationEndpoint = continuationEndpoint;
|
||||
const continuation_endpoint = data.continuationEndpoint ? parseLC(data.continuationEndpoint) : null;
|
||||
if (continuation_endpoint) {
|
||||
parsed_data.continuation_endpoint = continuation_endpoint;
|
||||
}
|
||||
|
||||
const metadata = parse(data.metadata);
|
||||
@@ -681,3 +689,28 @@ export function applyMutations(memo: Memo, mutations: RawNode[]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function applyCommentsMutations(memo: Memo, mutations: RawNode[]) {
|
||||
const comment_view_items = memo.getType(CommentView);
|
||||
|
||||
if (comment_view_items.length > 0) {
|
||||
if (!mutations) {
|
||||
ERROR_HANDLER({
|
||||
error_type: 'mutation_data_missing',
|
||||
classname: 'CommentView'
|
||||
});
|
||||
}
|
||||
|
||||
for (const comment_view of comment_view_items) {
|
||||
const comment_mutation = mutations
|
||||
.find((mutation) => mutation.payload?.commentEntityPayload?.key === comment_view.keys.comment)
|
||||
?.payload?.commentEntityPayload;
|
||||
|
||||
const toolbar_state_mutation = mutations
|
||||
.find((mutation) => mutation.payload?.engagementToolbarStateEntityPayload?.key === comment_view.keys.toolbar_state)
|
||||
?.payload?.engagementToolbarStateEntityPayload;
|
||||
|
||||
comment_view.applyMutations(comment_mutation, toolbar_state_mutation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ export interface IParsedResponse {
|
||||
items?: SuperParsedResult<YTNode>;
|
||||
entries?: SuperParsedResult<YTNode>;
|
||||
entries_memo?: Memo;
|
||||
continuationEndpoint?: YTNode;
|
||||
continuation_endpoint?: YTNode;
|
||||
}
|
||||
|
||||
export interface IPlayerConfig {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { Parser } from '../index.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { IParsedResponse } from '../types/ParsedResponse.js';
|
||||
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import AccountSectionList from '../classes/AccountSectionList.js';
|
||||
|
||||
import type { ApiResponse } from '../../core/index.js';
|
||||
import type { IParsedResponse } from '../types/index.js';
|
||||
import type AccountItemSection from '../classes/AccountItemSection.js';
|
||||
import type AccountChannel from '../classes/AccountChannel.js';
|
||||
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
class AccountInfo {
|
||||
#page: IParsedResponse;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Parser } from '../index.js';
|
||||
import Element from '../classes/Element.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import type { ApiResponse } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
|
||||
class Analytics {
|
||||
#page: IBrowseResponse;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import Feed from '../../core/mixins/Feed.js';
|
||||
import FilterableFeed from '../../core/mixins/FilterableFeed.js';
|
||||
import { ChannelError, InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
import TabbedFeed from '../../core/mixins/TabbedFeed.js';
|
||||
import C4TabbedHeader from '../classes/C4TabbedHeader.js';
|
||||
import CarouselHeader from '../classes/CarouselHeader.js';
|
||||
@@ -12,9 +16,6 @@ import SectionList from '../classes/SectionList.js';
|
||||
import Tab from '../classes/Tab.js';
|
||||
import PageHeader from '../classes/PageHeader.js';
|
||||
import TwoColumnBrowseResults from '../classes/TwoColumnBrowseResults.js';
|
||||
|
||||
import Feed from '../../core/mixins/Feed.js';
|
||||
import FilterableFeed from '../../core/mixins/FilterableFeed.js';
|
||||
import ChipCloudChip from '../classes/ChipCloudChip.js';
|
||||
import FeedFilterChipBar from '../classes/FeedFilterChipBar.js';
|
||||
import ChannelSubMenu from '../classes/ChannelSubMenu.js';
|
||||
@@ -22,11 +23,8 @@ import SortFilterSubMenu from '../classes/SortFilterSubMenu.js';
|
||||
import ContinuationItem from '../classes/ContinuationItem.js';
|
||||
import NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
|
||||
import { ChannelError, InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
import type { AppendContinuationItemsAction, ReloadContinuationItemsCommand } from '../index.js';
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
|
||||
export default class Channel extends TabbedFeed<IBrowseResponse> {
|
||||
@@ -196,10 +194,13 @@ export default class Channel extends TabbedFeed<IBrowseResponse> {
|
||||
if (this.hasTabWithURL('about')) {
|
||||
const tab = await this.getTabByURL('about');
|
||||
return tab.memo.getType(ChannelAboutFullMetadata)[0];
|
||||
} else if (this.header?.is(C4TabbedHeader) && this.header.tagline) {
|
||||
}
|
||||
|
||||
if (this.header.tagline.more_endpoint instanceof NavigationEndpoint) {
|
||||
const response = await this.header.tagline.more_endpoint.call(this.actions);
|
||||
const tagline = this.header?.is(C4TabbedHeader) && this.header.tagline;
|
||||
|
||||
if (tagline || this.header?.is(PageHeader) && this.header.content?.description) {
|
||||
if (tagline && tagline.more_endpoint instanceof NavigationEndpoint) {
|
||||
const response = await tagline.more_endpoint.call(this.actions);
|
||||
|
||||
const tab = new TabbedFeed<IBrowseResponse>(this.actions, response, false);
|
||||
return tab.memo.getType(ChannelAboutFullMetadata)[0];
|
||||
@@ -271,7 +272,9 @@ export default class Channel extends TabbedFeed<IBrowseResponse> {
|
||||
|
||||
get has_about(): boolean {
|
||||
// Game topic channels still have an about tab, user channels have switched to the popup
|
||||
return this.hasTabWithURL('about') || !!(this.header?.is(C4TabbedHeader) && this.header.tagline?.more_endpoint);
|
||||
return this.hasTabWithURL('about') ||
|
||||
!!(this.header?.is(C4TabbedHeader) && this.header.tagline?.more_endpoint) ||
|
||||
!!(this.header?.is(PageHeader) && this.header.content?.description?.more_endpoint);
|
||||
}
|
||||
|
||||
get has_search(): boolean {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Parser } from '../index.js';
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import { observe } from '../helpers.js';
|
||||
import type { INextResponse } from '../types/ParsedResponse.js';
|
||||
|
||||
import CommentsHeader from '../classes/comments/CommentsHeader.js';
|
||||
import CommentSimplebox from '../classes/comments/CommentSimplebox.js';
|
||||
import CommentThread from '../classes/comments/CommentThread.js';
|
||||
import ContinuationItem from '../classes/ContinuationItem.js';
|
||||
|
||||
import type { Actions, ApiResponse } from '../../core/index.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import type { INextResponse } from '../types/index.js';
|
||||
|
||||
class Comments {
|
||||
#page: INextResponse;
|
||||
#actions: Actions;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import type { IGuideResponse } from '../types/ParsedResponse.js';
|
||||
import type { IRawResponse } from '../index.js';
|
||||
import { Parser } from '../index.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import GuideSection from '../classes/GuideSection.js';
|
||||
import GuideSubscriptionsSection from '../classes/GuideSubscriptionsSection.js';
|
||||
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import type { IGuideResponse } from '../types/index.js';
|
||||
import type { IRawResponse } from '../index.js';
|
||||
|
||||
export default class Guide {
|
||||
|
||||
#page: IGuideResponse;
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import FilterableFeed from '../../core/mixins/FilterableFeed.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import FilterableFeed from '../../core/mixins/FilterableFeed.js';
|
||||
import HashtagHeader from '../classes/HashtagHeader.js';
|
||||
import RichGrid from '../classes/RichGrid.js';
|
||||
import PageHeader from '../classes/PageHeader.js';
|
||||
import Tab from '../classes/Tab.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type ChipCloudChip from '../classes/ChipCloudChip.js';
|
||||
import type { Actions, ApiResponse } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../index.js';
|
||||
import { PageHeader } from '../nodes.js';
|
||||
import type ChipCloudChip from '../classes/ChipCloudChip.js';
|
||||
|
||||
export default class HashtagFeed extends FilterableFeed<IBrowseResponse> {
|
||||
header?: HashtagHeader | PageHeader;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import Feed from '../../core/mixins/Feed.js';
|
||||
import ItemSection from '../classes/ItemSection.js';
|
||||
import BrowseFeedActions from '../classes/BrowseFeedActions.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
|
||||
import type { Actions, ApiResponse } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
|
||||
// TODO: make feed actions usable
|
||||
class History extends Feed<IBrowseResponse> {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import FilterableFeed from '../../core/mixins/FilterableFeed.js';
|
||||
import type ChipCloudChip from '../classes/ChipCloudChip.js';
|
||||
import FeedTabbedHeader from '../classes/FeedTabbedHeader.js';
|
||||
import RichGrid from '../classes/RichGrid.js';
|
||||
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
import type { AppendContinuationItemsAction, ReloadContinuationItemsCommand } from '../index.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type ChipCloudChip from '../classes/ChipCloudChip.js';
|
||||
|
||||
export default class HomeFeed extends FilterableFeed<IBrowseResponse> {
|
||||
contents: RichGrid | AppendContinuationItemsAction | ReloadContinuationItemsCommand;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import Button from '../classes/Button.js';
|
||||
import Menu from '../classes/menus/Menu.js';
|
||||
import Button from '../classes/Button.js';
|
||||
import MenuServiceItem from '../classes/menus/MenuServiceItem.js';
|
||||
import type NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { Actions } from '../../core/index.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
import type { IParsedResponse } from '../types/ParsedResponse.js';
|
||||
import type { IParsedResponse } from '../types/index.js';
|
||||
import type NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
|
||||
class ItemMenu {
|
||||
#page: IParsedResponse;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
import Feed from '../../core/mixins/Feed.js';
|
||||
import History from './History.js';
|
||||
import Playlist from './Playlist.js';
|
||||
@@ -9,8 +7,8 @@ import Shelf from '../classes/Shelf.js';
|
||||
import Button from '../classes/Button.js';
|
||||
import PageHeader from '../classes/PageHeader.js';
|
||||
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { Actions, ApiResponse } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
|
||||
class Library extends Feed<IBrowseResponse> {
|
||||
header: PageHeader | null;
|
||||
|
||||
@@ -1,42 +1,40 @@
|
||||
import EventEmitter from '../../utils/EventEmitterLike.js';
|
||||
import * as Proto from '../../proto/index.js';
|
||||
import { EventEmitter } from '../../utils/index.js';
|
||||
import { InnertubeError, Platform } from '../../utils/Utils.js';
|
||||
import { Parser, LiveChatContinuation } from '../index.js';
|
||||
import type VideoInfo from './VideoInfo.js';
|
||||
import SmoothedQueue from './SmoothedQueue.js';
|
||||
|
||||
import AddChatItemAction from '../classes/livechat/AddChatItemAction.js';
|
||||
import type AddLiveChatTickerItemAction from '../classes/livechat/AddLiveChatTickerItemAction.js';
|
||||
import type MarkChatItemAsDeletedAction from '../classes/livechat/MarkChatItemAsDeletedAction.js';
|
||||
import type MarkChatItemsByAuthorAsDeletedAction from '../classes/livechat/MarkChatItemsByAuthorAsDeletedAction.js';
|
||||
import type ReplaceChatItemAction from '../classes/livechat/ReplaceChatItemAction.js';
|
||||
import type ReplayChatItemAction from '../classes/livechat/ReplayChatItemAction.js';
|
||||
import type ShowLiveChatActionPanelAction from '../classes/livechat/ShowLiveChatActionPanelAction.js';
|
||||
|
||||
import UpdateDateTextAction from '../classes/livechat/UpdateDateTextAction.js';
|
||||
import UpdateDescriptionAction from '../classes/livechat/UpdateDescriptionAction.js';
|
||||
import UpdateTitleAction from '../classes/livechat/UpdateTitleAction.js';
|
||||
import UpdateToggleButtonTextAction from '../classes/livechat/UpdateToggleButtonTextAction.js';
|
||||
import UpdateViewershipAction from '../classes/livechat/UpdateViewershipAction.js';
|
||||
import NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
import ItemMenu from './ItemMenu.js';
|
||||
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
|
||||
import type VideoInfo from './VideoInfo.js';
|
||||
import type AddBannerToLiveChatCommand from '../classes/livechat/AddBannerToLiveChatCommand.js';
|
||||
import type RemoveBannerForLiveChatCommand from '../classes/livechat/RemoveBannerForLiveChatCommand.js';
|
||||
import type ShowLiveChatTooltipCommand from '../classes/livechat/ShowLiveChatTooltipCommand.js';
|
||||
|
||||
import * as Proto from '../../proto/index.js';
|
||||
import { InnertubeError, Platform } from '../../utils/Utils.js';
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
|
||||
import type Button from '../classes/Button.js';
|
||||
import type LiveChatAutoModMessage from '../classes/livechat/items/LiveChatAutoModMessage.js';
|
||||
import type LiveChatMembershipItem from '../classes/livechat/items/LiveChatMembershipItem.js';
|
||||
import type LiveChatPaidMessage from '../classes/livechat/items/LiveChatPaidMessage.js';
|
||||
import type LiveChatPaidSticker from '../classes/livechat/items/LiveChatPaidSticker.js';
|
||||
import type LiveChatTextMessage from '../classes/livechat/items/LiveChatTextMessage.js';
|
||||
import type LiveChatViewerEngagementMessage from '../classes/livechat/items/LiveChatViewerEngagementMessage.js';
|
||||
import ItemMenu from './ItemMenu.js';
|
||||
import type AddLiveChatTickerItemAction from '../classes/livechat/AddLiveChatTickerItemAction.js';
|
||||
import type MarkChatItemAsDeletedAction from '../classes/livechat/MarkChatItemAsDeletedAction.js';
|
||||
import type MarkChatItemsByAuthorAsDeletedAction from '../classes/livechat/MarkChatItemsByAuthorAsDeletedAction.js';
|
||||
import type ReplaceChatItemAction from '../classes/livechat/ReplaceChatItemAction.js';
|
||||
import type ReplayChatItemAction from '../classes/livechat/ReplayChatItemAction.js';
|
||||
import type ShowLiveChatActionPanelAction from '../classes/livechat/ShowLiveChatActionPanelAction.js';
|
||||
import type Button from '../classes/Button.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { IParsedResponse, IUpdatedMetadataResponse } from '../types/ParsedResponse.js';
|
||||
import { NavigationEndpoint } from '../nodes.js';
|
||||
import type { Actions } from '../../core/index.js';
|
||||
import type { IParsedResponse, IUpdatedMetadataResponse } from '../types/index.js';
|
||||
|
||||
export type ChatAction =
|
||||
AddChatItemAction | AddBannerToLiveChatCommand | AddLiveChatTickerItemAction |
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { Parser } from '../index.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
import ContinuationItem from '../classes/ContinuationItem.js';
|
||||
import SimpleMenuHeader from '../classes/menus/SimpleMenuHeader.js';
|
||||
import Notification from '../classes/Notification.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { IGetNotificationsMenuResponse } from '../types/ParsedResponse.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { IGetNotificationsMenuResponse } from '../types/index.js';
|
||||
|
||||
class NotificationsMenu {
|
||||
#page: IGetNotificationsMenuResponse;
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
import Feed from '../../core/mixins/Feed.js';
|
||||
import Message from '../classes/Message.js';
|
||||
import type Thumbnail from '../classes/misc/Thumbnail.js';
|
||||
import type NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
import PlaylistCustomThumbnail from '../classes/PlaylistCustomThumbnail.js';
|
||||
import PlaylistHeader from '../classes/PlaylistHeader.js';
|
||||
import PlaylistMetadata from '../classes/PlaylistMetadata.js';
|
||||
import PlaylistSidebarPrimaryInfo from '../classes/PlaylistSidebarPrimaryInfo.js';
|
||||
import PlaylistSidebarSecondaryInfo from '../classes/PlaylistSidebarSecondaryInfo.js';
|
||||
import PlaylistVideoThumbnail from '../classes/PlaylistVideoThumbnail.js';
|
||||
import ReelItem from '../classes/ReelItem.js';
|
||||
import VideoOwner from '../classes/VideoOwner.js';
|
||||
import Alert from '../classes/Alert.js';
|
||||
import ContinuationItem from '../classes/ContinuationItem.js';
|
||||
import PlaylistVideo from '../classes/PlaylistVideo.js';
|
||||
import SectionList from '../classes/SectionList.js';
|
||||
import { observe, type ObservedArray } from '../helpers.js';
|
||||
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import type Thumbnail from '../classes/misc/Thumbnail.js';
|
||||
import type NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
|
||||
export default class Playlist extends Feed<IBrowseResponse> {
|
||||
info;
|
||||
@@ -64,8 +67,38 @@ export default class Playlist extends Feed<IBrowseResponse> {
|
||||
return primary_info.stats[index]?.toString() || 'N/A';
|
||||
}
|
||||
|
||||
get items() {
|
||||
return this.videos;
|
||||
get items(): ObservedArray<PlaylistVideo | ReelItem> {
|
||||
return observe(this.videos.as(PlaylistVideo, ReelItem).filter((video) => (video as PlaylistVideo).style !== 'PLAYLIST_VIDEO_RENDERER_STYLE_RECOMMENDED_VIDEO'));
|
||||
}
|
||||
|
||||
get has_continuation() {
|
||||
const section_list = this.memo.getType(SectionList).first();
|
||||
|
||||
if (!section_list)
|
||||
return super.has_continuation;
|
||||
|
||||
return !!this.memo.getType(ContinuationItem).find((node) => !section_list.contents.includes(node));
|
||||
}
|
||||
|
||||
async getContinuationData(): Promise<IBrowseResponse | undefined> {
|
||||
const section_list = this.memo.getType(SectionList).first();
|
||||
|
||||
/**
|
||||
* No section list means there can't be additional continuation nodes here,
|
||||
* so no need to check.
|
||||
*/
|
||||
if (!section_list)
|
||||
return await super.getContinuationData();
|
||||
|
||||
const playlist_contents_continuation = this.memo.getType(ContinuationItem)
|
||||
.find((node) => !section_list.contents.includes(node));
|
||||
|
||||
if (!playlist_contents_continuation)
|
||||
throw new InnertubeError('There are no continuations.');
|
||||
|
||||
const response = await playlist_contents_continuation.endpoint.call<IBrowseResponse>(this.actions, { parse: true });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
async getContinuation(): Promise<Playlist> {
|
||||
|
||||
@@ -8,10 +8,10 @@ import SearchSubMenu from '../classes/SearchSubMenu.js';
|
||||
import SectionList from '../classes/SectionList.js';
|
||||
import UniversalWatchCard from '../classes/UniversalWatchCard.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
import type { ISearchResponse } from '../types/ParsedResponse.js';
|
||||
import type { ISearchResponse } from '../types/index.js';
|
||||
|
||||
class Search extends Feed<ISearchResponse> {
|
||||
header?: SearchHeader;
|
||||
results?: ObservedArray<YTNode> | null;
|
||||
|
||||
@@ -8,12 +8,14 @@ import SectionList from '../classes/SectionList.js';
|
||||
import SettingsOptions from '../classes/SettingsOptions.js';
|
||||
import SettingsSidebar from '../classes/SettingsSidebar.js';
|
||||
import SettingsSwitch from '../classes/SettingsSwitch.js';
|
||||
import CommentsHeader from '../classes/comments/CommentsHeader.js';
|
||||
import ItemSectionHeader from '../classes/ItemSectionHeader.js';
|
||||
import ItemSectionTabbedHeader from '../classes/ItemSectionTabbedHeader.js';
|
||||
import Tab from '../classes/Tab.js';
|
||||
import TwoColumnBrowseResults from '../classes/TwoColumnBrowseResults.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
|
||||
class Settings {
|
||||
#page: IBrowseResponse;
|
||||
@@ -42,7 +44,7 @@ class Settings {
|
||||
this.introduction = contents?.shift()?.contents?.firstOfType(PageIntroduction);
|
||||
|
||||
this.sections = contents?.map((el: ItemSection) => ({
|
||||
title: el.header?.title.toString() || null,
|
||||
title: el.header?.is(CommentsHeader, ItemSectionHeader, ItemSectionTabbedHeader) ? el.header.title.toString() : null,
|
||||
contents: el.contents
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import SectionList from '../classes/SectionList.js';
|
||||
import SingleColumnBrowseResults from '../classes/SingleColumnBrowseResults.js';
|
||||
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/index.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
|
||||
class TimeWatched {
|
||||
#page: IBrowseResponse;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import { type ApiResponse } from '../../core/Actions.js';
|
||||
import type { IGetTranscriptResponse } from '../index.js';
|
||||
import { Parser } from '../index.js';
|
||||
import Transcript from '../classes/Transcript.js';
|
||||
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { IGetTranscriptResponse } from '../index.js';
|
||||
|
||||
export default class TranscriptInfo {
|
||||
#page: IGetTranscriptResponse;
|
||||
#actions: Actions;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import { MediaInfo } from '../../core/mixins/index.js';
|
||||
|
||||
import ChipCloud from '../classes/ChipCloud.js';
|
||||
import ChipCloudChip from '../classes/ChipCloudChip.js';
|
||||
import CommentsEntryPointHeader from '../classes/comments/CommentsEntryPointHeader.js';
|
||||
@@ -19,8 +22,11 @@ import VideoPrimaryInfo from '../classes/VideoPrimaryInfo.js';
|
||||
import VideoSecondaryInfo from '../classes/VideoSecondaryInfo.js';
|
||||
import NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
import PlayerLegacyDesktopYpcTrailer from '../classes/PlayerLegacyDesktopYpcTrailer.js';
|
||||
import StructuredDescriptionContent from '../classes/StructuredDescriptionContent.js';
|
||||
import VideoDescriptionMusicSection from '../classes/VideoDescriptionMusicSection.js';
|
||||
import LiveChatWrap from './LiveChat.js';
|
||||
|
||||
import type { RawNode } from '../index.js';
|
||||
import type CardCollection from '../classes/CardCollection.js';
|
||||
import type Endscreen from '../classes/Endscreen.js';
|
||||
import type PlayerAnnotationsExpanded from '../classes/PlayerAnnotationsExpanded.js';
|
||||
@@ -28,16 +34,9 @@ import type PlayerCaptionsTracklist from '../classes/PlayerCaptionsTracklist.js'
|
||||
import type PlayerLiveStoryboardSpec from '../classes/PlayerLiveStoryboardSpec.js';
|
||||
import type PlayerStoryboardSpec from '../classes/PlayerStoryboardSpec.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import { MediaInfo } from '../../core/mixins/index.js';
|
||||
import StructuredDescriptionContent from '../classes/StructuredDescriptionContent.js';
|
||||
import { VideoDescriptionMusicSection } from '../nodes.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
|
||||
class VideoInfo extends MediaInfo {
|
||||
#watch_next_continuation?: ContinuationItem;
|
||||
|
||||
@@ -88,6 +87,7 @@ class VideoInfo extends MediaInfo {
|
||||
category: info.microformat?.is(PlayerMicroformat) ? info.microformat?.category : null,
|
||||
has_ypc_metadata: info.microformat?.is(PlayerMicroformat) ? info.microformat?.has_ypc_metadata : null,
|
||||
start_timestamp: info.microformat?.is(PlayerMicroformat) ? info.microformat.start_timestamp : null,
|
||||
end_timestamp: info.microformat?.is(PlayerMicroformat) ? info.microformat.end_timestamp : null,
|
||||
view_count: info.microformat?.is(PlayerMicroformat) && isNaN(info.video_details?.view_count as number) ? info.microformat.view_count : info.video_details?.view_count
|
||||
},
|
||||
like_count: undefined as number | undefined,
|
||||
@@ -223,7 +223,6 @@ class VideoInfo extends MediaInfo {
|
||||
return super.addToWatchHistory();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves watch next feed continuation.
|
||||
*/
|
||||
@@ -232,7 +231,7 @@ class VideoInfo extends MediaInfo {
|
||||
throw new InnertubeError('Watch next feed continuation not found');
|
||||
|
||||
const response = await this.#watch_next_continuation?.endpoint.call(this.actions, { parse: true });
|
||||
const data = response?.on_response_received_endpoints?.get({ type: 'appendContinuationItemsAction' });
|
||||
const data = response?.on_response_received_endpoints?.get({ type: 'AppendContinuationItemsAction' });
|
||||
|
||||
if (!data)
|
||||
throw new InnertubeError('AppendContinuationItemsAction not found');
|
||||
|
||||
@@ -17,3 +17,4 @@ export { default as Settings } from './Settings.js';
|
||||
export { default as SmoothedQueue } from './SmoothedQueue.js';
|
||||
export { default as TimeWatched } from './TimeWatched.js';
|
||||
export { default as VideoInfo } from './VideoInfo.js';
|
||||
export { default as TranscriptInfo } from './TranscriptInfo.js';
|
||||
@@ -2,9 +2,9 @@ import Feed from '../../core/mixins/Feed.js';
|
||||
import C4TabbedHeader from '../classes/C4TabbedHeader.js';
|
||||
import ItemSection from '../classes/ItemSection.js';
|
||||
import { ItemSectionContinuation } from '../index.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
|
||||
class Channel extends Feed<IBrowseResponse> {
|
||||
header?: C4TabbedHeader;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
import Feed from '../../core/mixins/Feed.js';
|
||||
import KidsCategoriesHeader from '../classes/ytkids/KidsCategoriesHeader.js';
|
||||
import KidsCategoryTab from '../classes/ytkids/KidsCategoryTab.js';
|
||||
import KidsHomeScreen from '../classes/ytkids/KidsHomeScreen.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
|
||||
class HomeFeed extends Feed<IBrowseResponse> {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import Feed from '../../core/mixins/Feed.js';
|
||||
import ItemSection from '../classes/ItemSection.js';
|
||||
import { InnertubeError } from '../../utils/Utils.js';
|
||||
import type Actions from '../../core/Actions.js';
|
||||
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
import type { ISearchResponse } from '../types/ParsedResponse.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ISearchResponse } from '../types/index.js';
|
||||
|
||||
class Search extends Feed<ISearchResponse> {
|
||||
estimated_results: number;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { MediaInfo } from '../../core/mixins/index.js';
|
||||
import ItemSection from '../classes/ItemSection.js';
|
||||
import type NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
import PlayerOverlay from '../classes/PlayerOverlay.js';
|
||||
import SlimVideoMetadata from '../classes/SlimVideoMetadata.js';
|
||||
import TwoColumnWatchNextResults from '../classes/TwoColumnWatchNextResults.js';
|
||||
|
||||
import type Actions from '../../core/Actions.js';
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ApiResponse, Actions } from '../../core/index.js';
|
||||
import type { ObservedArray, YTNode } from '../helpers.js';
|
||||
import { MediaInfo } from '../../core/mixins/index.js';
|
||||
import type NavigationEndpoint from '../classes/NavigationEndpoint.js';
|
||||
|
||||
class VideoInfo extends MediaInfo {
|
||||
basic_info;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { ApiResponse } from '../../core/Actions.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import { Parser } from '../index.js';
|
||||
|
||||
import MicroformatData from '../classes/MicroformatData.js';
|
||||
@@ -7,8 +5,10 @@ import MusicCarouselShelf from '../classes/MusicCarouselShelf.js';
|
||||
import MusicDetailHeader from '../classes/MusicDetailHeader.js';
|
||||
import MusicShelf from '../classes/MusicShelf.js';
|
||||
|
||||
import type { ApiResponse } from '../../core/index.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import type { IBrowseResponse } from '../types/index.js';
|
||||
import type MusicResponsiveListItem from '../classes/MusicResponsiveListItem.js';
|
||||
import type { IBrowseResponse } from '../types/ParsedResponse.js';
|
||||
|
||||
class Album {
|
||||
#page: IBrowseResponse;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user