From 898cb56c71105f4ec255a8d108f4316376cbd831 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Thu, 1 Sep 2022 05:10:16 -0300 Subject: [PATCH] chore(docs): finish most of v2's documentation --- README_v2.md | 263 ++++++++++++++++++++++++++------ docs/API/account.md | 112 ++++++++++++++ docs/API/interaction-manager.md | 108 +++++++++++++ docs/API/music.md | 250 ++++++++++++++++++++++++++++++ docs/API/playlist.md | 72 +++++++++ docs/API/session.md | 83 ++++++++++ docs/API/studio.md | 33 ++++ 7 files changed, 874 insertions(+), 47 deletions(-) create mode 100644 docs/API/account.md create mode 100644 docs/API/interaction-manager.md create mode 100644 docs/API/music.md create mode 100644 docs/API/playlist.md create mode 100644 docs/API/session.md create mode 100644 docs/API/studio.md diff --git a/README_v2.md b/README_v2.md index e3744b4a..488ada84 100644 --- a/README_v2.md +++ b/README_v2.md @@ -13,8 +13,6 @@ [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

@@ -48,6 +46,30 @@ + + +

+ Special thanks to: +

+ + + + + + + +
+ + SerpApi +
+ + + Scrape Google and other search engines from a fast, easy and complete API. + + +
+
+ ___ > WIP- Documentation for YouTube.js 2.0.0 @@ -57,10 +79,7 @@ ___ Table of Contents
  1. - About The Project - + About
  2. Getting Started @@ -72,19 +91,24 @@ ___
  3. Usage
  4. +
  5. Implementing custom functionality
  6. Contributing
  7. -
  8. License
  9. +
  10. Contributors
  11. Contact
  12. Disclaimer
  13. +
  14. License
## 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. +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. If you have any questions or need help, feel free to contact us on our chat server [here](https://discord.gg/syDu7Yks54). @@ -92,13 +116,13 @@ If you have any questions or need help, feel free to contact us on our chat serv ## Getting Started ### Prerequisites -YouTube.js runs on Node.js, Deno and in modern browsers. +YouTube.js runs on Node.js, Deno, and modern browsers. It requires a runtime with the following features: - [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) - - On Node we use [undici]()'s fetch implementation which requires Node.js 16.8+. You may provide your own fetch implementation if you need to use an older version. See [providing your own fetch implementation](#custom-fetch) for more information. + - On Node we use [undici]()'s fetch implementation which requires Node.js 16.8+. You may provide your fetch implementation if you need to use an older version. See [providing your own fetch implementation](#custom-fetch) for more information. - The `Response` object returned by fetch must thus be spec compliant and return a `ReadableStream` object if you want to use the `VideoInfo#download` method. (Implementations like `node-fetch` returns a non-standard `Readable` object.) -- [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) and [`CustomEvent`](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) required. +- [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) and [`CustomEvent`](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) are required. ### Installation @@ -127,7 +151,7 @@ const youtube = await Innertube.create(); ## Browser Usage To use YouTube.js in the browser you must proxy requests through your own server. You can see our simple reference implementation in Deno in [`examples/browser/proxy/deno.ts`](https://github.com/LuanRT/YouTube.js/tree/main/examples/browser/proxy/deno.ts). -You may provide your own fetch implementation to be used by YouTube.js. Which we will use here to modify and send the requests to through our proxy. See [`examples/browser/web`](https://github.com/LuanRT/YouTube.js/tree/main/examples/browser/web) for an simple example using [Vite](https://vitejs.dev/). +You may provide your own fetch implementation to be used by YouTube.js. Which we will use here to modify and send the requests through our proxy. See [`examples/browser/web`](https://github.com/LuanRT/YouTube.js/tree/main/examples/browser/web) for a simple example using [Vite](https://vitejs.dev/). ```ts // Pre-bundled version for the web @@ -137,14 +161,14 @@ await Innertube.create({ // Modify the request // and send it to the proxy - // fetch the url + // fetch the URL return fetch(request, init); } }); ``` ### Streaming -YouTube.js supports streaming of videos in the browser by converting YouTube's streaming data into a MPEG-DASH manifest. +YouTube.js supports streaming of videos in the browser by converting YouTube's streaming data into an MPEG-DASH manifest. The example below uses [`dash.js`](https://github.com/Dash-Industry-Forum/dash.js) to play the video. @@ -159,7 +183,7 @@ const videoInfo = await youtube.getInfo('videoId'); // now convert to a dash manifest // again - to be able to stream the video in the browser - we must proxy the requests through our own server -// to do this, we provide a method to transform the urls before writing them to the manifest +// to do this, we provide a method to transform the URLs before writing them to the manifest const manifest = videoInfo.toDash(url => { // modify the url // and return it @@ -174,13 +198,11 @@ const player = dashjs.MediaPlayer().create(); player.initialize(videoElement, uri, true); ``` -Our browser example in [`examples/browser/web`]() provides a full working example. - +Our browser example in [`examples/browser/web`]() provides a fully working example. ## Providing your own fetch implementation -You may provide your own fetch implementation to be used by YouTube.js. This may be useful in some cases to modify the requests before they are sent and transform the responses before they are returned (eg. for proxies). - +You may provide your own fetch implementation to be used by YouTube.js. This can be useful in some cases to modify the requests before they are sent and transform the responses before they are returned (eg. for proxies). ```ts // provide a fetch implementation const yt = await Innertube.create({ @@ -199,7 +221,7 @@ const yt = await Innertube.create({ ## Caching To improve performance, you may wish to cache the transformed player instance which we use to decode the streaming urls. -Our cache uses the `node:fs` module in Node-like environments, `Deno.writeFile` in Deno and `indexedDB` in browsers. +Our cache uses the `node:fs` module in Node-like environments, `Deno.writeFile` in Deno, and `indexedDB` in browsers. ```ts import { Innertube, UniversalCache } from 'youtubei.js'; @@ -213,7 +235,7 @@ const yt = await Innertube.create({ cache: new UniversalCache( // Enables persistent caching true, - // Path to the cache directory, will create the directory if it doesn't exist + // Path to the cache directory will create the directory if it doesn't exist './.cache' ) }); @@ -223,16 +245,27 @@ const yt = await Innertube.create({ * Innertube - - * [.session](#session) - * [.account](#account) - * [.interact](#interact) - * [.playlist](#playlist) - * [.music](#music) - * [.studio](#studio) - ___ - * [.getInfo(video_id)](#getinfo) - * [.getBasicInfo(video_id)](#getbasicinfo) +
+ objects +

