mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-14 01:52:11 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbfc569602 | ||
|
|
c16a967987 | ||
|
|
a07375eb20 | ||
|
|
ce9d9c56b4 | ||
|
|
f50ce1a06b | ||
|
|
3b6ccfa3d8 | ||
|
|
878488d1b3 | ||
|
|
3c94c9da4b | ||
|
|
0b301de6a1 | ||
|
|
c9135e66d3 | ||
|
|
e82c843928 | ||
|
|
be71d7c937 | ||
|
|
470d8d9406 | ||
|
|
2c5907f80f |
33
.github/pull_request_template.md
vendored
33
.github/pull_request_template.md
vendored
@@ -1,27 +1,6 @@
|
||||
# Pull Request Template
|
||||
|
||||
## Description
|
||||
|
||||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
|
||||
|
||||
Fixes # (issue)
|
||||
|
||||
## Type of change
|
||||
|
||||
Please delete options that are not relevant.
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- [ ] This change requires a documentation update
|
||||
|
||||
## Checklist:
|
||||
|
||||
- [ ] My code follows the style guidelines of this project
|
||||
- [ ] I have performed a self-review of my own code
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
- [ ] I have added tests that prove my fix is effective or that my feature works
|
||||
- [ ] New and existing unit tests pass locally with my changes
|
||||
- [ ] I have checked my code and corrected any misspellings
|
||||
<!-- Thank you for submitting a Pull Request! Please:
|
||||
* Read our contributing guidelines: https://github.com/LuanRT/YouTube.js/blob/main/CONTRIBUTING.md
|
||||
* Add "Fixes #<issue_number>" to the PR description if you are fixing an issue.
|
||||
* Ensure that the code is up-to-date with the `main` branch.
|
||||
* Include a description of the proposed changes and how to test them.
|
||||
-->
|
||||
17
CHANGELOG.md
17
CHANGELOG.md
@@ -1,5 +1,22 @@
|
||||
# Changelog
|
||||
|
||||
## [4.2.0](https://github.com/LuanRT/YouTube.js/compare/v4.1.1...v4.2.0) (2023-04-09)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Enable importHelpers in tsconfig to reduce output size ([#378](https://github.com/LuanRT/YouTube.js/issues/378)) ([0b301de](https://github.com/LuanRT/YouTube.js/commit/0b301de6a1e1352a64881c1751a84360922a77cd))
|
||||
* **parser:** ignore PrimetimePromo node ([ce9d9c5](https://github.com/LuanRT/YouTube.js/commit/ce9d9c56b4f45c0139d74edc95c295ecfd1ee4b1))
|
||||
* **PlaylistVideo:** Extract video_info and accessibility_label texts ([#376](https://github.com/LuanRT/YouTube.js/issues/376)) ([c9135e6](https://github.com/LuanRT/YouTube.js/commit/c9135e66d3c9c72b8d063eedcf3cc2123800946d))
|
||||
|
||||
## [4.1.1](https://github.com/LuanRT/YouTube.js/compare/v4.1.0...v4.1.1) (2023-03-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **PlayerCaptionsTracklist:** parse props only if they exist in the node ([470d8d9](https://github.com/LuanRT/YouTube.js/commit/470d8d94063f0159cd005c9eb15fd1a4a175bea0)), closes [#372](https://github.com/LuanRT/YouTube.js/issues/372)
|
||||
* **Search:** Return search results even if there are ads ([#373](https://github.com/LuanRT/YouTube.js/issues/373)) ([2c5907f](https://github.com/LuanRT/YouTube.js/commit/2c5907f80fd76452afe87d1722fe35a4f45a22e0))
|
||||
|
||||
## [4.1.0](https://github.com/LuanRT/YouTube.js/compare/v4.0.1...v4.1.0) (2023-03-24)
|
||||
|
||||
|
||||
|
||||
83
README.md
83
README.md
@@ -3,14 +3,12 @@
|
||||
[versions]: https://www.npmjs.com/package/youtubei.js?activeTab=versions
|
||||
[codefactor]: https://www.codefactor.io/repository/github/luanrt/youtube.js
|
||||
[actions]: https://github.com/LuanRT/YouTube.js/actions
|
||||
[say-thanks]: https://saythanks.io/to/LuanRT
|
||||
[collaborators]: https://github.com/LuanRT/YouTube.js/blob/main/COLLABORATORS.md
|
||||
|
||||
<!-- OTHER LINKS -->
|
||||
[project]: https://github.com/LuanRT/YouTube.js
|
||||
[twitter]: https://twitter.com/thesciencephile
|
||||
[discord]: https://discord.gg/syDu7Yks54
|
||||
[nodejs]: https://nodejs.org
|
||||
|
||||
<h1 align=center>YouTube.js</h1>
|
||||
|
||||
@@ -23,33 +21,28 @@
|
||||
[][codefactor]
|
||||
[][npm]
|
||||
[][discord]
|
||||
[][say-thanks]
|
||||
<br>
|
||||
[][collaborators]
|
||||
|
||||
</div>
|
||||
|
||||
<p align="center">
|
||||
<a><sub>Special thanks to:<sub></a>
|
||||
</p>
|
||||
|
||||
<table align="center">
|
||||
<body>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://serpapi.com/" target="_blank">
|
||||
<img width="80" alt="SerpApi" src="https://luanrt.is-a.dev/assets/img/serpapi.svg" />
|
||||
<br>
|
||||
<b>
|
||||
<sub>
|
||||
Scrape Google and other search engines from a fast, easy and complete API.
|
||||
</sub>
|
||||
</b>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</body>
|
||||
</table>
|
||||
<div align="center">
|
||||
<p>
|
||||
<sup>Special thanks to:</sup>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://serpapi.com#gh-light-mode-only" target="_blank">
|
||||
<img width="80" alt="SerpApi" src="https://luanrt.is-a.dev/assets/img/serpapi.svg" />
|
||||
<br>
|
||||
<sub>
|
||||
API to get search engine results with ease.
|
||||
</sub>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<br>
|
||||
<hr>
|
||||
<br>
|
||||
|
||||
## Table of Contents
|
||||
<ol>
|
||||
@@ -249,7 +242,7 @@ const yt = await Innertube.create({
|
||||
* `Innertube`
|
||||
|
||||
<details>
|
||||
<summary>Objects</summary>
|
||||
<summary>Properties</summary>
|
||||
<p>
|
||||
|
||||
* [.session](https://github.com/LuanRT/YouTube.js/blob/main/docs/API/session.md)
|
||||
@@ -293,7 +286,7 @@ const yt = await Innertube.create({
|
||||
</details>
|
||||
|
||||
<a name="getinfo"></a>
|
||||
### getInfo(target, client?)
|
||||
### `getInfo(target, client?)`
|
||||
|
||||
Retrieves video info.
|
||||
|
||||
@@ -357,7 +350,7 @@ Retrieves video info.
|
||||
</details>
|
||||
|
||||
<a name="getbasicinfo"></a>
|
||||
### getBasicInfo(video_id, client?)
|
||||
### `getBasicInfo(video_id, client?)`
|
||||
|
||||
Suitable for cases where you only need basic video metadata. Also, it is faster than [`getInfo()`](#getinfo).
|
||||
|
||||
@@ -369,7 +362,7 @@ Suitable for cases where you only need basic video metadata. Also, it is faster
|
||||
| client? | `InnerTubeClient` | `WEB`, `ANDROID`, `YTMUSIC_ANDROID`, `YTMUSIC`, `TV_EMBEDDED` |
|
||||
|
||||
<a name="search"></a>
|
||||
### search(query, filters?)
|
||||
### `search(query, filters?)`
|
||||
|
||||
Searches the given query on YouTube.
|
||||
|
||||
@@ -414,7 +407,7 @@ Searches the given query on YouTube.
|
||||
</details>
|
||||
|
||||
<a name="getsearchsuggestions"></a>
|
||||
### getSearchSuggestions(query)
|
||||
### `getSearchSuggestions(query)`
|
||||
Retrieves search suggestions for given query.
|
||||
|
||||
**Returns**: `Promise<string[]>`
|
||||
@@ -424,7 +417,7 @@ Retrieves search suggestions for given query.
|
||||
| query | `string` | The search query |
|
||||
|
||||
<a name="getcomments"></a>
|
||||
### getComments(video_id, sort_by?)
|
||||
### `getComments(video_id, sort_by?)`
|
||||
Retrieves comments for given video.
|
||||
|
||||
**Returns**: `Promise<Comments>`
|
||||
@@ -437,7 +430,7 @@ Retrieves comments for given video.
|
||||
See [`./examples/comments`](https://github.com/LuanRT/YouTube.js/blob/main/examples/comments) for examples.
|
||||
|
||||
<a name="gethomefeed"></a>
|
||||
### getHomeFeed()
|
||||
### `getHomeFeed()`
|
||||
Retrieves YouTube's home feed.
|
||||
|
||||
**Returns**: `Promise<HomeFeed>`
|
||||
@@ -471,13 +464,13 @@ Retrieves YouTube's home feed.
|
||||
</details>
|
||||
|
||||
<a name="getguide"></a>
|
||||
### getGuide()
|
||||
### `getGuide()`
|
||||
Retrieves YouTube's content guide.
|
||||
|
||||
**Returns**: `Promise<Guide>`
|
||||
|
||||
<a name="getlibrary"></a>
|
||||
### getLibrary()
|
||||
### `getLibrary()`
|
||||
Retrieves the account's library.
|
||||
|
||||
**Returns**: `Promise<Library>`
|
||||
@@ -499,7 +492,7 @@ Retrieves the account's library.
|
||||
</details>
|
||||
|
||||
<a name="gethistory"></a>
|
||||
### getHistory()
|
||||
### `getHistory()`
|
||||
Retrieves watch history.
|
||||
|
||||
**Returns**: `Promise<History>`
|
||||
@@ -518,19 +511,19 @@ Retrieves watch history.
|
||||
</details>
|
||||
|
||||
<a name="gettrending"></a>
|
||||
### getTrending()
|
||||
### `getTrending()`
|
||||
Retrieves trending content.
|
||||
|
||||
**Returns**: `Promise<TabbedFeed<IBrowseResponse>>`
|
||||
|
||||
<a name="getsubscriptionsfeed"></a>
|
||||
### getSubscriptionsFeed()
|
||||
### `getSubscriptionsFeed()`
|
||||
Retrieves the subscriptions feed.
|
||||
|
||||
**Returns**: `Promise<Feed<IBrowseResponse>>`
|
||||
|
||||
<a name="getchannel"></a>
|
||||
### getChannel(id)
|
||||
### `getChannel(id)`
|
||||
Retrieves contents for a given channel.
|
||||
|
||||
**Returns**: `Promise<Channel>`
|
||||
@@ -570,7 +563,7 @@ Retrieves contents for a given channel.
|
||||
See [`./examples/channel`](https://github.com/LuanRT/YouTube.js/blob/main/examples/channel) for examples.
|
||||
|
||||
<a name="getnotifications"></a>
|
||||
### getNotifications()
|
||||
### `getNotifications()`
|
||||
Retrieves notifications.
|
||||
|
||||
**Returns**: `Promise<NotificationsMenu>`
|
||||
@@ -586,13 +579,13 @@ Retrieves notifications.
|
||||
</details>
|
||||
|
||||
<a name="getunseennotificationscount"></a>
|
||||
### getUnseenNotificationsCount()
|
||||
### `getUnseenNotificationsCount()`
|
||||
Retrieves unseen notifications count.
|
||||
|
||||
**Returns**: `Promise<number>`
|
||||
|
||||
<a name="getplaylist"></a>
|
||||
### getPlaylist(id)
|
||||
### `getPlaylist(id)`
|
||||
Retrieves playlist contents.
|
||||
|
||||
**Returns**: `Promise<Playlist>`
|
||||
@@ -615,7 +608,7 @@ Retrieves playlist contents.
|
||||
</details>
|
||||
|
||||
<a name="gethashtag"></a>
|
||||
### getHashtag(hashtag)
|
||||
### `getHashtag(hashtag)`
|
||||
Retrieves a given hashtag's page.
|
||||
|
||||
**Returns**: `Promise<HashtagFeed>`
|
||||
@@ -640,7 +633,7 @@ Retrieves a given hashtag's page.
|
||||
</details>
|
||||
|
||||
<a name="getstreamingdata"></a>
|
||||
### getStreamingData(video_id, options)
|
||||
### `getStreamingData(video_id, options)`
|
||||
Returns deciphered streaming data.
|
||||
|
||||
> **Note**
|
||||
@@ -666,7 +659,7 @@ console.info('Playback url:', url);
|
||||
| options | `FormatOptions` | Format options |
|
||||
|
||||
<a name="download"></a>
|
||||
### download(video_id, options?)
|
||||
### `download(video_id, options?)`
|
||||
Downloads a given video.
|
||||
|
||||
**Returns**: `Promise<ReadableStream<Uint8Array>>`
|
||||
@@ -679,7 +672,7 @@ Downloads a given video.
|
||||
See [`./examples/download`](https://github.com/LuanRT/YouTube.js/blob/main/examples/download) for examples.
|
||||
|
||||
<a name="resolveurl"></a>
|
||||
### resolveURL(url)
|
||||
### `resolveURL(url)`
|
||||
Resolves a given url.
|
||||
|
||||
**Returns**: `Promise<NavigationEndpoint>`
|
||||
@@ -689,7 +682,7 @@ Resolves a given url.
|
||||
| url | `string` | Url to resolve |
|
||||
|
||||
<a name="call"></a>
|
||||
### call(endpoint, args?)
|
||||
### `call(endpoint, args?)`
|
||||
Utility to call navigation endpoints.
|
||||
|
||||
**Returns**: `Promise<T extends IParsedResponse | IParsedResponse | ApiResponse>`
|
||||
|
||||
75
package-lock.json
generated
75
package-lock.json
generated
@@ -1,19 +1,20 @@
|
||||
{
|
||||
"name": "youtubei.js",
|
||||
"version": "4.1.0",
|
||||
"version": "4.2.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "youtubei.js",
|
||||
"version": "4.1.0",
|
||||
"version": "4.2.0",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/LuanRT"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"jintr": "^0.4.1",
|
||||
"jintr": "^1.0.0",
|
||||
"linkedom": "^0.14.12",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.19.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -1574,6 +1575,12 @@
|
||||
"node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@yarnpkg/fslib/node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@yarnpkg/libzip": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@yarnpkg/libzip/-/libzip-2.2.4.tgz",
|
||||
@@ -1587,6 +1594,12 @@
|
||||
"node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@yarnpkg/libzip/node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.8.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
|
||||
@@ -4394,9 +4407,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jintr": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/jintr/-/jintr-0.4.1.tgz",
|
||||
"integrity": "sha512-R42VuIoTjsGbZuEmtT7WqyErd9JQuuV17Cg05wQwRWkQbmQNm2zO519Af1Ib7P7SBATqSMbhyu2/VcTnb3TcOg==",
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jintr/-/jintr-1.0.0.tgz",
|
||||
"integrity": "sha512-Kbyb5jiIzmTrbhbdjQGt+jjVzn9BPluvL3mZU5ihFQIEGjCHUA4+rsXE2PNDKmg1UlfdTn3947aSwWOVnc5UIw==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/LuanRT"
|
||||
],
|
||||
@@ -6193,10 +6206,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"node_modules/tsutils": {
|
||||
"version": "3.21.0",
|
||||
@@ -6213,6 +6225,12 @@
|
||||
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
||||
}
|
||||
},
|
||||
"node_modules/tsutils/node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||
@@ -7641,6 +7659,14 @@
|
||||
"requires": {
|
||||
"@yarnpkg/libzip": "^2.2.4",
|
||||
"tslib": "^1.13.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@yarnpkg/libzip": {
|
||||
@@ -7651,6 +7677,14 @@
|
||||
"requires": {
|
||||
"@types/emscripten": "^1.38.0",
|
||||
"tslib": "^1.13.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"acorn": {
|
||||
@@ -9619,9 +9653,9 @@
|
||||
}
|
||||
},
|
||||
"jintr": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/jintr/-/jintr-0.4.1.tgz",
|
||||
"integrity": "sha512-R42VuIoTjsGbZuEmtT7WqyErd9JQuuV17Cg05wQwRWkQbmQNm2zO519Af1Ib7P7SBATqSMbhyu2/VcTnb3TcOg==",
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jintr/-/jintr-1.0.0.tgz",
|
||||
"integrity": "sha512-Kbyb5jiIzmTrbhbdjQGt+jjVzn9BPluvL3mZU5ihFQIEGjCHUA4+rsXE2PNDKmg1UlfdTn3947aSwWOVnc5UIw==",
|
||||
"requires": {
|
||||
"acorn": "^8.8.0"
|
||||
}
|
||||
@@ -10930,10 +10964,9 @@
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "3.21.0",
|
||||
@@ -10942,6 +10975,14 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"type-check": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "youtubei.js",
|
||||
"version": "4.1.0",
|
||||
"version": "4.2.0",
|
||||
"description": "A wrapper around YouTube's private API. Supports YouTube, YouTube Music, YouTube Kids and YouTube Studio (WIP).",
|
||||
"type": "module",
|
||||
"types": "./dist/src/platform/lib.d.ts",
|
||||
@@ -72,7 +72,7 @@
|
||||
"build:proto": "npx pb-gen-ts --entry-path=\"src/proto\" --out-dir=\"src/proto/generated\" --ext-in-import=\".js\"",
|
||||
"build:esm": "npx tsc",
|
||||
"build:deno": "npx cpy ./src ./deno && npx cpy ./package.json ./deno && npx replace \".js';\" \".ts';\" ./deno -r && npx replace '.js\";' '.ts\";' ./deno -r && npx replace \"'linkedom';\" \"'https://esm.sh/linkedom';\" ./deno -r && npx replace \"'jintr';\" \"'https://esm.sh/jintr';\" ./deno -r && npx replace \"new Jinter.default\" \"new Jinter\" ./deno -r",
|
||||
"bundle:node": "npx esbuild ./dist/src/platform/node.js --bundle --target=node10 --keep-names --format=cjs --platform=node --outfile=./bundle/node.cjs --external:jintr --external:undici --external:linkedom --sourcemap --banner:js=\"/* eslint-disable */\"",
|
||||
"bundle:node": "npx esbuild ./dist/src/platform/node.js --bundle --target=node10 --keep-names --format=cjs --platform=node --outfile=./bundle/node.cjs --external:jintr --external:undici --external:linkedom --external:tslib --sourcemap --banner:js=\"/* eslint-disable */\"",
|
||||
"bundle:browser": "npx esbuild ./dist/src/platform/web.js --banner:js=\"/* eslint-disable */\" --bundle --target=chrome58 --keep-names --format=esm --sourcemap --define:global=globalThis --outfile=./bundle/browser.js --platform=browser",
|
||||
"bundle:browser:prod": "npm run bundle:browser -- --outfile=./bundle/browser.min.js --minify",
|
||||
"prepare": "npm run build",
|
||||
@@ -84,8 +84,9 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"jintr": "^0.4.1",
|
||||
"jintr": "^1.0.0",
|
||||
"linkedom": "^0.14.12",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.19.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import Text from './misc/Text.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { RawNode } from '../index.js';
|
||||
|
||||
class PlayerCaptionsTracklist extends YTNode {
|
||||
static type = 'PlayerCaptionsTracklist';
|
||||
|
||||
caption_tracks: {
|
||||
caption_tracks?: {
|
||||
base_url: string;
|
||||
name: Text;
|
||||
vss_id: string;
|
||||
@@ -13,7 +14,7 @@ class PlayerCaptionsTracklist extends YTNode {
|
||||
is_translatable: boolean;
|
||||
}[];
|
||||
|
||||
audio_tracks: {
|
||||
audio_tracks?: {
|
||||
audio_track_id: string;
|
||||
captions_initial_state: string;
|
||||
default_caption_track_index: number;
|
||||
@@ -22,39 +23,48 @@ class PlayerCaptionsTracklist extends YTNode {
|
||||
caption_track_indices: number;
|
||||
}[];
|
||||
|
||||
default_audio_track_index: number;
|
||||
default_audio_track_index?: number;
|
||||
|
||||
translation_languages: {
|
||||
translation_languages?: {
|
||||
language_code: string;
|
||||
language_name: Text;
|
||||
}[];
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.caption_tracks = data.captionTracks.map((ct: any) => ({
|
||||
base_url: ct.baseUrl,
|
||||
name: new Text(ct.name),
|
||||
vss_id: ct.vssId,
|
||||
language_code: ct.languageCode,
|
||||
kind: ct.kind,
|
||||
is_translatable: ct.isTranslatable
|
||||
}));
|
||||
|
||||
this.audio_tracks = data.audioTracks.map((at: any) => ({
|
||||
audio_track_id: at.audioTrackId,
|
||||
captions_initial_state: at.captionsInitialState,
|
||||
default_caption_track_index: at.defaultCaptionTrackIndex,
|
||||
has_default_track: at.hasDefaultTrack,
|
||||
visibility: at.visibility,
|
||||
caption_track_indices: at.captionTrackIndices
|
||||
}));
|
||||
if (Reflect.has(data, 'captionTracks')) {
|
||||
this.caption_tracks = data.captionTracks.map((ct: any) => ({
|
||||
base_url: ct.baseUrl,
|
||||
name: new Text(ct.name),
|
||||
vss_id: ct.vssId,
|
||||
language_code: ct.languageCode,
|
||||
kind: ct.kind,
|
||||
is_translatable: ct.isTranslatable
|
||||
}));
|
||||
}
|
||||
|
||||
this.default_audio_track_index = data.defaultAudioTrackIndex;
|
||||
if (Reflect.has(data, 'audioTracks')) {
|
||||
this.audio_tracks = data.audioTracks.map((at: any) => ({
|
||||
audio_track_id: at.audioTrackId,
|
||||
captions_initial_state: at.captionsInitialState,
|
||||
default_caption_track_index: at.defaultCaptionTrackIndex,
|
||||
has_default_track: at.hasDefaultTrack,
|
||||
visibility: at.visibility,
|
||||
caption_track_indices: at.captionTrackIndices
|
||||
}));
|
||||
}
|
||||
|
||||
this.translation_languages = data.translationLanguages.map((tl: any) => ({
|
||||
language_code: tl.languageCode,
|
||||
language_name: new Text(tl.languageName)
|
||||
}));
|
||||
if (Reflect.has(data, 'defaultAudioTrackIndex')) {
|
||||
this.default_audio_track_index = data.defaultAudioTrackIndex;
|
||||
}
|
||||
|
||||
if (Reflect.has(data, 'translationLanguages')) {
|
||||
this.translation_languages = data.translationLanguages.map((tl: any) => ({
|
||||
language_code: tl.languageCode,
|
||||
language_name: new Text(tl.languageName)
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ class PlaylistVideo extends YTNode {
|
||||
is_playable: boolean;
|
||||
menu: Menu | null;
|
||||
upcoming;
|
||||
video_info: Text;
|
||||
accessibility_label?: string;
|
||||
|
||||
duration: {
|
||||
text: string;
|
||||
@@ -40,6 +42,8 @@ class PlaylistVideo extends YTNode {
|
||||
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
||||
this.is_playable = data.isPlayable;
|
||||
this.menu = Parser.parseItem(data.menu, Menu);
|
||||
this.video_info = new Text(data.videoInfo);
|
||||
this.accessibility_label = data.title.accessibility.accessibilityData.label;
|
||||
|
||||
const upcoming = data.upcomingEventData && Number(`${data.upcomingEventData.startTime}000`);
|
||||
if (upcoming) {
|
||||
|
||||
@@ -497,6 +497,7 @@ export default class Parser {
|
||||
'DisplayAd',
|
||||
'SearchPyv',
|
||||
'MealbarPromo',
|
||||
'PrimetimePromo',
|
||||
'BackgroundPromo',
|
||||
'PromotedSparklesWeb',
|
||||
'RunAttestationCommand',
|
||||
|
||||
@@ -28,8 +28,8 @@ class Library extends Feed<IBrowseResponse> {
|
||||
if (!this.page.contents_memo)
|
||||
throw new InnertubeError('Page contents not found');
|
||||
|
||||
const stats = this.page.contents_memo.getType(ProfileColumnStats)?.[0];
|
||||
const user_info = this.page.contents_memo.getType(ProfileColumnUserInfo)?.[0];
|
||||
const stats = this.page.contents_memo.getType(ProfileColumnStats).first();
|
||||
const user_info = this.page.contents_memo.getType(ProfileColumnUserInfo).first();
|
||||
|
||||
this.profile = { stats, user_info };
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class Search extends Feed<ISearchResponse> {
|
||||
if (!contents)
|
||||
throw new InnertubeError('No contents found in search response');
|
||||
|
||||
this.results = contents.firstOfType(ItemSection)?.contents;
|
||||
this.results = contents.filterType(ItemSection).find((section) => section.contents && section.contents.length > 0)?.contents;
|
||||
|
||||
this.refinements = this.page.refinements || [];
|
||||
this.estimated_results = this.page.estimated_results;
|
||||
|
||||
@@ -13,7 +13,7 @@ class TimeWatched {
|
||||
contents?: ObservedArray<ItemSection>;
|
||||
|
||||
constructor(response: ApiResponse) {
|
||||
this.#page = Parser.parseResponse(response.data);
|
||||
this.#page = Parser.parseResponse<IBrowseResponse>(response.data);
|
||||
|
||||
if (!this.#page.contents)
|
||||
throw new InnertubeError('Page contents not found');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Jinter from 'jintr';
|
||||
import { Jinter } from 'jintr';
|
||||
import { VMPrimative } from '../../types/PlatformShim.js';
|
||||
|
||||
export default function evaluate(code: string, env: Record<string, VMPrimative>) {
|
||||
const runtime = new Jinter.default(code);
|
||||
const runtime = new Jinter(code);
|
||||
for (const [ key, value ] of Object.entries(env)) {
|
||||
runtime.scope.set(key, value);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
"importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
@@ -102,9 +102,7 @@
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.js",
|
||||
"index.ts",
|
||||
"browser.ts"
|
||||
"src/**/*.js"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
||||
Reference in New Issue
Block a user