diff --git a/README_v2.0.0WIP.md b/README_v2.0.0WIP.md new file mode 100644 index 00000000..42583400 --- /dev/null +++ b/README_v2.0.0WIP.md @@ -0,0 +1,255 @@ + + + +[npm]: https://www.npmjs.com/package/youtubei.js +[versions]: https://www.npmjs.com/package/youtubei.js?activeTab=versions +[codefactor]: https://www.codefactor.io/repository/github/luanrt/youtube.js +[actions]: https://github.com/LuanRT/YouTube.js/actions +[say-thanks]: https://saythanks.io/to/LuanRT +[ko-fi]:https://ko-fi.com/luanrt +[github-sponsors]:https://github.com/sponsors/LuanRT + + +[project]: https://github.com/LuanRT/YouTube.js +[twitter]: https://twitter.com/lrt_nooneknows +[nodejs]: https://nodejs.org +[gatecrasher]: https://github.com/gatecrasher777/ytcog +[gizmodo]: https://gizmodo.com/how-project-innertube-helped-pull-youtube-out-of-the-gu-1704946491 + + +

+ YouTube.js +

+ +

+ + A full-featured wrapper around the Innertube API, which is what YouTube itself uses. + +

+ +

+ + Report Bug + + · + + Request Feature + +

+ + +
+ + [![Tests](https://github.com/LuanRT/YouTube.js/actions/workflows/node.js.yml/badge.svg)][actions] + [![Latest version](https://img.shields.io/npm/v/youtubei.js?color=%2335C757)][versions] + [![Codefactor](https://www.codefactor.io/repository/github/luanrt/youtube.js/badge)][codefactor] + [![Monthly downloads](https://img.shields.io/npm/dm/youtubei.js)][npm] + [![Say thanks](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)][say-thanks] +
+ [![Donate](https://img.shields.io/badge/donate-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#white)][github-sponsors] + +
+ +___ + +> WIP- Documentation for YouTube.js 2.0.0 + + +
+ Table of Contents +
    +
  1. + About The Project + +
  2. +
  3. + Getting Started + +
  4. +
  5. + Usage +
      +
    +
  6. +
  7. Contributing
  8. +
  9. License
  10. +
  11. Contact
  12. +
  13. Disclaimer
  14. +
+
+ + +## About + +Innertube is an API used across all YouTube clients, it was created to simplify[^1] the internal structure of the platform in a way that updates, tweaks, and experiments can be easily made. This library handles all the low-level communication with Innertube, providing a simple, fast, and efficient way to interact with YouTube programmatically. + +And huge thanks to [@gatecrasher777][gatecrasher] for his research on the workings of the Innertube API! + + +## Getting Started + +### Prerequisites +- [NodeJS][nodejs] v14 or greater + + To verify things are set up +properly, run this: + ```bash + node --version + ``` + +### Installation +- NPM: + ```bash + npm install youtubei.js@latest + ``` +- Yarn: + ```bash + yarn add youtubei.js@latest + ``` +- Git (bleeding-edge version): + ```bash + npm install git+https://github.com/LuanRT/YouTube.js.git + ``` + + +## Usage + +Create an Innertube instance (or session): +```js +// const Innertube = require('youtubei.js'); +import Innertube from 'youtubei.js'; +const youtube = await new Innertube({ gl: 'US' }); +``` +## API + +## Innertube : `object` + +* Innertube : `object` + * [.getInfo(video_id)](#getinfo) ⇒ `function` + * [.getBasicInfo(video_id)](#getbasicinfo) ⇒ `function` + * [.search(query, filters?)](#ytsearch) ⇒ `function` + +### getInfo(video_id) + +Retrieves video info, including playback data and even layout elements such as menus, buttons etc — all nicely parsed. + +**Returns**: [`Promise.`](https://github.com/LuanRT/YouTube.js/blob/main/typings/lib/parser/youtube/VideoInfo.d.ts) + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | The id of the video | + +**Methods & Getters**: + +- [`#like()`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/VideoInfo.d.ts#L91) + - Likes the video. + +- [`#dislike()`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/VideoInfo.d.ts#L100) + - Dislikes the video. + +- [`#removeLike()`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/VideoInfo.d.ts#L100) + - Removes like/dislike. + +- [`#filters`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/VideoInfo.d.ts#L115) + - Returns filters that can be applied to the watch next feed. + +- [`#selectFilter(name)`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/VideoInfo.d.ts#L77) + - Applies given filter to the watch next feed and returns a new instance of [`VideoInfo`](https://github.com/LuanRT/YouTube.js/blob/main/typings/lib/parser/youtube/VideoInfo.d.ts). + +- [`#getWatchNextContinuation()`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/lib/parser/youtube/VideoInfo.js#L144#L152) + - Retrieves next batch of items for the [watch next feed](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/VideoInfo.d.ts#L30). + +- [`#page`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/lib/parser/youtube/VideoInfo.js#L203) + - Returns original InnerTube response (sanitized). + + +### getBasicInfo(video_id) + +Suitable for cases where you only need basic video metadata, much faster than `getInfo()`. + +**Returns**: [`Promise.`](https://github.com/LuanRT/YouTube.js/blob/main/typings/lib/parser/youtube/VideoInfo.d.ts) + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | The id of the video | + + +### search(query, filters?) + +Searches the given query on YouTube. + +**Returns**: [`Promise.`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts) + +| Param | Type | Description | +| --- | --- | --- | +| query | `string` | The search query | +| filters | `object` | Search filters | + +**Supported search filters**: +* type: `all` | `video` | `channel` | `playlist` | `movie` +* upload_date: `all` | `hour` | `today` | `week` | `month` | `year` +* duration: `all` | `short` | `medium` | `long` +* sort_by: `relevance` | `rating` | `upload_date` | `view_count` + +**Methods & Getters**: + +- [`#videos`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L47) + - Shortcut to get all videos from the [results object](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L15) + +- [`#playlists`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L49) + - Shortcut to get all playlists from the [results object](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L15) + +- [`#selectRefinementCard(SearchRefinementCard | string)`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L41) + - Applies given refinement card and returns a new [Search](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts) instance. + +- [`#refinement_card_queries`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L45) + - Returns available refinement cards, this is a simplified version of the [refinement cards](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L25#L30) object. + +- [`#has_continuation`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L43) + - Returns `true` if search continuation is available. + +- [`#getContinuation()`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L35) + - Retrieves next batch of results. + +- [`#page`](https://github.com/LuanRT/YouTube.js/blob/3f22a44ba9dd96575f609b0349bab5f50490c9fe/typings/lib/parser/youtube/Search.d.ts#L50) + - Returns original InnerTube response (sanitized). + + +## Contributing +Contributions, issues and feature requests are welcome. +Feel free to check [issues page](https://github.com/LuanRT/YouTube.js/issues) if you want to contribute. + + +## Contributors + + + + + +## Contact + +LuanRT - [@lrt_nooneknows][twitter] - luan.lrt4@gmail.com + +Project Link: [https://github.com/LuanRT/YouTube.js][project] + +## Disclaimer +This project is not affiliated with, endorsed, or sponsored by YouTube or any of their affiliates or subsidiaries. +All trademarks, logos and brand names are the property of their respective owners, and are used only to directly describe the services being provided, as such, any usage of trademarks to refer to such services is considered nominative use. + +Should you have any questions or concerns please contact me directly via email. + + +[^1]: https://gizmodo.com/how-project-innertube-helped-pull-youtube-out-of-the-gu-1704946491 + + +## License +Distributed under the [MIT](https://choosealicense.com/licenses/mit/) License. + +

+ (back to top) +

\ No newline at end of file