+ + * [.session](./docs/API/session.md) + * [.account](./docs/API/account.md) + * [.interact](./docs/API/interaction-manager.md) + * [.playlist](./docs/API/playlist.md) + * [.music](./docs/API/music.md) + * [.studio](./docs/API/studio.md) + +

+
+ + +
+ methods +

+ + * [.getInfo(video_id, client?)](#getinfo) + * [.getBasicInfo(video_id, client?)](#getbasicinfo) * [.search(query, filters?)](#search) * [.getSearchSuggestions(query)](#getsearchsuggestions) * [.getComments(video_id, sort_by?)](#getcomments) @@ -247,19 +280,26 @@ const yt = await Innertube.create({ * [.getPlaylist(id)](#getplaylist) * [.getStreamingData(video_id, options)](#getstreamingdata) * [.download(video_id, options?)](#download) + * [.call(endpoint, args?)](#call) - -### getInfo(video_id) +

+
-Retrieves video info, including playback data and even layout elements such as menus, buttons etc — all nicely parsed. + +### getInfo(video_id, client?) + +Retrieves video info, including playback data and even layout elements such as menus, buttons, etc — all nicely parsed. **Returns**: `Promise.` | Param | Type | Description | | --- | --- | --- | | video_id | `string` | The id of the video | +| client? | `InnerTubeClient` | `WEB`, `ANDROID` or `YTMUSIC` | -**Methods & Getters**: +
+Methods & Getters +

- `#like()` - Likes the video. @@ -270,28 +310,44 @@ Retrieves video info, including playback data and even layout elements such as m - `#removeLike()` - Removes like/dislike. +- `#getLiveChat()` + - Returns a LiveChat instance. + +- `#chooseFormat(options)` + - Used to choose streaming data formats. + +- `#toDash(url_transformer)` + - Converts streaming data to a MPEG-DASH manifest. + +- `#download(options)` + - Downloads the video. See [download](#download). + - `#filters` - Returns filters that can be applied to the watch next feed. - `#selectFilter(name)` - - 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). + - Applies the given filter to the watch next feed and returns a new instance of [`VideoInfo`](https://github.com/LuanRT/YouTube.js/blob/main/src/parser/youtube/VideoInfo.ts). - `#getWatchNextContinuation()` - - Retrieves next batch of items for the [watch next feed](https://github.com/LuanRT/YouTube.js/blob/main/typings/lib/parser/youtube/VideoInfo.d.ts). + - Retrieves the next batch of items for the watch next feed. - `#page` - Returns original InnerTube response (sanitized). +

+
+ ### getBasicInfo(video_id) -Suitable for cases where you only need basic video metadata, much faster than `getInfo()`. +Suitable for cases where you only need basic video metadata. Also, it is faster than [`getInfo()`](#getinfo). **Returns**: `Promise.` | Param | Type | Description | | --- | --- | --- | | video_id | `string` | The id of the video | +| client? | `InnerTubeClient` | `WEB`, `ANDROID` or `YTMUSIC` | ### search(query, filters?) @@ -303,9 +359,11 @@ Searches the given query on YouTube. | Param | Type | Description | | --- | --- | --- | | query | `string` | The search query | -| filters | `SearchFilters` | Search filters | +| filters? | `SearchFilters` | Search filters | -**Methods & Getters**: +
+Methods & Getters +

- `#selectRefinementCard(SearchRefinementCard | string)` - Applies given refinement card and returns a new Search instance. @@ -316,6 +374,9 @@ Searches the given query on YouTube. - `#getContinuation()` - Retrieves next batch of results. +

+
+ ### getSearchSuggestions(query) Retrieves search suggestions for given query. @@ -326,7 +387,6 @@ Retrieves search suggestions for given query. | --- | --- | --- | | query | `string` | The search query | - ### getComments(video_id, sort_by?) Retrieves comments for given video. @@ -338,6 +398,7 @@ Retrieves comments for given video. | video_id | `string` | The video id | | sort_by | `string` | Can be: `TOP_COMMENTS` or `NEWEST_FIRST` | +Examples & docs can be found [here](./examples/comments). ### getHomeFeed() @@ -351,12 +412,37 @@ Retrieves the account's library. **Returns**: `Promise.` +
+Methods & Getters +

+ +- `#history` +- `#watch_later` +- `#liked_videos` +- `#playlists` +- `#clips` +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ ### getHistory() Retrieves watch history. **Returns**: `Promise.` +
+Methods & Getters +

+ +- `#getContinuation()` + - Retrieves next batch of contents. + +

+
+ ### getTrending() Retrieves trending content. @@ -379,6 +465,22 @@ Retrieves contents for a given channel. | --- | --- | --- | | id | `string` | Channel id | +
+Methods & Getters +

+ +- `#getVideos()` +- `#getPlaylists()` +- `#getHome()` +- `#getCommunity()` +- `#getChannels()` +- `#getAbout()` + +

+
+ +**Info:** +Examples can be found [here](./examples/channel). ### getNotifications() @@ -386,6 +488,16 @@ Retrieves notifications. **Returns**: `Promise.` +
+Methods & Getter +

+ +- `#getContinuation()` + - Retrieves next batch of notifications. + +

+
+ ### getUnseenNotificationsCount() Retrieves unseen notifications count. @@ -402,6 +514,15 @@ Retrieves playlist contents. | --- | --- | --- | | id | `string` | Playlist id | +
+Methods & Getter +

+ +- `#items` + - Returns the items of the playlist. + +

+
### getStreamingData(video_id, options) @@ -414,7 +535,6 @@ Returns deciphered streaming data. | video_id | `string` | Video id | | options | `FormatOptions` | Format options | - ### download(video_id, options?) Downloads a given video. @@ -426,11 +546,60 @@ Downloads a given video. | video_id | `string` | Video id | | options | `DownloadOptions` | Download options | + +### call(endpoint, args?) +Utility to call navigation endpoints. + +**Returns**: `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| endpoint | `NavigationEndpoint` | The target endpoint | +| args? | `object` | Additional payload arguments | + +## Implementing custom functionality + +Something cool about YouTube.js is that it is completely modular and easy to tinker with. Almost all methods, classes, and utilities used internally are exposed and can be used to implement your own extensions without having to modify the library's source code. + +For example, you may want to call an endpoint directly, that can be achieved by using the `Actions` class, which the library uses internally to make API calls. + +Example: + +```ts +// ... + +const payload = { + videoId: 'jLTOuvBTLxA', + client: 'YTMUSIC', // InnerTube client, can be ANDROID, YTMUSIC, WEB + parse: true // tells YouTube.js to parse the response, this is not sent to InnerTube. +}; + +const response = await yt.actions.execute('/player', payload); + +console.info(response); +``` + +Or maybe there's an interesting `NavigationEndpoint` in a parsed response and we want to call it to see what happens: + +```ts +// ... +const artist = await yt.music.getArtist('UC52ZqHVQz5OoGhvbWiRal6g'); +const albums = artist.sections[1].as(MusicCarouselShelf); + +// Say we have a button and want to “click” it +const button = albums.as(MusicCarouselShelf).header?.more_content; + +if (button) { + // To do that, we can call its navigation endpoint: + const page = await button.endpoint.call(yt.actions, 'YTMUSIC', true); + console.info(page); +} +``` ## 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. +Contributions, issues, and feature requests are welcome. +Feel free to check [issues page](https://github.com/LuanRT/YouTube.js/issues) and our [guidelines](./CONTRIBUTING.md) if you want to contribute. ## Contributors @@ -446,8 +615,8 @@ 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. +This project is not affiliated with, endorsed, or sponsored by YouTube or any of its 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. @@ -458,6 +627,6 @@ Should you have any questions or concerns please contact me directly via email. ## License Distributed under the [MIT](https://choosealicense.com/licenses/mit/) License. -

+

(back to top)

\ No newline at end of file diff --git a/docs/API/account.md b/docs/API/account.md new file mode 100644 index 00000000..dbb94986 --- /dev/null +++ b/docs/API/account.md @@ -0,0 +1,112 @@ +# Account + +YouTube account manager. + +## API + +* Account + * [.channel](#channel) + * [.getInfo()](#getinfo) + * [.getTimeWatched()](#gettimewatched) + * [.getSettings()](#getsettings) + * [.getAnalytics](#getanalytics) + + +### channel + +Channel settings. + +**Returns:** `object` + +
+Methods & Getters +

+ +- `#editName(new_name)` + - Edits the name of the channel. + +- `#editDescription(new_description)` + - Edits channel description. + +- `#getBasicAnalytics()` + - Alias for [`Account#getAnalytics()`](#getanalytics) — returns basic channel analytics. + +

+
+ + +### getInfo() + +Retrieves account information. + +**Returns:** `Promise.` + +
+Methods & Getters +

+ +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ + +### getTimeWatched() + +Retrieves time watched statistics. + +**Returns:** `Promise.` + +
+Methods & Getters +

+ +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ + +### getSettings() + +Retrieves YouTube settings. + +**Returns:** `Promise.` + +
+Methods & Getters +

+ +- `#selectSidebarItem(name)` + - Selects an item from the sidebar menu. Use `settings#sidebar_items` to see available items. + +- `#getSettingOption(name)` + - Finds a setting by name and returns it. Use `settings#setting_options` to see available options. + +- `#setting_options` + - Returns settings available in the page. + +- `#sidebar_items` + - Returns options available in the sidebar menu. + +

+
+ + +### getAnalytics() + +Retrieves basic channel analytics. + +**Returns:** `Promise.` + +
+Methods & Getters +

+ +- `#page` + - Returns original InnerTube response (sanitized). + +

+
\ No newline at end of file diff --git a/docs/API/interaction-manager.md b/docs/API/interaction-manager.md new file mode 100644 index 00000000..bcada4db --- /dev/null +++ b/docs/API/interaction-manager.md @@ -0,0 +1,108 @@ +# InteractionManager + +Handles direct interactions. + +## API + +* InteractionManager + * [.like(video_id)](#like) + * [.dislike(video_id)](#dislike) + * [.removeLike(video_id)](#removelike) + * [.subscribe(video_id)](#subscribe) + * [.unsubscribe(video_id)](#unsubscribe) + * [.comment(video_id, text)](#comment) + * [.translate(text, target_language, args?)](#translate) + * [.setNotificationPreferences(channel_id, type)](#setnotificationpreferences) + + +### like(video_id) + +Likes given video. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | + + +### dislike(video_id) + +Dislikes given video. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | + + +### removeLike(video_id) + +Remover like/dislike. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | + + +### subscribe(channel_id) + +Subscribes to given channel. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| channel_id | `string` | Channel id | + + +### unsubscribe(channel_id) + +Unsubscribes from given channel. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| channel_id | `string` | Channel id | + + +### comment(video_id, text) + +Posts a comment on given video. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | +| text | `string` | Comment content | + + +### translate(text, target_language, args?) + +Translates given text using YouTube's comment translation feature. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| text | `string` | Text to be translated | +| target_language | `string` | ISO language code | +| args? | `object` | Additional arguments | + + +### setNotificationPreferences(channel_id, type) + +Changes notification preferences for a given channel. +Only works with channels you are subscribed to. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| channel_id | `string` | Channel id | +| type | `string` | `PERSONALIZED`, `ALL` or `NONE` | \ No newline at end of file diff --git a/docs/API/music.md b/docs/API/music.md new file mode 100644 index 00000000..4221e82f --- /dev/null +++ b/docs/API/music.md @@ -0,0 +1,250 @@ +# Music + +YouTube Music class. + +## API + +* Music + * [.getInfo(video_id)](#getinfo) + * [.search(query, [filters?])](#search) + * [.getHomeFeed()](#gethomefeed) + * [.getExplore()](#getexplore) + * [.getLibrary()](#getlibrary) + * [.getArtist(artist_id)](#getartist) + * [.getAlbum(album_id)](#getalbum) + * [.getPlaylist(playlist_id)](#getplaylist) + * [.getLyrics(video_id)](#getlyrics) + * [.getUpNext(video_id)](#getupnext) + * [.getRelated(video_id)](#getrelated) + * [.getSearchSuggestions(query)](#getsearchsuggestions) + + +### getInfo(video_id) + +Retrieves track info. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | + + +### search(query, [filters?]) + +Searches on YouTube Music. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| query | `string` | Search query | +| filters? | `object` | Search filters | + +
+Methods & Getters +

+ +- `#getMore(shelf)` + - Equivalent to clicking on the shelf to load more items. + +- `#getContinuation()` + - Retrieves continuation, only works for individual sections or filtered results. + +- `#selectFilter(name)` + - Applies given filter to the search. + +- `#has_continuation` + - Checks if continuation is available. + +- `#filters` + - Returns available filters. + +- `#songs` + - Returns songs shelf. + +- `#videos` + - Returns videos shelf. + +- `#albums` + - Returns albums shelf. + +- `#artists` + - Returns artists shelf. + +- `#playlists` + - Returns songs shelf. + +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ + +### getHomeFeed() + +Retrieves home feed. + +**Returns:** `Promise.` + +
+Methods & Getters +

+ +- `#getContinuation()` + - Retrieves continuation, only works for individual sections or filtered results. + +- `#has_continuation` + - Checks if continuation is available. + +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ + +### getExplore() + +Retrieves “Explore” feed. + +**Returns:** `Promise.` + +
+Methods & Getters +

+ +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ + +### getLibrary() + +Retrieves library. + +**Returns:** `Promise.` + + + + +### getArtist(artist_id) + +Retrieves artist's info & content. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| artist_id | `string` | Artist id | + +
+Methods & Getters +

+ +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ + +### getAlbum(album_id) + +Retrieves given album. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| album_id | `string` | Album id | + +
+Methods & Getters +

+ +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ + +### getPlaylist(playlist_id) + +Retrieves given playlist. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| playlist_id | `string` | Playlist id | + +
+Methods & Getters +

+ +- `#has_continuation` + - Checks if continuation is available. + +- `#page` + - Returns original InnerTube response (sanitized). + +

+
+ + +### getLyrics(video_id) + +Retrieves song lyrics. + +**Returns:** `Promise.<{ text: string; footer: object; }>` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | + + +### getUpNext(video_id) + +Retrieves up next content. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | + + +### getRelated(video_id) + +Retrieves related content. + +**Returns:** `Promise.>` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | + + +### getSearchSuggestions(query) + +Retrieves search suggestions. + +**Returns:** `Promise.>` + +| Param | Type | Description | +| --- | --- | --- | +| query | `string` | Search query | \ No newline at end of file diff --git a/docs/API/playlist.md b/docs/API/playlist.md new file mode 100644 index 00000000..8db400a9 --- /dev/null +++ b/docs/API/playlist.md @@ -0,0 +1,72 @@ +# PlaylistManager + +Playlist management class. + +## API + +* PlaylistManager + * [.create(title, video_ids)](#create) + * [.delete(playlist_id)](#delete) + * [.addVideos(playlist_id, video_ids)](#addvideos) + * [.removeVideos(playlist_id, video_ids)](#removevideos) + * [.moveVideo(playlist_id, moved_video_id, predecessor_video_id)](#movevideo) + + +### create(title, video_ids) + +Creates a playlist. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| title | `string` | Playlist name | +| video_ids | `string[]` | array of videos | + + +### delete(playlist_id) + +Deletes given playlist. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| playlist_id | `string` | Playlist id | + + +### addVideos(playlist_id, video_ids) + +Adds videos to given playlist. + +**Returns:** `Promise.<{ playlist_id: string; action_result: any[] }>` + +| Param | Type | Description | +| --- | --- | --- | +| playlist_id | `string` | Playlist id | +| video_ids | `string` | array of videos | + + +### removeVideos(playlist_id, video_ids) + +Removes videos from given playlist. + +**Returns:** `Promise.<{ playlist_id: string; action_result: any[] }>` + +| Param | Type | Description | +| --- | --- | --- | +| playlist_id | `string` | Playlist id | +| video_ids | `string` | array of videos | + + +### moveVideo(playlist_id, moved_video_id, predecessor_video_id) + +Moves a video to a new position within a given playlist. + +**Returns:** `Promise.<{ playlist_id: string; action_result: any[] }>` + +| Param | Type | Description | +| --- | --- | --- | +| 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 | \ No newline at end of file diff --git a/docs/API/session.md b/docs/API/session.md new file mode 100644 index 00000000..dde7934e --- /dev/null +++ b/docs/API/session.md @@ -0,0 +1,83 @@ +# Session + +Represents an InnerTube session. + +## API + +* Session + * [.signIn(credentials?)](#signin) ⇒ `function` + * [.signOut()](#signout) ⇒ `function` + * [.key](#key) ⇒ `getter` + * [.api_version](#api_version) ⇒ `getter` + * [.client_version](#client_version) ⇒ `getter` + * [.client_name](#client_name) ⇒ `getter` + * [.context](#context) ⇒ `getter` + * [.player](#player) ⇒ `getter` + * [.lang](#lang) ⇒ `getter` + + +### signIn(credentials?) + +Signs in with given credentials. + +**Returns:** `Promise` + +| Param | Type | Description | +| --- | --- | --- | +| credentials? | `Credentials` | OAuth credentials | + + +### signOut() + +Signs out of the current account. + +**Returns:** `Promise` + + +### key + +InnerTube API key. + +**Returns:** `string` + + +### key + +InnerTube API version. + +**Returns:** `string` + + +### client_version + +InnerTube client version. + +**Returns:** `string` + + +### client_name + +InnerTube client name. + +**Returns:** `string` + + +### context + +InnerTube context. + +**Returns:** `Context` + + +### player + +Player script object. + +**Returns:** `Player` + + +### lang + +Client language. + +**Returns:** `string` \ No newline at end of file diff --git a/docs/API/studio.md b/docs/API/studio.md new file mode 100644 index 00000000..210ce636 --- /dev/null +++ b/docs/API/studio.md @@ -0,0 +1,33 @@ +# Studio + +YouTube Studio class (WIP). + +## API + +* Studio + * [.setThumbnail(video_id, buffer)](#setthumbnail) + * [.upload(file, metadata)](#upload) + + +### setThumbnail(video_id, buffer) + +Uploads a custom thumbnail and sets it for a video. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| video_id | `string` | Video id | +| buffer | `Uint8Array` | Thumbnail buffer | + + +### upload(file, metadata) + +Uploads a video to YouTube. + +**Returns:** `Promise.` + +| Param | Type | Description | +| --- | --- | --- | +| file | `BodyInit` | Video file | +| metadata | `VideoMetadata` | Video metadata | \ No newline at end of file