mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 12:31:17 +00:00
chore: merge
This commit is contained in:
@@ -139,7 +139,7 @@ export default class MediaInfo {
|
||||
manifest_options
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a cleaned up representation of the adaptive_formats
|
||||
*/
|
||||
@@ -207,10 +207,7 @@ export default class MediaInfo {
|
||||
return new TranscriptInfo(this.actions, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds video to the watch history.
|
||||
*/
|
||||
async addToWatchHistory(client_name: string = Constants.CLIENTS.WEB.NAME, client_version: string = Constants.CLIENTS.WEB.VERSION, replacement = 'https://www.'): Promise<Response> {
|
||||
async addToWatchHistory(client_name?: string, client_version?: string, replacement = 'https://www.'): Promise<Response> {
|
||||
if (!this.#playback_tracking)
|
||||
throw new InnertubeError('Playback tracking not available');
|
||||
|
||||
@@ -223,6 +220,26 @@ export default class MediaInfo {
|
||||
|
||||
const url = this.#playback_tracking.videostats_playback_url.replace('https://s.', replacement);
|
||||
|
||||
return await this.#actions.stats(url, {
|
||||
client_name: client_name || Constants.CLIENTS.WEB.NAME,
|
||||
client_version: client_version || Constants.CLIENTS.WEB.VERSION
|
||||
}, url_params);
|
||||
}
|
||||
|
||||
async updateWatchTime(startTime: number, client_name: string = Constants.CLIENTS.WEB.NAME, client_version: string = Constants.CLIENTS.WEB.VERSION, replacement = 'https://www.'): Promise<Response> {
|
||||
if (!this.#playback_tracking)
|
||||
throw new InnertubeError('Playback tracking not available');
|
||||
|
||||
const url_params = {
|
||||
cpn: this.#cpn,
|
||||
st: startTime.toFixed(3),
|
||||
et: startTime.toFixed(3),
|
||||
cmt: startTime.toFixed(3),
|
||||
final: '1'
|
||||
};
|
||||
|
||||
const url = this.#playback_tracking.videostats_watchtime_url.replace('https://s.', replacement);
|
||||
|
||||
return await this.#actions.stats(url, {
|
||||
client_name,
|
||||
client_version
|
||||
@@ -243,7 +260,7 @@ export default class MediaInfo {
|
||||
/**
|
||||
* Parsed InnerTube response.
|
||||
*/
|
||||
get page(): [ IPlayerResponse, INextResponse? ] {
|
||||
get page(): [IPlayerResponse, INextResponse?] {
|
||||
return this.#page;
|
||||
}
|
||||
}
|
||||
@@ -192,6 +192,13 @@ export default class VideoInfo extends MediaInfo {
|
||||
return super.addToWatchHistory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates watch time for the video.
|
||||
*/
|
||||
async updateWatchTime(startTime: number): Promise<Response> {
|
||||
return super.updateWatchTime(startTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves watch next feed continuation.
|
||||
*/
|
||||
|
||||
@@ -144,6 +144,13 @@ class TrackInfo extends MediaInfo {
|
||||
async addToWatchHistory(): Promise<Response> {
|
||||
return super.addToWatchHistory(Constants.CLIENTS.YTMUSIC.NAME, Constants.CLIENTS.YTMUSIC.VERSION, 'https://music.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the watch time of the song.
|
||||
*/
|
||||
async updateWatchTime(startTime: number): Promise<Response> {
|
||||
return super.updateWatchTime(startTime, Constants.CLIENTS.YTMUSIC.NAME, Constants.CLIENTS.YTMUSIC.VERSION, 'https://music.');
|
||||
}
|
||||
|
||||
get available_tabs(): string[] {
|
||||
return this.tabs ? this.tabs.map((tab) => tab.title) : [];
|
||||
|
||||
Reference in New Issue
Block a user