style: clean up and fix minor inconsistencies

This commit is contained in:
LuanRT
2023-02-13 19:42:49 -03:00
parent e37cf62732
commit 6e30309f56
8 changed files with 19 additions and 22 deletions

View File

@@ -26,6 +26,9 @@ async function main() {
// now serialize the headers
url.searchParams.set('__headers', JSON.stringify([...headers]));
// @ts-ignore
input.duplex = 'half';
// copy over the request
const request = new Request(
url,
@@ -42,7 +45,7 @@ async function main() {
headers
});
},
cache: new UniversalCache(),
cache: new UniversalCache(false),
});
const span = document.getElementById('video_name') as HTMLSpanElement;
@@ -66,7 +69,6 @@ async function main() {
}
try {
const video = await yt.getInfo(video_id);
console.log(video);
span.textContent = video.basic_info.title || null;

View File

@@ -14,10 +14,10 @@ import VideoInfo from './parser/youtube/VideoInfo.js';
import AccountManager from './core/AccountManager.js';
import Feed from './core/Feed.js';
import InteractionManager from './core/InteractionManager.js';
import YTKids from './core/Kids.js';
import YTMusic from './core/Music.js';
import PlaylistManager from './core/PlaylistManager.js';
import YTStudio from './core/Studio.js';
import YTKids from './core/Kids.js';
import TabbedFeed from './core/TabbedFeed.js';
import HomeFeed from './parser/youtube/HomeFeed.js';
import Proto from './proto/index.js';
@@ -26,10 +26,10 @@ import Constants from './utils/Constants.js';
import type Actions from './core/Actions.js';
import type Format from './parser/classes/misc/Format.js';
import { generateRandomString, throwIfMissing } from './utils/Utils.js';
import type { FormatOptions, DownloadOptions } from './utils/FormatUtils.js';
import type { ApiResponse } from './core/Actions.js';
import type { IBrowseResponse, IParsedResponse } from './parser/types/ParsedResponse.js';
import type { IBrowseResponse, IParsedResponse } from './parser/types/index.js';
import type { DownloadOptions, FormatOptions } from './utils/FormatUtils.js';
import { generateRandomString, throwIfMissing } from './utils/Utils.js';
export type InnertubeConfig = SessionOptions;

View File

@@ -5,13 +5,10 @@ import type Session from './Session.js';
import type {
IBrowseResponse, IGetNotificationsMenuResponse,
INextResponse, IParsedResponse, IPlayerResponse,
IResolveURLResponse, ISearchResponse,
IUpdatedMetadataResponse
} from '../parser/types/ParsedResponse.js';
import type { IRawResponse } from '../parser/types/RawResponse.js';
INextResponse, IPlayerResponse, IResolveURLResponse,
ISearchResponse, IUpdatedMetadataResponse,
IParsedResponse, IRawResponse
} from '../parser/types/index.js';
export interface ApiResponse {
success: boolean;

View File

@@ -11,8 +11,7 @@ import type LiveChatHeader from './classes/LiveChatHeader.js';
import type LiveChatItemList from './classes/LiveChatItemList.js';
import type Alert from './classes/Alert.js';
import type { IParsedResponse } from './types/ParsedResponse.js';
import type { IRawResponse, RawData, RawNode } from './types/RawResponse.js';
import type { IParsedResponse, IRawResponse, RawData, RawNode } from './types/index.js';
import MusicMultiSelectMenuItem from './classes/menus/MusicMultiSelectMenuItem.js';
import Format from './classes/misc/Format.js';

View File

@@ -311,7 +311,7 @@ class VideoInfo {
* @param format_filter - Function to filter the formats.
* @returns DASH manifest
*/
toDash(url_transformer: URLTransformer = (url) => url, format_filter: FormatFilter): string {
toDash(url_transformer?: URLTransformer, format_filter?: FormatFilter): string {
return FormatUtils.toDash(this.streaming_data, url_transformer, format_filter, this.#cpn, this.#player);
}

View File

@@ -73,7 +73,7 @@ class VideoInfo {
* @param format_filter - Function to filter the formats.
* @returns DASH manifest
*/
toDash(url_transformer: URLTransformer = (url) => url, format_filter: FormatFilter): string {
toDash(url_transformer?: URLTransformer, format_filter?: FormatFilter): string {
return FormatUtils.toDash(this.streaming_data, url_transformer, format_filter, this.#cpn, this.#actions.session.player);
}

View File

@@ -95,7 +95,7 @@ class TrackInfo {
* @param format_filter - Function to filter the formats.
* @returns DASH manifest
*/
toDash(url_transformer: URLTransformer = (url) => url, format_filter: FormatFilter): string {
toDash(url_transformer?: URLTransformer, format_filter?: FormatFilter): string {
return FormatUtils.toDash(this.streaming_data, url_transformer, format_filter, this.#cpn, this.#actions.session.player);
}

View File

@@ -311,7 +311,7 @@ class FormatUtils {
if (!video_format.index_range || !video_format.init_range) {
return;
}
const mime_type = video_format.mime_type.split(';')[0];
const mime_type = video_format.mime_type;
const mime_type_index = mime_types.indexOf(mime_type);
if (mime_type_index > -1) {
mime_objects[mime_type_index].push(video_format);
@@ -324,7 +324,6 @@ class FormatUtils {
let set_id = 0;
for (let i = 0; i < mime_types.length; i++) {
// When the video has multiple different audio tracks/langues we want to include the extra information in the manifest
if (mime_objects[i][0].has_audio && mime_objects[i][0].language) {
const languages: string[] = [];
@@ -367,7 +366,7 @@ class FormatUtils {
const set = this.#el(document, 'AdaptationSet', {
id: `${set_id++}`,
mimeType: mime_types[i],
mimeType: mime_types[i].split(';')[0],
startWithSAP: '1',
subsegmentAlignment: 'true',
lang: languages[j]
@@ -382,7 +381,7 @@ class FormatUtils {
} else {
const set = this.#el(document, 'AdaptationSet', {
id: `${set_id++}`,
mimeType: mime_types[i],
mimeType: mime_types[i].split(';')[0],
startWithSAP: '1',
subsegmentAlignment: 'true'
});