Compare commits

...

63 Commits

Author SHA1 Message Date
github-actions[bot]
b7cacc34f3 chore(main): release 8.2.0 (#567)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-01-08 20:46:30 -03:00
Brahim Hadriche
8f07e49512 fix(Parser): Add SortFilterHeader (#563)
* Fix for SortFilterHeader

* fix(Settings): Use `YTNode#is` to identify headers with a title

---------

Co-authored-by: LuanRT <luan.lrt4@gmail.com>
2024-01-08 20:37:06 -03:00
Luan
abd8a82cd0 chore(docs): Update auth documentation and examples (#568)
* chore(docs): Update auth documentation and examples

* chore(docs): Minor rewording

* chore(docs): Fix library version in the OAuth2 example
2024-01-08 20:16:16 -03:00
Luan
7ffd0fc25e feat(OAuth): Allow passing custom client identity (#566) 2024-01-08 20:03:01 -03:00
github-actions[bot]
b50408fc1c chore(main): release 8.1.0 (#548)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-12-26 23:24:27 -03:00
Brahim Hadriche
9618f38fe1 fear(parser): Add DecoratedAvatarView (#544)
* Add DecoratedAvatarView

* Export the class

* Update PageHeaderView

* Adjust thumbnails

* Add avatar view

* Apply suggestions from code review

---------

Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
2023-12-26 23:21:37 -03:00
LuanRT
e7efec2cf4 Merge branch 'main' of https://github.com/LuanRT/YouTube.js 2023-12-26 23:17:19 -03:00
LuanRT
82d5d1e3e1 chore: Fix import formatting in multiple files 2023-12-26 23:16:45 -03:00
LuanRT
9c503f4fa8 fix(VideoInfo): Restore like, dislike & removeRating methods 2023-12-26 23:15:31 -03:00
RenautMestdagh
4dd977e375 Update interaction-manager.md (#562) 2023-12-26 21:36:55 -03:00
Daniel Wykerd
e4f2a00c84 feat(generator): add support for arrays (#556)
* feat(generator): add support for arrays

* fix(parser): add overload for non array validTypes

Add Parser#parse overload to support non array validTypes.

Fixes issue in generator generating invalid Parser#parse calls
introduced in #551.
2023-12-21 19:02:44 -03:00
absidue
fcd3044982 feat(parser): Support new like and dislike nodes (#557) 2023-12-21 19:02:19 -03:00
Brahim Hadriche
14578ac96a feat(YouTube): Add FEchannels feed (#560) 2023-12-21 19:00:31 -03:00
absidue
5c83e999df fix(Format): Extract correct audio language from captions (#553) 2023-12-07 08:46:05 -03:00
LuanRT
4e67240ff9 chore(FeedNudge): Add Text import 2023-12-04 15:51:09 -03:00
absidue
f938c34ee8 feat(generator): Add support for generating view models (#550) 2023-12-04 15:46:09 -03:00
absidue
bd487f8bef fix(generator): Output Parser.parseItem() calls with one valid type, without the array (#551) 2023-12-04 15:45:38 -03:00
absidue
48a5d4e7c3 feat(Thumbnail): Support sources in Thumbnail.fromResponse (#552) 2023-12-04 13:50:08 -03:00
absidue
37ae55a7c3 chore(protobuf): Commit generated files missing from #512 (#549)
Co-authored-by: Konstantin <duell10111@t-online.de>
2023-12-02 11:35:05 -03:00
LuanRT
923232de07 chore(PlayerConfig): Add default value to some fields 2023-12-01 17:56:25 -03:00
LuanRT
a1c3ef8fbb Merge branch 'main' of https://github.com/LuanRT/YouTube.js 2023-12-01 17:15:07 -03:00
LuanRT
5c9c231cc2 feat(MediaInfo): Parse player config 2023-12-01 17:14:36 -03:00
github-actions[bot]
572e16c541 chore(main): release 8.0.0 (#530)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-12-01 00:54:29 -03:00
LuanRT
ed2cbf8a13 chore: lint 2023-12-01 00:50:26 -03:00
LuanRT
4261915fd4 fix(Library)!: Add support for the new layout and remove profile & stats info 2023-12-01 00:49:22 -03:00
LuanRT
f74ed5a1cf fix(StructuredDescriptionContent): Add ReelShelf to list of possible nodes 2023-11-30 23:36:32 -03:00
LuanRT
5ae15be63d fix(VideoAttributeView): Fix image and overflow_menu_on_tap props 2023-11-30 23:34:31 -03:00
Konstantin
a32aa8c633 feat: Add Shorts endpoint (#512)
* chore: first try for shorts endpoints

* chore: add shorts to index

* fix: fix code style

* chore: fix suggestions

* fix: fix code style with spaces on curly brackets

* chore: add curly rule to eslint

* chore: run request in parallel

* chore: remove console.logs and add other expect tests

* chore: apply eslint suggestions

* Update ReelPlayerOverlay.ts

* Update VideoInfo.ts

* chore: remove console.log from tests

---------

Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
Co-authored-by: LuanRT <luan.lrt4@gmail.com>
2023-11-30 22:58:11 -03:00
absidue
4806fc6c11 feat(toDash): Add contentType to audio and video adaption sets (#539) 2023-11-30 22:33:13 -03:00
absidue
95ed60207a perf: Use named Parser import, to allow bundlers to create direct function references (#535)
Co-authored-by: Luan <luan.lrt4@gmail.com>
2023-11-30 22:31:59 -03:00
absidue
b50e2001aa chore: Clean up so unneeded private properties (#540) 2023-11-30 22:21:14 -03:00
absidue
b60930a0c1 feat(parser): Add ChannelOwnerEmptyState (#541) 2023-11-30 22:12:11 -03:00
absidue
c66eb1fecf feat(Channel): Support new about popup (#537)
* feat(Channel): Support new about popup

* chore: Minor cleanup

* fix(concatMemos): Merge duplicate nodes instead of overwriting

* fix(Feed): `has_continuation` and `getContinuation()` avoid header continuations

* chore(Channel): Remove unused import

---------

Co-authored-by: LuanRT <luan.lrt4@gmail.com>
2023-11-30 22:06:25 -03:00
absidue
6a5a579e39 fix(Channel)!: Remove getChannels() and has_channels, as YouTube removed the tab (#542)
BREAKING CHANGE: YouTube removed the "Channels" tab on channels, so this
pull request removes the `getChannels()` method and `has_channels`
getter from the `YT.Channel` class, as they are no longer useful. The
featured channels are now shown on the channel home tab. To get them
you can use the `channels` getter on the home tab of the channel.
Please note that some channel owners might not have added that section
to their home page yet, so you won't be able to get the featured
channels for those channels. The home tab is the default tab that is
returned when you call `InnerTube#getChannel()`, you can also access
that tab by calling `getHome()` on a `YT.Channel` object.
2023-11-30 22:03:36 -03:00
JellyBrick
ff4ab1680e feat: add VideoAttributeView (#531)
* feat: add `VideoAttributeView`

* fix: remove `logging_directives`

See https://github.com/LuanRT/YouTube.js/pull/531#discussion_r1375315550

* fix: Update src/parser/classes/VideoAttributeView.ts

---------

Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
Co-authored-by: Luan <luan.lrt4@gmail.com>
2023-11-30 21:38:51 -03:00
JellyBrick
9007b65237 feat(Parser): Add ClipSection (#532)
* feat: add `ClipSection`

* fix: Update src/parser/classes/ClipCreation.ts

---------

Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
2023-11-30 21:29:18 -03:00
JellyBrick
e02139532b feat: add FeedNudge (#533)
* feat: add `FeedNudge`

see https://github.com/LuanRT/YouTube.js/actions/runs/6679090140/job/18150827068?pr=532

* fix: lint

* fix: update parser-map
2023-10-29 09:51:25 -03:00
JellyBrick
db7f6209b2 feat: Use overrides instead of --legacy-peer-deps (#529) 2023-10-28 16:32:39 -03:00
github-actions[bot]
312c636ec4 chore(main): release 7.0.0 (#528)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-28 15:21:53 -03:00
Azarattum
4c0de199e8 fix(build): Inline package.json import to avoid runtime erros (#509)
* chore(main): Inline package.json import

* chore: add `--legacy-peer-deps` flag to ci

* chore: update lock file

---------

Co-authored-by: LuanRT <luan.lrt4@gmail.com>
2023-10-28 15:19:37 -03:00
Ryan Sandbach
9ab528ec82 feat(Kids): Add blockChannel command to easily block channels (#503)
* Add blockChannel command to support easily blocking content for supervised accounts.

* Moved blockChannel functionality to the Kids client and updated API docs.

* Fix whitepsace issues.

* Resolve remaining linting errors.

* Avoid changing interaction manager. Remove comment for ToggleButton change.

* chore: clean up

---------

Co-authored-by: LuanRT <luan.lrt4@gmail.com>
2023-10-28 14:28:17 -03:00
LuanRT
24ffb01aef Merge branch 'main' of https://github.com/LuanRT/YouTube.js 2023-10-28 13:31:10 -03:00
LuanRT
eaac38c919 chore: lint 2023-10-28 13:30:58 -03:00
absidue
e627887fe0 chore(MediaInfo): Throw helpful errors when calling toDash or download for live and Post-Live DVR videos (#526)
* Address pull request feedback

---------

Co-authored-by: LuanRT <luan.lrt4@gmail.com>
2023-10-28 13:29:37 -03:00
LuanRT
beaa28f4c6 feat(music#getSearchSuggestions)!: Return array of SearchSuggestionsSection instead of a single node 2023-10-28 13:27:58 -03:00
LuanRT
a45273fec4 feat(parser): Add PlayerOverflow and PlayerControlsOverlay 2023-10-28 13:17:26 -03:00
absidue
bc97e07ac6 feat(UpdateViewerShipAction): Add original_view_count and unlabeled_view_count_value (#527) 2023-10-21 12:39:03 -03:00
LuanRT
f35b4c2c8c Merge branch 'main' of https://github.com/LuanRT/YouTube.js 2023-10-18 23:32:01 -03:00
LuanRT
c934325648 chore: update readme [skip ci] 2023-10-18 23:31:03 -03:00
dependabot[bot]
cd27acd25b chore(deps-dev): bump @babel/traverse from 7.22.10 to 7.23.2 (#524)
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.10 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-16 22:55:44 -03:00
dependabot[bot]
83b42d2585 chore(deps): bump undici from 5.23.0 to 5.26.2 (#523)
Bumps [undici](https://github.com/nodejs/undici) from 5.23.0 to 5.26.2.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v5.23.0...v5.26.2)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-16 17:36:00 -03:00
github-actions[bot]
e54c0c4bf1 chore(main): release 6.4.1 (#507)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-02 00:04:10 -03:00
LuanRT
8e372d5c67 fix(Feed): Do not throw when multiple continuations are present 2023-10-01 23:39:54 -03:00
LuanRT
987f50604a fix(Playlist): Throw a more helpful error when parsing empty responses 2023-10-01 23:31:05 -03:00
Luan
69702085c6 refactor: Move transcript logic to MediaInfo (#511)
* refactor: Move transcript logic to `MediaInfo`

+ Add support for retrieving different languages.

* docs: Update and add examples
2023-09-17 22:17:14 -03:00
absidue
d2959b3a55 perf: Cache deciphered n-params by info response (#505) 2023-09-17 18:52:32 -03:00
absidue
68df321858 perf(generator): Remove duplicate checks in isMiscType (#506) 2023-09-15 15:25:08 -03:00
Ryan Sandbach
f4bc8508d0 chore(docs): Minor update (#502)
* Updated documentation example to matche syntax of existing parsers.

* Changed from require since package is setup as module.
2023-09-12 03:49:36 -03:00
LuanRT
e216124bb0 chore: update docs 2023-09-10 02:14:14 -03:00
github-actions[bot]
6d98abbd53 chore(main): release 6.4.0 (#499)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-09-10 02:08:24 -03:00
LuanRT
fba3fc9714 fix(BackstagePost): vote_button type mismatch 2023-09-10 02:06:01 -03:00
Luan
f94ea6cf91 feat: Add support for retrieving transcripts (#500)
* feat: Add support for retrieving transcripts

* chore: lint

* chore: update docs

* chore: Do not include nodes in errors thrown

* chore: Improve error messages

* fix(ExpandableMetadata): `expanded_content` type mismatch

* chore: lint
2023-09-10 01:50:30 -03:00
Jeremy Banks
86fb33ed03 feat(PlaylistManager): add .setName() and .setDescription() functions for editing playlists (#498) 2023-09-01 17:40:25 -03:00
319 changed files with 7713 additions and 1943 deletions

View File

@@ -79,6 +79,7 @@ rules:
prefer-template: error
keyword-spacing: ["error", { "before": true } ]
object-curly-spacing: ["warn", "always"]
array-bracket-spacing: ["error", "always"]
arrow-parens: ["error", "always"]
comma-dangle: ["error", "never"]

View File

@@ -1,5 +1,114 @@
# Changelog
## [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)
### Features
* **generator:** add support for arrays ([#556](https://github.com/LuanRT/YouTube.js/issues/556)) ([e4f2a00](https://github.com/LuanRT/YouTube.js/commit/e4f2a00c843fe453cc7904f79e35597cc6e2e619))
* **generator:** Add support for generating view models ([#550](https://github.com/LuanRT/YouTube.js/issues/550)) ([f938c34](https://github.com/LuanRT/YouTube.js/commit/f938c34ee81186774096b3d24d06250211ce2851))
* **MediaInfo:** Parse player config ([5c9c231](https://github.com/LuanRT/YouTube.js/commit/5c9c231cc2f17c49da03daa8262043b985320e9a))
* **parser:** Support new like and dislike nodes ([#557](https://github.com/LuanRT/YouTube.js/issues/557)) ([fcd3044](https://github.com/LuanRT/YouTube.js/commit/fcd30449821763e9b5b57718dd02eff15d964d2b))
* **Thumbnail:** Support `sources` in `Thumbnail.fromResponse` ([#552](https://github.com/LuanRT/YouTube.js/issues/552)) ([48a5d4e](https://github.com/LuanRT/YouTube.js/commit/48a5d4e7c37b76f8980f9b68e8815aef7a6d91ab))
* **YouTube:** Add FEchannels feed ([#560](https://github.com/LuanRT/YouTube.js/issues/560)) ([14578ac](https://github.com/LuanRT/YouTube.js/commit/14578ac96af4b8bee652cce87d043173de964113))
### Bug Fixes
* **Format:** Extract correct audio language from captions ([#553](https://github.com/LuanRT/YouTube.js/issues/553)) ([5c83e99](https://github.com/LuanRT/YouTube.js/commit/5c83e999dfa00386d18369f42aa9aa10123ba578))
* **generator:** Output Parser.parseItem() calls with one valid type, without the array ([#551](https://github.com/LuanRT/YouTube.js/issues/551)) ([bd487f8](https://github.com/LuanRT/YouTube.js/commit/bd487f8befe7f62022c61ff3aae7f487104e81eb))
* **VideoInfo:** Restore `like`, `dislike` & `removeRating` methods ([9c503f4](https://github.com/LuanRT/YouTube.js/commit/9c503f4fa8a750558cedbeca974faf36e304147e))
## [8.0.0](https://github.com/LuanRT/YouTube.js/compare/v7.0.0...v8.0.0) (2023-12-01)
### ⚠ BREAKING CHANGES
* **Library:** Add support for the new layout and remove profile & stats info
* **Channel:** YouTube removed the "Channels" tab on channels, so this pull request removes the `getChannels()` method and `has_channels` getter from the `YT.Channel` class, as they are no longer useful. The featured channels are now shown on the channel home tab. To get them you can use the `channels` getter on the home tab of the channel. Please note that some channel owners might not have added that section to their home page yet, so you won't be able to get the featured channels for those channels. The home tab is the default tab that is returned when you call `InnerTube#getChannel()`, you can also access that tab by calling `getHome()` on a `YT.Channel` object.
### Features
* add `FeedNudge` ([#533](https://github.com/LuanRT/YouTube.js/issues/533)) ([e021395](https://github.com/LuanRT/YouTube.js/commit/e02139532b2c07aaf72dd1bd8610f63b6780001d))
* add `VideoAttributeView` ([#531](https://github.com/LuanRT/YouTube.js/issues/531)) ([ff4ab16](https://github.com/LuanRT/YouTube.js/commit/ff4ab1680e110fc32e09d09215fd3e05dbde2c85))
* Add Shorts endpoint ([#512](https://github.com/LuanRT/YouTube.js/issues/512)) ([a32aa8c](https://github.com/LuanRT/YouTube.js/commit/a32aa8c633b6f3c3bb0695ad1878cbb313867346))
* **Channel:** Support new about popup ([#537](https://github.com/LuanRT/YouTube.js/issues/537)) ([c66eb1f](https://github.com/LuanRT/YouTube.js/commit/c66eb1fecf0e66d9eca841be0ca56b39ad4466eb))
* **parser:** Add `ChannelOwnerEmptyState` ([#541](https://github.com/LuanRT/YouTube.js/issues/541)) ([b60930a](https://github.com/LuanRT/YouTube.js/commit/b60930a0c1ce419dddb753846c84d4e46ddf04e1))
* **Parser:** Add `ClipSection` ([#532](https://github.com/LuanRT/YouTube.js/issues/532)) ([9007b65](https://github.com/LuanRT/YouTube.js/commit/9007b652375e1ca3c3844bdf091fe3670f98dc2c))
* **toDash:** Add `contentType` to audio and video adaption sets ([#539](https://github.com/LuanRT/YouTube.js/issues/539)) ([4806fc6](https://github.com/LuanRT/YouTube.js/commit/4806fc6c112cb3cf0584f7d253f3c4aeaffa9927))
* Use `overrides` instead of `--legacy-peer-deps` ([#529](https://github.com/LuanRT/YouTube.js/issues/529)) ([db7f620](https://github.com/LuanRT/YouTube.js/commit/db7f6209b2329bf18b8b35aababfdb9b750c3b0f))
### Bug Fixes
* **Channel:** Remove `getChannels()` and `has_channels`, as YouTube removed the tab ([#542](https://github.com/LuanRT/YouTube.js/issues/542)) ([6a5a579](https://github.com/LuanRT/YouTube.js/commit/6a5a579e3947109af0e7c2a318aef40edb8484f8))
* **Library:** Add support for the new layout and remove profile & stats info ([4261915](https://github.com/LuanRT/YouTube.js/commit/4261915fd4aa84f7619a45d678910be0ae30e13e))
* **StructuredDescriptionContent:** Add `ReelShelf` to list of possible nodes ([f74ed5a](https://github.com/LuanRT/YouTube.js/commit/f74ed5a1cf352a7b57fa84b9373f9ed9ba1911fc))
* **VideoAttributeView:** Fix `image` and `overflow_menu_on_tap` props ([5ae15be](https://github.com/LuanRT/YouTube.js/commit/5ae15be63dee2a2393a1aa2a308ca5378140760a))
### Performance Improvements
* Use named Parser import, to allow bundlers to create direct function references ([#535](https://github.com/LuanRT/YouTube.js/issues/535)) ([95ed602](https://github.com/LuanRT/YouTube.js/commit/95ed60207a1219f4891f28d2b2b90cf816f11831))
## [7.0.0](https://github.com/LuanRT/YouTube.js/compare/v6.4.1...v7.0.0) (2023-10-28)
### ⚠ BREAKING CHANGES
* **music#getSearchSuggestions:** Return array of `SearchSuggestionsSection` instead of a single node
### Features
* **Kids:** Add `blockChannel` command to easily block channels ([#503](https://github.com/LuanRT/YouTube.js/issues/503)) ([9ab528e](https://github.com/LuanRT/YouTube.js/commit/9ab528ec823dcd527a97150009eed632c6d3eb6a))
* **music#getSearchSuggestions:** Return array of `SearchSuggestionsSection` instead of a single node ([beaa28f](https://github.com/LuanRT/YouTube.js/commit/beaa28f4c68de8366caa84ce5a026bf9e12e1b9d))
* **parser:** Add `PlayerOverflow` and `PlayerControlsOverlay` ([a45273f](https://github.com/LuanRT/YouTube.js/commit/a45273fec498df87eecd364ffb708c9f787793d5))
* **UpdateViewerShipAction:** Add `original_view_count` and `unlabeled_view_count_value` ([#527](https://github.com/LuanRT/YouTube.js/issues/527)) ([bc97e07](https://github.com/LuanRT/YouTube.js/commit/bc97e07ac6d1cdc45194e214c6001cf92190e1d5))
### Bug Fixes
* **build:** Inline package.json import to avoid runtime erros ([#509](https://github.com/LuanRT/YouTube.js/issues/509)) ([4c0de19](https://github.com/LuanRT/YouTube.js/commit/4c0de199e85dd5cc8b3719920b24dec9613acaab))
## [6.4.1](https://github.com/LuanRT/YouTube.js/compare/v6.4.0...v6.4.1) (2023-10-02)
### Bug Fixes
* **Feed:** Do not throw when multiple continuations are present ([8e372d5](https://github.com/LuanRT/YouTube.js/commit/8e372d5c67f148be288bb0485f2c70ec43fbecd0))
* **Playlist:** Throw a more helpful error when parsing empty responses ([987f506](https://github.com/LuanRT/YouTube.js/commit/987f50604a0163f9a07091ce787995c6f6fddb75))
### Performance Improvements
* Cache deciphered n-params by info response ([#505](https://github.com/LuanRT/YouTube.js/issues/505)) ([d2959b3](https://github.com/LuanRT/YouTube.js/commit/d2959b3a55a5081295da4754627913933bbaf1e7))
* **generator:** Remove duplicate checks in `isMiscType` ([#506](https://github.com/LuanRT/YouTube.js/issues/506)) ([68df321](https://github.com/LuanRT/YouTube.js/commit/68df3218580db10c9a0932c93ff2ce487526ff1e))
## [6.4.0](https://github.com/LuanRT/YouTube.js/compare/v6.3.0...v6.4.0) (2023-09-10)
### Features
* Add support for retrieving transcripts ([#500](https://github.com/LuanRT/YouTube.js/issues/500)) ([f94ea6c](https://github.com/LuanRT/YouTube.js/commit/f94ea6cf917f63f30dd66514b22a4cf43b948f07))
* **PlaylistManager:** add .setName() and .setDescription() functions for editing playlists ([#498](https://github.com/LuanRT/YouTube.js/issues/498)) ([86fb33e](https://github.com/LuanRT/YouTube.js/commit/86fb33ed03a127d9fd4caa695ca97642bffe61bd))
### Bug Fixes
* **BackstagePost:** `vote_button` type mismatch ([fba3fc9](https://github.com/LuanRT/YouTube.js/commit/fba3fc971454d66d80d4920fbd60889a221de381))
## [6.3.0](https://github.com/LuanRT/YouTube.js/compare/v6.2.0...v6.3.0) (2023-08-31)

View File

@@ -171,7 +171,7 @@ import dashjs from 'dashjs';
const youtube = await Innertube.create({ /* setup - see above */ });
// get the video info
// Get the video info
const videoInfo = await youtube.getInfo('videoId');
// now convert to a dash manifest
@@ -191,7 +191,7 @@ const player = dashjs.MediaPlayer().create();
player.initialize(videoElement, uri, true);
```
A fully working example can be found in [`examples/browser/web`](https://github.com/LuanRT/YouTube.js/blob/main/examples/browser/web). Alternatively, you can view it live at [ytjsexample.pages.dev](https://ytjsexample.pages.dev/).
A fully working example can be found in [`examples/browser/web`](https://github.com/LuanRT/YouTube.js/blob/main/examples/browser/web).
<a name="custom-fetch"></a>
@@ -325,6 +325,9 @@ Retrieves video info.
- `<info>#download(options)`
- Downloads the video. See [download](#download).
- `<info>#getTranscript()`
- Retrieves the video's transcript.
- `<info>#filters`
- Returns filters that can be applied to the watch next feed.

View File

@@ -12,7 +12,7 @@ Handles direct interactions.
* [.unsubscribe(video_id)](#unsubscribe)
* [.comment(video_id, text)](#comment)
* [.translate(text, target_language, args?)](#translate)
* [.setNotificationPreferences(channel_id, type)](#setnotificationpreferences)
* [.setNotificationPreferences(channel_id, type)](#setnotificationpreferences)
<a name="like"></a>
### like(video_id)
@@ -37,7 +37,7 @@ Dislikes given video.
| video_id | `string` | Video id |
<a name="removerating"></a>
### removeLike(video_id)
### removeRating(video_id)
Remover like/dislike.
@@ -105,4 +105,4 @@ Only works with channels you are subscribed to.
| Param | Type | Description |
| --- | --- | --- |
| channel_id | `string` | Channel id |
| type | `string` | `PERSONALIZED`, `ALL` or `NONE` |
| type | `string` | `PERSONALIZED`, `ALL` or `NONE` |

View File

@@ -9,6 +9,7 @@ YouTube Kids is a modified version of the YouTube app, with a simplified interfa
* [.getInfo(video_id)](#getinfo)
* [.getChannel(channel_id)](#getchannel)
* [.getHomeFeed()](#gethomefeed)
* [.blockChannel(channel_id)](#blockchannel)
<a name="search"></a>
### search(query)
@@ -110,4 +111,17 @@ Retrieves the home feed.
- Returns available categories.
- `<feed>#page`
- Returns the original InnerTube response(s), parsed and sanitized.
- Returns the original InnerTube response(s), parsed and sanitized.
</details>
<a name="blockChannel"></a>
### blockChannel(channel_id)
Retrieves the list of supervised accounts that the signed-in user has access to and blocks the given channel for each of them.
**Returns:** `Promise.<ApiResponse[]>`
| Param | Type | Description |
| --- | --- | --- |
| channel_id | `string` | Channel id |

View File

@@ -10,6 +10,8 @@ Playlist management class.
* [.addVideos(playlist_id, video_ids)](#addvideos)
* [.removeVideos(playlist_id, video_ids)](#removevideos)
* [.moveVideo(playlist_id, moved_video_id, predecessor_video_id)](#movevideo)
* [.setName(playlist_id, name)](#setname)
* [.setDescription(playlist_id, description)](#setdescription)
<a name="create"></a>
### create(title, video_ids)
@@ -69,4 +71,29 @@ Moves a video to a new position within a given playlist.
| --- | --- | --- |
| playlist_id | `string` | Playlist id |
| moved_video_id | `string` | the video to be moved |
| predecessor_video_id | `string` | the video present in the target position |
| predecessor_video_id | `string` | the video present in the target position |
<a name="setname"></a>
### setName(playlist_id, name)
Sets the name / title for the given playlist.
**Returns:** `Promise.<ApiResponse>`
| Param | Type | Description |
| --- | --- | --- |
| playlist_id | `string` | Playlist id |
| name | `string` | Name / title |
<a name="setdescription"></a>
### setDescription(playlist_id, description)
Sets the description for the given playlist.
**Returns:** `Promise.<ApiResponse>`
| Param | Type | Description |
| --- | --- | --- |
| playlist_id | `string` | Playlist id |
| description | `string` | Description |

View File

@@ -31,24 +31,22 @@ For example, suppose we have found a new renderer named `verticalListRenderer`.
> `../classes/VerticalList.ts`
```ts
import Parser from '..';
import { YTNode } from '../helpers';
import type { RawNode } from '../index.js';
import { Parser, RawNode } from '../index.js';
import { YTNode } from '../helpers.js';
class VerticalList extends YTNode {
export default class VerticalList extends YTNode {
static type = 'VerticalList';
header;
contents;
constructor(data: RawNode) {
super();
// parse the data here, ex;
this.header = Parser.parseItem(data.header);
this.contents = Parser.parseArray(data.contents);
}
}
export default VerticalList;
```
You may use the parser's generated class for the new renderer as a starting point for your own implementation.

View File

@@ -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: '...'
});
```

View 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}`);
});

View 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"
}
}

View 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. */
}
}

View File

@@ -1,4 +1,4 @@
const { Innertube, UniversalCache } = require('youtubei.js');
import { Innertube, UniversalCache } from 'youtubei.js';
(async () => {
const yt = await Innertube.create({

View File

@@ -0,0 +1,23 @@
import { Innertube, UniversalCache } from 'youtubei.js';
(async () => {
const yt = await Innertube.create({ cache: new UniversalCache(true, './credcache') });
yt.session.on('auth-pending', (data) => {
console.log(`Go to ${data.verification_url} in your browser and enter code ${data.user_code} to authenticate.`);
});
yt.session.on('auth', async () => {
console.log('Sign in successful');
await yt.session.oauth.cacheCredentials();
});
yt.session.on('update-credentials', async () => {
await yt.session.oauth.cacheCredentials();
});
// Attempt to sign in
await yt.session.signIn();
// Block Channel for all kids / profiles on the signed-in account.
const resp = await yt.kids.blockChannel('UCpbpfcZfo-hoDAx2m1blFhg');
console.info('Blocked channel for ', resp.length, ' profiles.');
})();

View File

@@ -58,6 +58,4 @@ After that, you can use the library as normal.
## Example
We've got a full example in `examples/browser/web` using vite.
If you don't want to run the example yourself, you can see it in action here: [ytjsexample.pages.dev](https://ytjsexample.pages.dev/).
We've got a full example in `examples/browser/web` using vite.

View File

@@ -0,0 +1,16 @@
import { Innertube } from 'youtubei.js';
(async () => {
const yt = await Innertube.create({ generate_session_locally: true });
const info = await yt.getInfo('hePb00CqvP0');
const defaultTranscriptInfo = await info.getTranscript();
console.log(`Got ${defaultTranscriptInfo.selectedLanguage} transcript with ${defaultTranscriptInfo.transcript.content.body.initial_segments.length} lines.`);
console.log("Fetching Hebrew transcript...");
const heTranscriptInfo = await defaultTranscriptInfo.selectLanguage('Hebrew');
console.log(`Got ${heTranscriptInfo.selectedLanguage} transcript with ${heTranscriptInfo.transcript.content.body.initial_segments.length} lines.`);
})();

5695
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "youtubei.js",
"version": "6.3.0",
"version": "8.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",
@@ -71,7 +71,7 @@
"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: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 tsc",
"build:esm": "npx tspc",
"build:deno": "npx cpy ./src ./deno && npx esbuild ./src/utils/DashManifest.tsx --keep-names --format=esm --platform=neutral --target=es2020 --outfile=./deno/src/utils/DashManifest.js && npx cpy ./package.json ./deno && npx replace \".js';\" \".ts';\" ./deno -r && npx replace '.js\";' '.ts\";' ./deno -r && npx replace \"'./DashManifest.ts';\" \"'./DashManifest.js';\" ./deno -r && npx replace \"'jintr';\" \"'https://esm.sh/jintr';\" ./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 --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",
@@ -89,6 +89,9 @@
"tslib": "^2.5.0",
"undici": "^5.19.1"
},
"overrides": {
"typescript": "^5.0.0"
},
"devDependencies": {
"@types/glob": "^8.1.0",
"@types/jest": "^28.1.7",
@@ -104,6 +107,8 @@
"pbkit": "^0.0.59",
"replace": "^1.2.2",
"ts-jest": "^28.0.8",
"ts-patch": "^3.0.2",
"ts-transformer-inline-file": "^0.2.0",
"typescript": "^5.0.0"
},
"bugs": {

View File

@@ -14,6 +14,7 @@ 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';
@@ -30,15 +31,17 @@ import {
NextEndpoint,
PlayerEndpoint,
ResolveURLEndpoint,
SearchEndpoint
SearchEndpoint,
Reel
} from './core/endpoints/index.js';
import { GetUnseenCountEndpoint } from './core/endpoints/notification/index.js';
import type { ApiResponse } from './core/Actions.js';
import type { IBrowseResponse, IParsedResponse } from './parser/types/index.js';
import { type IBrowseResponse, type IParsedResponse } from './parser/types/index.js';
import type { INextRequest } from './types/index.js';
import type { DownloadOptions, FormatOptions } from './types/FormatUtils.js';
import { encodeReelSequence } from './proto/index.js';
export type InnertubeConfig = SessionOptions;
@@ -131,6 +134,32 @@ export default class Innertube {
return new VideoInfo([ response ], this.actions, cpn);
}
/**
* Retrieves shorts info.
* @param short_id - The short id.
* @param client - The client to use.
*/
async getShortsWatchItem(short_id: string, client?: InnerTubeClient): Promise<ShortsVideoInfo> {
throwIfMissing({ short_id });
const watchResponse = this.actions.execute(
Reel.WatchEndpoint.PATH, Reel.WatchEndpoint.build({
short_id: short_id,
client: client
})
);
const sequenceResponse = this.actions.execute(
Reel.WatchSequenceEndpoint.PATH, Reel.WatchSequenceEndpoint.build({
sequenceParams: encodeReelSequence(short_id)
})
);
const response = await Promise.all([ watchResponse, sequenceResponse ]);
return new ShortsVideoInfo(response, this.actions);
}
/**
* Searches a given query.
* @param query - The search query.
@@ -251,6 +280,16 @@ export default class Innertube {
return new Feed(this.actions, response);
}
/**
* Retrieves channels feed.
*/
async getChannelsFeed(): Promise<Feed<IBrowseResponse>> {
const response = await this.actions.execute(
BrowseEndpoint.PATH, { ...BrowseEndpoint.build({ browse_id: 'FEchannels' }), parse: true }
);
return new Feed(this.actions, response);
}
/**
* Retrieves contents for a given channel.
* @param id - Channel id

View File

@@ -1,4 +1,4 @@
import Parser, { NavigateAction } from '../parser/index.js';
import { Parser, NavigateAction } from '../parser/index.js';
import { InnertubeError } from '../utils/Utils.js';
import type Session from './Session.js';
@@ -16,7 +16,7 @@ export interface ApiResponse {
data: IRawResponse;
}
export type InnertubeEndpoint = '/player' | '/search' | '/browse' | '/next' | '/updated_metadata' | '/notification/get_notification_menu' | string;
export type InnertubeEndpoint = '/player' | '/search' | '/browse' | '/next' | '/reel' | '/updated_metadata' | '/notification/get_notification_menu' | string;
export type ParsedResponse<T> =
T extends '/player' ? IPlayerResponse :
@@ -167,6 +167,7 @@ export default class Actions {
'FElibrary',
'FEhistory',
'FEsubscriptions',
'FEchannels',
'FEmusic_listening_review',
'FEmusic_library_landing',
'SPaccount_overview',

View File

@@ -2,6 +2,9 @@ import * as Constants from '../utils/Constants.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,6 +39,11 @@ 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 {
#identity?: Record<string, string>;
#session: Session;
@@ -71,6 +87,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 +175,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 +226,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 +248,14 @@ 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) {
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();
@@ -241,7 +270,7 @@ export default class OAuth {
.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' });

View File

@@ -66,7 +66,7 @@ export default class Player {
return await Player.fromSource(cache, sig_timestamp, sig_sc, nsig_sc, player_id);
}
decipher(url?: string, signature_cipher?: string, cipher?: string): string {
decipher(url?: string, signature_cipher?: string, cipher?: string, this_response_nsig_cache?: Map<string, string>): string {
url = url || signature_cipher || cipher;
if (!url)
@@ -93,15 +93,23 @@ export default class Player {
const n = url_components.searchParams.get('n');
if (n) {
const nsig = Platform.shim.eval(this.#nsig_sc, {
nsig: n
});
let nsig;
if (typeof nsig !== 'string')
throw new PlayerError('Failed to decipher nsig');
if (this_response_nsig_cache && this_response_nsig_cache.has(n)) {
nsig = this_response_nsig_cache.get(n) as string;
} else {
nsig = Platform.shim.eval(this.#nsig_sc, {
nsig: n
});
if (nsig.startsWith('enhanced_except_')) {
console.warn('Warning:\nCould not transform nsig, download may be throttled.\nChanging the InnerTube client to "ANDROID" might help!');
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!');
} else if (this_response_nsig_cache) {
this_response_nsig_cache.set(n, nsig);
}
}
url_components.searchParams.set('n', nsig);

View File

@@ -1,16 +1,22 @@
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 { generateRandomString } from '../../utils/Utils.js';
import { InnertubeError, generateRandomString } from '../../utils/Utils.js';
import {
BrowseEndpoint, NextEndpoint,
PlayerEndpoint, SearchEndpoint
} from '../endpoints/index.js';
import { BlocklistPickerEndpoint } from '../endpoints/kids/index.js';
import KidsBlocklistPickerItem from '../../parser/classes/ytkids/KidsBlocklistPickerItem.js';
export default class Kids {
#session: Session;
@@ -80,4 +86,38 @@ export default class Kids {
);
return new HomeFeed(this.#session.actions, response);
}
/**
* Retrieves the list of supervised accounts that the signed-in user has
* access to, and blocks the given channel for each of them.
* @param channel_id - The channel id to block.
* @returns A list of API responses.
*/
async blockChannel(channel_id: string): Promise<ApiResponse[]> {
if (!this.#session.logged_in)
throw new InnertubeError('You must be signed in to perform this operation.');
const blocklist_payload = BlocklistPickerEndpoint.build({ channel_id: channel_id });
const response = await this.#session.actions.execute(BlocklistPickerEndpoint.PATH, blocklist_payload );
const popup = response.data.command.confirmDialogEndpoint;
const popup_fragment = { contents: popup.content, engagementPanels: [] };
const kid_picker = Parser.parseResponse(popup_fragment);
const kids = kid_picker.contents_memo?.getType(KidsBlocklistPickerItem);
if (!kids)
throw new InnertubeError('Could not find any kids profiles or supervised accounts.');
// Iterate through the kids and block the channel if not already blocked.
const responses: ApiResponse[] = [];
for (const kid of kids) {
if (!kid.block_button?.is_toggled) {
kid.setActions(this.#session.actions);
// Block channel and add to the response list.
responses.push(await kid.blockChannel());
}
}
return responses;
}
}

View File

@@ -20,7 +20,7 @@ import SectionList from '../../parser/classes/SectionList.js';
import Tab from '../../parser/classes/Tab.js';
import * as Proto from '../../proto/index.js';
import type { ObservedArray, YTNode } from '../../parser/helpers.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';
@@ -355,17 +355,17 @@ export default class Music {
* Retrieves search suggestions for the given query.
* @param query - The query.
*/
async getSearchSuggestions(query: string): Promise<ObservedArray<YTNode>> {
async getSearchSuggestions(query: string): Promise<ObservedArray<SearchSuggestionsSection>> {
const response = await this.#actions.execute(
GetSearchSuggestionsEndpoint.PATH,
{ ...GetSearchSuggestionsEndpoint.build({ input: query }), parse: true }
);
if (!response.contents_memo)
throw new InnertubeError('Unexpected response', response);
return [] as unknown as ObservedArray<SearchSuggestionsSection>;
const search_suggestions_section = response.contents_memo.getType(SearchSuggestionsSection).first();
const search_suggestions_sections = response.contents_memo.getType(SearchSuggestionsSection);
return search_suggestions_section.contents;
return search_suggestions_sections;
}
}

View File

@@ -15,7 +15,9 @@ export function build(opts: EditPlaylistEndpointOptions): IEditPlaylistRequest {
...{
addedVideoId: action.added_video_id,
setVideoId: action.set_video_id,
movedSetVideoIdPredecessor: action.moved_set_video_id_predecessor
movedSetVideoIdPredecessor: action.moved_set_video_id_predecessor,
playlistDescription: action.playlist_description,
playlistName: action.playlist_name
}
}))
};

View File

@@ -15,4 +15,6 @@ export * as Music from './music/index.js';
export * as Notification from './notification/index.js';
export * as Playlist from './playlist/index.js';
export * as Subscription from './subscription/index.js';
export * as Upload from './upload/index.js';
export * as Reel from './reel/index.js';
export * as Upload from './upload/index.js';
export * as Kids from './kids/index.js';

View File

@@ -0,0 +1,12 @@
import type { IBlocklistPickerRequest, BlocklistPickerRequestEndpointOptions } from '../../../types/index.js';
export const PATH = '/kids/get_kids_blocklist_picker';
/**
* Builds a `/kids/get_kids_blocklist_picker` request payload.
* @param options - The options to use.
* @returns The payload.
*/
export function build(options: BlocklistPickerRequestEndpointOptions): IBlocklistPickerRequest {
return { blockedForKidsContent: { external_channel_id: options.channel_id } };
}

View File

@@ -0,0 +1 @@
export * as BlocklistPickerEndpoint from './BlocklistPickerEndpoint.js';

View File

@@ -0,0 +1,18 @@
import type { IReelWatchRequest, ReelWatchEndpointOptions } from '../../../types/index.js';
export const PATH = '/reel/reel_item_watch';
/**
* Builds a `/reel/reel_watch_sequence` request payload.
* @param opts - The options to use.
* @returns The payload.
*/
export function build(opts: ReelWatchEndpointOptions): IReelWatchRequest {
return {
playerRequest: {
videoId: opts.short_id,
params: opts.params ?? 'CAUwAg%3D%3D'
},
params: opts.params ?? 'CAUwAg%3D%3D'
};
}

View File

@@ -0,0 +1,14 @@
import type { IReelSequenceRequest, ReelWatchSequenceEndpointOptions } from '../../../types/index.js';
export const PATH = '/reel/reel_watch_sequence';
/**
* Builds a `/reel/reel_watch_sequence` request payload.
* @param opts - The options to use.
* @returns The payload.
*/
export function build(opts: ReelWatchSequenceEndpointOptions): IReelSequenceRequest {
return {
sequenceParams: opts.sequenceParams
};
}

View File

@@ -0,0 +1,2 @@
export * as WatchEndpoint from './WatchEndpoint.js';
export * as WatchSequenceEndpoint from './WatchSequenceEndpoint.js';

View File

@@ -200,4 +200,60 @@ export default class PlaylistManager {
action_result: response.data.actions // TODO: implement actions in the parser
};
}
}
/**
* Sets the name (title) for the given playlist.
* @param playlist_id - The playlist ID.
* @param name - The name / title to use for the playlist.
*/
async setName(playlist_id: string, name: string): Promise<{ playlist_id: string; action_result: any; }> {
throwIfMissing({ playlist_id, name });
if (!this.#actions.session.logged_in)
throw new InnertubeError('You must be signed in to perform this operation.');
const payload: EditPlaylistEndpointOptions = { playlist_id, actions: [] };
payload.actions.push({
action: 'ACTION_SET_PLAYLIST_NAME',
playlist_name: name
});
const response = await this.#actions.execute(
EditPlaylistEndpoint.PATH, EditPlaylistEndpoint.build(payload)
);
return {
playlist_id,
action_result: response.data.actions
};
}
/**
* Sets the description for the given playlist.
* @param playlist_id - The playlist ID.
* @param description - The description to use for the playlist.
*/
async setDescription(playlist_id: string, description: string): Promise<{ playlist_id: string; action_result: any; }> {
throwIfMissing({ playlist_id, description });
if (!this.#actions.session.logged_in)
throw new InnertubeError('You must be signed in to perform this operation.');
const payload: EditPlaylistEndpointOptions = { playlist_id, actions: [] };
payload.actions.push({
action: 'ACTION_SET_PLAYLIST_DESCRIPTION',
playlist_description: description
});
const response = await this.#actions.execute(
EditPlaylistEndpoint.PATH, EditPlaylistEndpoint.build(payload)
);
return {
playlist_id,
action_result: response.data.actions
};
}
}

View File

@@ -1,5 +1,5 @@
import type { Memo, ObservedArray, SuperParsedResult, YTNode } from '../../parser/helpers.js';
import Parser, { ReloadContinuationItemsCommand } from '../../parser/index.js';
import { Parser, ReloadContinuationItemsCommand } from '../../parser/index.js';
import { concatMemos, InnertubeError } from '../../utils/Utils.js';
import type Actions from '../Actions.js';
@@ -177,7 +177,7 @@ export default class Feed<T extends IParsedResponse = IParsedResponse> {
* Checks if the feed has continuation.
*/
get has_continuation(): boolean {
return (this.#memo.get('ContinuationItem') || []).length > 0;
return this.#getBodyContinuations().length > 0;
}
/**
@@ -185,17 +185,15 @@ export default class Feed<T extends IParsedResponse = IParsedResponse> {
*/
async getContinuationData(): Promise<T | undefined> {
if (this.#continuation) {
if (this.#continuation.length > 1)
throw new InnertubeError('There are too many continuations, you\'ll need to find the correct one yourself in this.page');
if (this.#continuation.length === 0)
throw new InnertubeError('There are no continuations');
throw new InnertubeError('There are no continuations.');
const response = await this.#continuation[0].endpoint.call<T>(this.#actions, { parse: true });
return response;
}
this.#continuation = this.#memo.getType(ContinuationItem);
this.#continuation = this.#getBodyContinuations();
if (this.#continuation)
return this.getContinuationData();
@@ -210,4 +208,14 @@ export default class Feed<T extends IParsedResponse = IParsedResponse> {
throw new InnertubeError('Could not get continuation data');
return new Feed<T>(this.actions, continuation_data, true);
}
#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);
}
}

View File

@@ -5,11 +5,13 @@ import type { DownloadOptions, FormatFilter, FormatOptions, URLTransformer } fro
import * as FormatUtils from '../../utils/FormatUtils.js';
import { InnertubeError } from '../../utils/Utils.js';
import type Format from '../../parser/classes/misc/Format.js';
import type { INextResponse, IPlayerResponse } from '../../parser/index.js';
import Parser from '../../parser/index.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 ContinuationItem from '../../parser/classes/ContinuationItem.js';
import TranscriptInfo from '../../parser/youtube/TranscriptInfo.js';
export default class MediaInfo {
#page: [IPlayerResponse, INextResponse?];
@@ -18,6 +20,7 @@ export default class MediaInfo {
#playback_tracking;
streaming_data;
playability_status;
player_config: IPlayerConfig;
constructor(data: [ApiResponse, ApiResponse?], actions: Actions, cpn: string) {
this.#actions = actions;
@@ -33,6 +36,7 @@ export default class MediaInfo {
this.streaming_data = info.streaming_data;
this.playability_status = info.playability_status;
this.player_config = info.player_config;
this.#playback_tracking = info.playback_tracking;
}
@@ -44,10 +48,16 @@ export default class MediaInfo {
* @returns DASH manifest
*/
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.');
}
let storyboards;
if (options.include_thumbnails && this.#page[0].storyboards?.is(PlayerStoryboardSpec)) {
storyboards = this.#page[0].storyboards;
if (options.include_thumbnails && player_response.storyboards?.is(PlayerStoryboardSpec)) {
storyboards = player_response.storyboards;
}
return FormatUtils.toDash(this.streaming_data, url_transformer, format_filter, this.#cpn, this.#actions.session.player, this.#actions, storyboards);
@@ -81,9 +91,45 @@ export default class MediaInfo {
* @param options - Download options.
*/
async download(options: DownloadOptions = {}): Promise<ReadableStream<Uint8Array>> {
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('Downloading is not supported for live and Post-Live-DVR videos, as they are split up into 5 second segments that are individual files, which require using a tool such as ffmpeg to stitch them together, so they cannot be returned in a single stream.');
}
return FormatUtils.download(options, this.#actions, this.playability_status, this.streaming_data, this.#actions.session.player, this.cpn);
}
/**
* Retrieves the video's transcript.
* @param video_id - The video id.
*/
async getTranscript(): Promise<TranscriptInfo> {
const next_response = this.page[1];
if (!next_response)
throw new InnertubeError('Cannot get transcript from basic video info.');
if (!next_response.engagement_panels)
throw new InnertubeError('Engagement panels not found. Video likely has no transcript.');
const transcript_panel = next_response.engagement_panels.get({
panel_identifier: 'engagement-panel-searchable-transcript'
});
if (!transcript_panel)
throw new InnertubeError('Transcript panel not found. Video likely has no transcript.');
const transcript_continuation = transcript_panel.content?.as(ContinuationItem);
if (!transcript_continuation)
throw new InnertubeError('Transcript continuation not found.');
const response = await transcript_continuation.endpoint.call(this.actions);
return new TranscriptInfo(this.actions, response);
}
/**
* Adds video to the watch history.
*/

View File

@@ -0,0 +1,18 @@
import { YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import AboutChannelView from './AboutChannelView.js';
import Button from './Button.js';
export default class AboutChannel extends YTNode {
static type = 'AboutChannel';
metadata: AboutChannelView | null;
share_channel: Button | null;
constructor(data: RawNode) {
super();
this.metadata = Parser.parseItem(data.metadata, AboutChannelView);
this.share_channel = Parser.parseItem(data.shareChannel, Button);
}
}

View File

@@ -0,0 +1,87 @@
import type { ObservedArray } from '../helpers.js';
import { YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import ChannelExternalLinkView from './ChannelExternalLinkView.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';
export default class AboutChannelView extends YTNode {
static type = 'AboutChannelView';
description?: string;
description_label?: Text;
country?: string;
custom_links_label?: Text;
subscriber_count?: string;
view_count?: string;
joined_date?: Text;
canonical_channel_url?: string;
channel_id?: string;
additional_info_label?: Text;
custom_url_on_tap?: NavigationEndpoint;
video_count?: string;
sign_in_for_business_email?: Text;
links: ObservedArray<ChannelExternalLinkView>;
constructor(data: RawNode) {
super();
if (Reflect.has(data, 'description')) {
this.description = data.description;
}
if (Reflect.has(data, 'descriptionLabel')) {
this.description_label = Text.fromAttributed(data.descriptionLabel);
}
if (Reflect.has(data, 'country')) {
this.country = data.country;
}
if (Reflect.has(data, 'customLinksLabel')) {
this.custom_links_label = Text.fromAttributed(data.customLinksLabel);
}
if (Reflect.has(data, 'subscriberCountText')) {
this.subscriber_count = data.subscriberCountText;
}
if (Reflect.has(data, 'viewCountText')) {
this.view_count = data.viewCountText;
}
if (Reflect.has(data, 'joinedDateText')) {
this.joined_date = Text.fromAttributed(data.joinedDateText);
}
if (Reflect.has(data, 'canonicalChannelUrl')) {
this.canonical_channel_url = data.canonicalChannelUrl;
}
if (Reflect.has(data, 'channelId')) {
this.channel_id = data.channelId;
}
if (Reflect.has(data, 'additionalInfoLabel')) {
this.additional_info_label = Text.fromAttributed(data.additionalInfoLabel);
}
if (Reflect.has(data, 'customUrlOnTap')) {
this.custom_url_on_tap = new NavigationEndpoint(data.customUrlOnTap);
}
if (Reflect.has(data, 'videoCountText')) {
this.video_count = data.videoCountText;
}
if (Reflect.has(data, 'signInForBusinessEmail')) {
this.sign_in_for_business_email = Text.fromAttributed(data.signInForBusinessEmail);
}
if (Reflect.has(data, 'links')) {
this.links = Parser.parseArray(data.links, ChannelExternalLinkView);
} else {
this.links = [] as unknown as ObservedArray<ChannelExternalLinkView>;
}
}
}

View File

@@ -1,4 +1,4 @@
import Parser from '../index.js';
import { Parser } from '../index.js';
import AccountItemSectionHeader from './AccountItemSectionHeader.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';

View File

@@ -1,4 +1,4 @@
import Parser from '../index.js';
import { Parser } from '../index.js';
import AccountChannel from './AccountChannel.js';
import AccountItemSection from './AccountItemSection.js';

View File

@@ -0,0 +1,30 @@
import { YTNode } from '../helpers.js';
import { type RawNode } from '../index.js';
import { Thumbnail } from '../misc.js';
export default class AvatarView extends YTNode {
static type = 'AvatarView';
image: {
sources: Thumbnail[],
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.avatar_image_size = data.avatarImageSize;
}
}

View File

@@ -1,5 +1,6 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import CommentActionButtons from './comments/CommentActionButtons.js';
import Menu from './menus/Menu.js';
@@ -18,7 +19,7 @@ export default class BackstagePost extends YTNode {
vote_count?: Text;
menu?: Menu | null;
action_buttons?: CommentActionButtons | null;
vote_button?: CommentActionButtons | null;
vote_button?: Button | null;
surface: string;
endpoint?: NavigationEndpoint;
attachment;
@@ -56,7 +57,7 @@ export default class BackstagePost extends YTNode {
}
if (Reflect.has(data, 'voteButton')) {
this.vote_button = Parser.parseItem(data.voteButton, CommentActionButtons);
this.vote_button = Parser.parseItem(data.voteButton, Button);
}
if (Reflect.has(data, 'navigationEndpoint')) {

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import { YTNode } from '../helpers.js';
export default class BackstagePostThread extends YTNode {

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import { type ObservedArray, YTNode } from '../helpers.js';
export default class BrowseFeedActions extends YTNode {

View File

@@ -0,0 +1,28 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
export default class ButtonView extends YTNode {
static type = 'ButtonView';
icon_name: string;
title: string;
accessibility_text: string;
style: string;
is_full_width: boolean;
type: string;
button_size: string;
on_tap: NavigationEndpoint;
constructor(data: RawNode) {
super();
this.icon_name = data.iconName;
this.title = data.title;
this.accessibility_text = data.accessibilityText;
this.style = data.style;
this.is_full_width = data.isFullWidth;
this.type = data.type;
this.button_size = data.buttonSize;
this.on_tap = new NavigationEndpoint(data.onTap);
}
}

View File

@@ -1,8 +1,9 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
import ChannelHeaderLinks from './ChannelHeaderLinks.js';
import ChannelHeaderLinksView from './ChannelHeaderLinksView.js';
import ChannelTagline from './ChannelTagline.js';
import SubscribeButton from './SubscribeButton.js';
import Author from './misc/Author.js';
import Text from './misc/Text.js';
@@ -22,6 +23,7 @@ export default class C4TabbedHeader extends YTNode {
header_links?: ChannelHeaderLinks | ChannelHeaderLinksView | null;
channel_handle?: Text;
channel_id?: string;
tagline?: ChannelTagline | null;
constructor(data: RawNode) {
super();
@@ -69,5 +71,9 @@ export default class C4TabbedHeader extends YTNode {
if (Reflect.has(data, 'channelId')) {
this.channel_id = data.channelId;
}
if (Reflect.has(data, 'tagline')) {
this.tagline = Parser.parseItem(data.tagline, ChannelTagline);
}
}
}

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import { YTNode } from '../helpers.js';
export default class Card extends YTNode {

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Text from './misc/Text.js';
export default class CardCollection extends YTNode {

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import { type ObservedArray, YTNode } from '../helpers.js';
export default class CarouselHeader extends YTNode {

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import { type ObservedArray, YTNode } from '../helpers.js';
import Thumbnail from './misc/Thumbnail.js';

View File

@@ -1,6 +1,6 @@
import { type ObservedArray, YTNode } from '../helpers.js';
import InfoRow from './InfoRow.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import CompactVideo from './CompactVideo.js';
export default class CarouselLockup extends YTNode {

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import SubscribeButton from './SubscribeButton.js';

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';

View File

@@ -0,0 +1,20 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import Text from './misc/Text.js';
import Thumbnail from './misc/Thumbnail.js';
export default class ChannelExternalLinkView extends YTNode {
static type = 'ChannelExternalLinkView';
title: Text;
link: Text;
favicon: Thumbnail[];
constructor(data: RawNode) {
super();
this.title = Text.fromAttributed(data.title);
this.link = Text.fromAttributed(data.link);
this.favicon = Thumbnail.fromResponse(data.favicon);
}
}

View File

@@ -1,5 +1,5 @@
import { type ObservedArray, YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Text from './misc/Text.js';
export default class ChannelFeaturedContent extends YTNode {

View File

@@ -0,0 +1,17 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import Text from './misc/Text.js';
import Thumbnail from './misc/Thumbnail.js';
export default class ChannelOwnerEmptyState extends YTNode {
static type = 'ChannelOwnerEmptyState';
illustration: Thumbnail[];
description: Text;
constructor(data: RawNode) {
super();
this.illustration = Thumbnail.fromResponse(data.illustration);
this.description = new Text(data.description);
}
}

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
export default class ChannelSubMenu extends YTNode {

View File

@@ -0,0 +1,44 @@
import { YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import EngagementPanelSectionList from './EngagementPanelSectionList.js';
export default class ChannelTagline extends YTNode {
static type = 'ChannelTagline';
content: string;
max_lines: number;
more_endpoint: {
show_engagement_panel_endpoint: {
engagement_panel: EngagementPanelSectionList | null,
engagement_panel_popup_type: string;
identifier: {
surface: string,
tag: string
}
}
} | NavigationEndpoint;
more_icon_type: string;
more_label: string;
target_id: string;
constructor(data: RawNode) {
super();
this.content = data.content;
this.max_lines = data.maxLines;
this.more_endpoint = data.moreEndpoint.showEngagementPanelEndpoint ? {
show_engagement_panel_endpoint: {
engagement_panel: Parser.parseItem(data.moreEndpoint.showEngagementPanelEndpoint.engagementPanel, EngagementPanelSectionList),
engagement_panel_popup_type: data.moreEndpoint.showEngagementPanelEndpoint.engagementPanelPresentationConfigs.engagementPanelPopupPresentationConfig.popupType,
identifier: {
surface: data.moreEndpoint.showEngagementPanelEndpoint.identifier.surface,
tag: data.moreEndpoint.showEngagementPanelEndpoint.identifier.tag
}
}
} : new NavigationEndpoint(data.moreEndpoint);
this.more_icon_type = data.moreIcon.iconType;
this.more_label = data.moreLabel;
this.target_id = data.targetId;
}
}

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
import ChipCloudChip from './ChipCloudChip.js';

View File

@@ -0,0 +1,17 @@
import { YTNode } from '../helpers.js';
import Text from './misc/Text.js';
import type { RawNode } from '../types/index.js';
export default class ClipAdState extends YTNode {
static type = 'ClipAdState';
title: Text;
body: Text;
constructor(data: RawNode) {
super();
this.title = new Text(data.title);
this.body = new Text(data.body);
}
}

View File

@@ -0,0 +1,40 @@
import { YTNode } from '../helpers.js';
import Thumbnail from './misc/Thumbnail.js';
import Button from './Button.js';
import ClipCreationTextInput from './ClipCreationTextInput.js';
import ClipCreationScrubber from './ClipCreationScrubber.js';
import ClipAdState from './ClipAdState.js';
import Text from './misc/Text.js';
import { Parser } from '../index.js';
import type { RawNode } from '../types/index.js';
export default class ClipCreation extends YTNode {
static type = 'ClipCreation';
user_avatar: Thumbnail[];
title_input: ClipCreationTextInput | null;
scrubber: ClipCreationScrubber | null;
save_button: Button | null;
display_name: Text;
publicity_label: string;
cancel_button: Button | null;
ad_state_overlay: ClipAdState | null;
external_video_id: string;
publicity_label_icon: string;
constructor(data: RawNode) {
super();
this.user_avatar = Thumbnail.fromResponse(data.userAvatar);
this.title_input = Parser.parseItem(data.titleInput, [ ClipCreationTextInput ]);
this.scrubber = Parser.parseItem(data.scrubber, [ ClipCreationScrubber ]);
this.save_button = Parser.parseItem(data.saveButton, [ Button ]);
this.display_name = new Text(data.displayName);
this.publicity_label = data.publicityLabel;
this.cancel_button = Parser.parseItem(data.cancelButton, [ Button ]);
this.ad_state_overlay = Parser.parseItem(data.adStateOverlay, [ ClipAdState ]);
this.external_video_id = data.externalVideoId;
this.publicity_label_icon = data.publicityLabelIcon;
}
}

View File

@@ -0,0 +1,28 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../types/index.js';
export default class ClipCreationScrubber extends YTNode {
static type = 'ClipCreationScrubber';
length_template: string;
max_length_ms: number;
min_length_ms: number;
default_length_ms: number;
window_size_ms: number;
start_label?: string;
end_label?: string;
duration_label?: string;
constructor(data: RawNode) {
super();
this.length_template = data.lengthTemplate;
this.max_length_ms = data.maxLengthMs;
this.min_length_ms = data.minLengthMs;
this.default_length_ms = data.defaultLengthMs;
this.window_size_ms = data.windowSizeMs;
this.start_label = data.startAccessibility?.accessibilityData?.label;
this.end_label = data.endAccessibility?.accessibilityData?.label;
this.duration_label = data.durationAccessibility?.accessibilityData?.label;
}
}

View File

@@ -0,0 +1,17 @@
import { YTNode } from '../helpers.js';
import Text from './misc/Text.js';
import type { RawNode } from '../types/index.js';
export default class ClipCreationTextInput extends YTNode {
static type = 'ClipCreationTextInput';
placeholder_text: Text;
max_character_limit: number;
constructor(data: RawNode) {
super();
this.placeholder_text = new Text(data.placeholderText);
this.max_character_limit = data.maxCharacterLimit;
}
}

View File

@@ -0,0 +1,19 @@
import type { ObservedArray } from '../helpers.js';
import { YTNode } from '../helpers.js';
import ClipCreation from './ClipCreation.js';
import { Parser } from '../index.js';
import type { RawNode } from '../types/index.js';
export default class ClipSection extends YTNode {
static type = 'ClipSection';
contents: ObservedArray<ClipCreation> | null;
constructor(data: RawNode) {
super();
this.contents = Parser.parse(data.contents, true, [ ClipCreation ]);
}
}

View File

@@ -0,0 +1,14 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
export default class Command extends YTNode {
static type = 'Command';
endpoint: NavigationEndpoint;
constructor(data: RawNode) {
super();
this.endpoint = new NavigationEndpoint(data);
}
}

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Menu from './menus/Menu.js';
import Text from './misc/Text.js';

View File

@@ -1,6 +1,6 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import type { RawNode } from '../index.js';
import Parser from '../index.js';
import { Parser } from '../index.js';
import Author from './misc/Author.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';

View File

@@ -1,6 +1,6 @@
import { timeToSeconds } from '../../utils/Utils.js';
import { YTNode, type ObservedArray, type SuperParsedResult } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Menu from './menus/Menu.js';
import MetadataBadge from './MetadataBadge.js';
import Author from './misc/Author.js';

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Text from './misc/Text.js';
import Button from './Button.js';
import { YTNode } from '../helpers.js';

View File

@@ -0,0 +1,26 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import { Text } from '../misc.js';
export type MetadataRow = {
metadata_parts: {
text: Text;
}[];
};
export default class ContentMetadataView extends YTNode {
static type = 'ContentMetadataView';
metadata_rows: MetadataRow[];
delimiter: string;
constructor(data: RawNode) {
super();
this.metadata_rows = data.metadataRows.map((row: RawNode) => ({
metadata_parts: row.metadataParts.map((part: RawNode) => ({
text: Text.fromAttributed(part.text)
}))
}));
this.delimiter = data.delimiter;
}
}

View File

@@ -10,7 +10,7 @@ export default class ContentPreviewImageView extends YTNode {
constructor(data: RawNode) {
super();
this.image = data.image.sources.map((x: any) => new Thumbnail(x)).sort((a: Thumbnail, b: Thumbnail) => b.width - a.width);
this.image = Thumbnail.fromResponse(data.image);
this.style = data.style;
}
}

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
import NavigationEndpoint from './NavigationEndpoint.js';

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Message from './Message.js';
export default class ConversationBar extends YTNode {

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
export default class CopyLink extends YTNode {

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
import Dropdown from './Dropdown.js';
import Text from './misc/Text.js';

View File

@@ -0,0 +1,19 @@
import { YTNode } from '../helpers.js';
import 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;
a11y_label: string;
on_tap_endpoint: NavigationEndpoint;
constructor(data: RawNode) {
super();
this.avatar = new AvatarView(data.avatar.avatarViewModel);
this.a11y_label = data.a11yLabel;
this.on_tap_endpoint = new NavigationEndpoint(data.rendererContext.commandContext.onTap.innertubeCommand);
}
}

View File

@@ -1,6 +1,6 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import Parser from '../index.js';
import { Parser } from '../index.js';
import Button from './Button.js';
import MultiMarkersPlayerBar from './MultiMarkersPlayerBar.js';

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';

View File

@@ -0,0 +1,16 @@
import { YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import ToggleButtonView from './ToggleButtonView.js';
export default class DislikeButtonView extends YTNode {
static type = 'DislikeButtonView';
toggle_button: ToggleButtonView | null;
dislike_entity_key: string;
constructor(data: RawNode) {
super();
this.toggle_button = Parser.parseItem(data.toggleButtonViewModel, ToggleButtonView);
this.dislike_entity_key = data.dislikeEntityKey;
}
}

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import DropdownItem from './DropdownItem.js';
export default class Dropdown extends YTNode {

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import ChildElement from './misc/ChildElement.js';
import { type ObservedArray, YTNode, observe } from '../helpers.js';

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Menu from './menus/Menu.js';
import Text from './misc/Text.js';

View File

@@ -1,5 +1,5 @@
import { type ObservedArray, YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Author from './misc/Author.js';
import Text from './misc/Text.js';
import Thumbnail from './misc/Thumbnail.js';

View File

@@ -1,4 +1,4 @@
import Parser from '../index.js';
import { Parser } from '../index.js';
import { type ObservedArray, YTNode } from '../helpers.js';
export default class Endscreen extends YTNode {

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Thumbnail from './misc/Thumbnail.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';

View File

@@ -1,26 +1,37 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import ClipSection from './ClipSection.js';
import ContinuationItem from './ContinuationItem.js';
import EngagementPanelTitleHeader from './EngagementPanelTitleHeader.js';
import MacroMarkersList from './MacroMarkersList.js';
import ProductList from './ProductList.js';
import SectionList from './SectionList.js';
import StructuredDescriptionContent from './StructuredDescriptionContent.js';
import VideoAttributeView from './VideoAttributeView.js';
export default class EngagementPanelSectionList extends YTNode {
static type = 'EngagementPanelSectionList';
header: EngagementPanelTitleHeader | null;
content: SectionList | ContinuationItem | StructuredDescriptionContent | MacroMarkersList | null;
content: VideoAttributeView | SectionList | ContinuationItem | ClipSection | StructuredDescriptionContent | MacroMarkersList | ProductList | null;
target_id?: string;
panel_identifier?: string;
identifier?: {
surface: string,
tag: string
};
visibility?: string;
constructor(data: RawNode) {
super();
this.header = Parser.parseItem(data.header, EngagementPanelTitleHeader);
this.content = Parser.parseItem(data.content, [ SectionList, ContinuationItem, StructuredDescriptionContent, MacroMarkersList ]);
this.content = Parser.parseItem(data.content, [ VideoAttributeView, SectionList, ContinuationItem, ClipSection, StructuredDescriptionContent, MacroMarkersList, ProductList ]);
this.panel_identifier = data.panelIdentifier;
this.identifier = data.identifier ? {
surface: data.identifier.surface,
tag: data.identifier.tag
} : undefined;
this.target_id = data.targetId;
this.visibility = data.visibility;
}
}
}

View File

@@ -1,7 +1,8 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Button from './Button.js';
import HorizontalCardList from './HorizontalCardList.js';
import HorizontalList from './HorizontalList.js';
import Text from './misc/Text.js';
import Thumbnail from './misc/Thumbnail.js';
@@ -15,7 +16,7 @@ export default class ExpandableMetadata extends YTNode {
expanded_title: Text;
};
expanded_content: HorizontalCardList | null;
expanded_content: HorizontalCardList | HorizontalList | null;
expand_button: Button | null;
collapse_button: Button | null;
@@ -31,7 +32,7 @@ export default class ExpandableMetadata extends YTNode {
};
}
this.expanded_content = Parser.parseItem(data.expandedContent, HorizontalCardList);
this.expanded_content = Parser.parseItem(data.expandedContent, [ HorizontalCardList, HorizontalList ]);
this.expand_button = Parser.parseItem(data.expandButton, Button);
this.collapse_button = Parser.parseItem(data.collapseButton, Button);
}

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
export default class ExpandableTab extends YTNode {

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import { type ObservedArray, YTNode } from '../helpers.js';
export default class ExpandedShelfContents extends YTNode {

View File

@@ -0,0 +1,16 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import { Text } from '../misc.js';
export default class FancyDismissibleDialog extends YTNode {
static type = 'FancyDismissibleDialog';
dialog_message: Text;
confirm_label: Text;
constructor(data: RawNode) {
super();
this.dialog_message = new Text(data.dialogMessage);
this.confirm_label = new Text(data.confirmLabel);
}
}

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import ChipCloudChip from './ChipCloudChip.js';
export default class FeedFilterChipBar extends YTNode {

View File

@@ -0,0 +1,26 @@
import { YTNode } from '../helpers.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';
import type { RawNode } from '../types/index.js';
export default class FeedNudge extends YTNode {
static type = 'FeedNudge';
title: Text;
subtitle: Text;
endpoint: NavigationEndpoint;
apply_modernized_style: boolean;
trim_style: string;
background_style: string;
constructor(data: RawNode) {
super();
this.title = new Text(data.title);
this.subtitle = new Text(data.subtitle);
this.endpoint = new NavigationEndpoint(data.impressionEndpoint);
this.apply_modernized_style = data.applyModernizedStyle;
this.trim_style = data.trimStyle;
this.background_style = data.backgroundStyle;
}
}

View File

@@ -0,0 +1,22 @@
import { type ObservedArray, YTNode } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import ButtonView from './ButtonView.js';
export type ActionRow = {
actions: ObservedArray<ButtonView>;
};
export default class FlexibleActionsView extends YTNode {
static type = 'FlexibleActionsView';
actions_rows: ActionRow[];
style: string;
constructor(data: RawNode) {
super();
this.actions_rows = data.actionsRows.map((row: RawNode) => ({
actions: Parser.parseArray(row.actions, ButtonView)
}));
this.style = data.style;
}
}

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
export default class GameCard extends YTNode {
static type = 'GameCard';

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
export default class Grid extends YTNode {
static type = 'Grid';

View File

@@ -1,5 +1,5 @@
import { YTNode } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Author from './misc/Author.js';
import Text from './misc/Text.js';
import NavigationEndpoint from './NavigationEndpoint.js';

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';
import Thumbnail from './misc/Thumbnail.js';

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import MetadataBadge from './MetadataBadge.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import Author from './misc/Author.js';
import Text from './misc/Text.js';
import Thumbnail from './misc/Thumbnail.js';

View File

@@ -1,5 +1,5 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Menu from './menus/Menu.js';
import Author from './misc/Author.js';

View File

@@ -1,4 +1,4 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import HeatMarker from './HeatMarker.js';
import { type ObservedArray, YTNode } from '../helpers.js';

View File

@@ -1,4 +1,5 @@
import NavigationEndpoint from './NavigationEndpoint.js';
import Thumbnail from './misc/Thumbnail.js';
import { YTNode, observe } from '../helpers.js';
import { type RawNode } from '../index.js';
@@ -6,11 +7,7 @@ export class Panel extends YTNode {
static type = 'Panel';
thumbnail?: {
image: {
url: string;
width: number;
height: number;
}[];
image: Thumbnail[];
endpoint: NavigationEndpoint;
on_long_press_endpoint: NavigationEndpoint;
content_mode: string;
@@ -18,16 +15,8 @@ export class Panel extends YTNode {
};
background_image: {
image: {
url: string;
width: number;
height: number;
}[];
gradient_image: {
url: string;
width: number;
height: number;
}[];
image: Thumbnail[];
gradient_image: Thumbnail[];
};
strapline: string;
@@ -48,7 +37,7 @@ export class Panel extends YTNode {
if (data.thumbnail) {
this.thumbnail = {
image: data.thumbnail.image.sources,
image: Thumbnail.fromResponse(data.thumbnail.image),
endpoint: new NavigationEndpoint(data.thumbnail.onTap),
on_long_press_endpoint: new NavigationEndpoint(data.thumbnail.onLongPress),
content_mode: data.thumbnail.contentMode,
@@ -57,8 +46,8 @@ export class Panel extends YTNode {
}
this.background_image = {
image: data.backgroundImage.image.sources,
gradient_image: data.backgroundImage.gradientImage.sources
image: Thumbnail.fromResponse(data.backgroundImage.image),
gradient_image: Thumbnail.fromResponse(data.backgroundImage.gradientImage)
};
this.strapline = data.strapline;

View File

@@ -1,22 +1,23 @@
import Parser, { type RawNode } from '../index.js';
import { Parser, type RawNode } from '../index.js';
import { type ObservedArray, YTNode } from '../helpers.js';
import SearchRefinementCard from './SearchRefinementCard.js';
import Button from './Button.js';
import MacroMarkersListItem from './MacroMarkersListItem.js';
import GameCard from './GameCard.js';
import VideoCard from './VideoCard.js';
import VideoAttributeView from './VideoAttributeView.js';
export default class HorizontalCardList extends YTNode {
static type = 'HorizontalCardList';
cards: ObservedArray<SearchRefinementCard | MacroMarkersListItem | GameCard | VideoCard>;
cards: ObservedArray<VideoAttributeView | SearchRefinementCard | MacroMarkersListItem | GameCard | VideoCard>;
header: YTNode;
previous_button: Button | null;
next_button: Button | null;
constructor(data: RawNode) {
super();
this.cards = Parser.parseArray(data.cards, [ SearchRefinementCard, MacroMarkersListItem, GameCard, VideoCard ]);
this.cards = Parser.parseArray(data.cards, [ VideoAttributeView, SearchRefinementCard, MacroMarkersListItem, GameCard, VideoCard ]);
this.header = Parser.parseItem(data.header);
this.previous_button = Parser.parseItem(data.previousButton, Button);
this.next_button = Parser.parseItem(data.nextButton, Button);

Some files were not shown because too many files have changed in this diff Show More