mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-17 03:22:15 +00:00
* feat: allow setting search params to custom value
This is useful for getting results other than videos, like playlists and
channels.
* feat: add initial parsers for common renderers
* feat: artist search renderers
Added common renderers used when searching artists
* refactor: snake_case
* feat: channel home page renderers
* feat: parsers for more channel tabs
These are needed for channel tabs: Videos, Playlists, Community,
Channels
Additionally, do not merely return text as string, since they may
include links which may be navigated to
* feat: channel full metadata
* feat: renderers for playlists
* refactor!: Actions.browse
Channels should be viewable when not logged in, also added 'navigation'
type for use in NagivationEndpoint in the future.
* feat: home feed parsers
* feat: watch page renderers
* feat: start implementing HomeFeed API
The HomeFeed class remains compatible with the existing API
* feat: generate types using tsc and jsdoc
* feat: browse continuations from navigationEndpoint
* fix: Actions moved to session
This follows commit 1bfe2676d8
* fix: add more typescript config
* chore: use correct spaces and quotes
* feat: Trending API
* feat: reimplement existing channel API
* feat: add base video feed class
* feat: get channel videos
* feat: channel playlists
* feat: get channel community posts
* feat: get channels from channel
* feat: get channel about page data
* feat: add missing channel parsers
this commit also adds regenerated types I've neglected to push
* feat: initial playlist reimplementation
* feat: complete playlist reimplementation
* refactor: change InnertubeError to ES6 class
* fix: some unresolved types
* chore: update types
* feat: wip video details
* feat: get music tracks in video
Possibly an implementation for issue #48
* refactor: merge parsers (wip)
This is a work in progress.
* fix: add pnpm to ignore
* fix: merge issues
* fix: merge Video and VideoInfo
VideoInfo should be working again.
Also remove the old parsers.
* feat: set matching in Simplify
Still looking into removing Simplify
* fix: ContinuationItem
This `call` method allows for traversal of continuations with the Simplify API
but may be removed in the future
* fix: optionally returned data
* revert: replace ContinuationItem with main
* feat(parser): contents memoization by classname
* feat(channel): working without Simplify
* feat(feed): working continuations
* fix: liniting issues
* feat(feed): filterable feed for home
* feat(feed): tabbed feed for trending & channel
* refactor: remove Simplify completely
* chore: lint
* refactor: alias `items` with `contents`
* refactor: `Search` to extend `Feed`
* fix: Search working
Also added MenuServiceItemDownload
* refactor: move `Channel` and `Playlist`
* fix: pass all tests
* fix: linting errors
65 lines
2.2 KiB
JavaScript
65 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
const NToken = require('../../../deciphers/NToken');
|
|
const Signature = require('../../../deciphers/Signature');
|
|
const QueryString = require('querystring');
|
|
|
|
class Format {
|
|
constructor(data) {
|
|
this.itag = data.itag;
|
|
this.mime_type = data.mimeType;
|
|
this.bitrate = data.bitrate;
|
|
this.average_bitrate = data.averageBitrate;
|
|
this.width = data.width || null;
|
|
this.height = data.height || null;
|
|
this.init_range = data.initRange && {
|
|
start: parseInt(data.initRange.start),
|
|
end: parseInt(data.initRange.end)
|
|
};
|
|
this.index_range = data.indexRange && {
|
|
start: parseInt(data.indexRange.start),
|
|
end: parseInt(data.indexRange.end)
|
|
};
|
|
this.last_modified = new Date(Math.floor(parseInt(data.lastModified) / 1000));
|
|
this.content_length = parseInt(data.contentLength);
|
|
this.quality = data.quality;
|
|
this.quality_label = data.qualityLabel || null;
|
|
this.fps = data.fps || null;
|
|
this.url = data.url || null;
|
|
this.cipher = data.cipher || null;
|
|
this.signature_cipher = data.signatureCipher || null;
|
|
this.audio_quality = data.audioQuality;
|
|
this.approx_duration_ms = parseInt(data.approxDurationMs);
|
|
this.audio_sample_rate = parseInt(data.audioSampleRate);
|
|
this.audio_channels = data.audioChannels;
|
|
this.loudness_db = data.loudnessDb;
|
|
this.has_audio = !!data.audioBitrate || !!data.audioQuality;
|
|
this.has_video = !!data.qualityLabel;
|
|
}
|
|
|
|
decipher(player) {
|
|
this.url = this.url || this.signature_cipher || this.cipher;
|
|
|
|
const args = QueryString.parse(this.url);
|
|
const url_components = new URL(args.url);
|
|
|
|
url_components.searchParams.set('ratebypass', 'yes');
|
|
|
|
if (this.signature_cipher || this.cipher) {
|
|
const signature = new Signature(this.url, player.signature_decipher).decipherBeta();
|
|
|
|
args.sp ?
|
|
url_components.searchParams.set(args.sp, signature) :
|
|
url_components.searchParams.set('signature', signature);
|
|
}
|
|
|
|
if (url_components.searchParams.get('n')) {
|
|
const ntoken = new NToken(player.ntoken_decipher, url_components.searchParams.get('n')).transform();
|
|
url_components.searchParams.set('n', ntoken);
|
|
}
|
|
|
|
return url_components.toString();
|
|
}
|
|
}
|
|
|
|
module.exports = Format; |