mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-23 23:09:28 +00:00
chore: clean up some types [skip ci]
This commit is contained in:
@@ -38,24 +38,11 @@ import * as Constants from './utils/Constants.js';
|
||||
import { InnertubeError, generateRandomString, throwIfMissing } from './utils/Utils.js';
|
||||
|
||||
import type { ApiResponse } from './core/Actions.js';
|
||||
import type { INextRequest } from './types/index.js';
|
||||
import type { InnerTubeConfig, InnerTubeClient, SearchFilters, INextRequest } from './types/index.js';
|
||||
import type { IBrowseResponse, IParsedResponse } from './parser/types/index.js';
|
||||
import type { DownloadOptions, FormatOptions } from './types/FormatUtils.js';
|
||||
import type { SessionOptions } from './core/Session.js';
|
||||
import type Format from './parser/classes/misc/Format.js';
|
||||
|
||||
export type InnerTubeConfig = SessionOptions;
|
||||
|
||||
export type InnerTubeClient = 'IOS' | 'WEB' | 'ANDROID' | 'YTMUSIC' | 'YTMUSIC_ANDROID' | 'YTSTUDIO_ANDROID' | 'TV_EMBEDDED' | 'YTKIDS';
|
||||
|
||||
export type SearchFilters = Partial<{
|
||||
upload_date: 'all' | 'hour' | 'today' | 'week' | 'month' | 'year';
|
||||
type: 'all' | 'video' | 'channel' | 'playlist' | 'movie';
|
||||
duration: 'all' | 'short' | 'medium' | 'long';
|
||||
sort_by: 'relevance' | 'rating' | 'upload_date' | 'view_count';
|
||||
features: ('hd' | 'subtitles' | 'creative_commons' | '3d' | 'live' | 'purchased' | '4k' | '360' | 'location' | 'hdr' | 'vr180')[];
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Provides access to various services and modules in the YouTube API.
|
||||
*/
|
||||
@@ -103,7 +90,7 @@ export default class Innertube {
|
||||
|
||||
const player_response = this.actions.execute(PlayerEndpoint.PATH, player_payload);
|
||||
const next_response = this.actions.execute(NextEndpoint.PATH, next_payload);
|
||||
const response = await Promise.all([ player_response, next_response ]);
|
||||
const response = await Promise.all([player_response, next_response]);
|
||||
|
||||
const cpn = generateRandomString(16);
|
||||
|
||||
@@ -124,7 +111,7 @@ export default class Innertube {
|
||||
|
||||
const cpn = generateRandomString(16);
|
||||
|
||||
return new VideoInfo([ response ], this.actions, cpn);
|
||||
return new VideoInfo([response], this.actions, cpn);
|
||||
}
|
||||
|
||||
async getShortsVideoInfo(video_id: string, client?: InnerTubeClient): Promise<ShortFormVideoInfo> {
|
||||
@@ -140,11 +127,11 @@ export default class Innertube {
|
||||
})
|
||||
);
|
||||
|
||||
const response = await Promise.all([ watch_response, sequence_response ]);
|
||||
const response = await Promise.all([watch_response, sequence_response]);
|
||||
|
||||
const cpn = generateRandomString(16);
|
||||
|
||||
return new ShortFormVideoInfo([ response[0] ], this.actions, cpn, response[1]);
|
||||
return new ShortFormVideoInfo([response[0]], this.actions, cpn, response[1]);
|
||||
}
|
||||
|
||||
async search(query: string, filters: SearchFilters = {}): Promise<Search> {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Constants } from '../../utils/index.js';
|
||||
import { InnertubeError, MissingParamError, Platform } from '../../utils/Utils.js';
|
||||
import { CreateVideoEndpoint } from '../endpoints/upload/index.js';
|
||||
|
||||
import type { UpdateVideoMetadataOptions, UploadedVideoMetadataOptions } from '../../types/Clients.js';
|
||||
import type { UpdateVideoMetadataOptions, UploadedVideoMetadataOptions } from '../../types/Misc.js';
|
||||
import type { ApiResponse, Session } from '../index.js';
|
||||
|
||||
interface UploadResult {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
export * as Parser from './parser.js';
|
||||
export * from './continuations.js';
|
||||
export * from './types/index.js';
|
||||
export * as Misc from './misc.js';
|
||||
export * as YTNodes from './nodes.js';
|
||||
export * as YT from './youtube/index.js';
|
||||
@@ -8,4 +6,9 @@ export * as YTMusic from './ytmusic/index.js';
|
||||
export * as YTKids from './ytkids/index.js';
|
||||
export * as YTShorts from './ytshorts/index.js';
|
||||
export * as Helpers from './helpers.js';
|
||||
export * as Generator from './generator.js';
|
||||
export * as Generator from './generator.js';
|
||||
export * as APIResponseTypes from './types/index.js';
|
||||
export * from './continuations.js';
|
||||
|
||||
// @TODO: Remove this when files are updated to use APIResponseTypes or /types/index.js directly.
|
||||
export * from './types/index.js';
|
||||
@@ -2,9 +2,10 @@ import type { Memo, ObservedArray, SuperParsedResult, YTNode } from '../helpers.
|
||||
import type {
|
||||
ReloadContinuationItemsCommand, Continuation, GridContinuation,
|
||||
ItemSectionContinuation, LiveChatContinuation, MusicPlaylistShelfContinuation, MusicShelfContinuation,
|
||||
PlaylistPanelContinuation, SectionListContinuation, ContinuationCommand,
|
||||
CpnSource
|
||||
PlaylistPanelContinuation, SectionListContinuation, ContinuationCommand
|
||||
} from '../index.js';
|
||||
|
||||
import type { CpnSource } from './RawResponse.js';
|
||||
import type PlayerCaptionsTracklist from '../classes/PlayerCaptionsTracklist.js';
|
||||
import type CardCollection from '../classes/CardCollection.js';
|
||||
import type Endscreen from '../classes/Endscreen.js';
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
export type UpdateVideoMetadataOptions = Partial<{
|
||||
title: string;
|
||||
description: string;
|
||||
tags: string[];
|
||||
category: number;
|
||||
license: string;
|
||||
age_restricted: boolean;
|
||||
made_for_kids: boolean;
|
||||
privacy: 'PUBLIC' | 'PRIVATE' | 'UNLISTED';
|
||||
}>;
|
||||
|
||||
export type UploadedVideoMetadataOptions = Partial<{
|
||||
title: string;
|
||||
description: string;
|
||||
privacy: 'PUBLIC' | 'PRIVATE' | 'UNLISTED';
|
||||
is_draft: boolean;
|
||||
}>;
|
||||
|
||||
export type MusicSearchFilters = Partial<{
|
||||
type: 'all' | 'song' | 'video' | 'album' | 'playlist' | 'artist';
|
||||
}>;
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { InnerTubeClient } from '../Innertube.js';
|
||||
import type { InnerTubeClient } from '../types/index.js';
|
||||
|
||||
export type SnakeToCamel<S extends string> = S extends `${infer T}_${infer U}` ? `${Lowercase<T>}${Capitalize<SnakeToCamel<U>>}` : S;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { InnerTubeClient } from '../Innertube.js';
|
||||
import type { InnerTubeClient } from '../types/index.js';
|
||||
import type { Format } from '../parser/misc.js';
|
||||
|
||||
export type URLTransformer = (url: URL) => URL;
|
||||
|
||||
42
src/types/Misc.ts
Normal file
42
src/types/Misc.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { SessionOptions } from '../core/index.js';
|
||||
|
||||
export type InnerTubeConfig = SessionOptions;
|
||||
export type InnerTubeClient = 'IOS' | 'WEB' | 'ANDROID' | 'YTMUSIC' | 'YTMUSIC_ANDROID' | 'YTSTUDIO_ANDROID' | 'TV_EMBEDDED' | 'YTKIDS';
|
||||
|
||||
export type UploadDate = 'all' | 'hour' | 'today' | 'week' | 'month' | 'year';
|
||||
export type SearchType = 'all' | 'video' | 'channel' | 'playlist' | 'movie';
|
||||
export type Duration = 'all' | 'short' | 'medium' | 'long';
|
||||
export type SortBy = 'relevance' | 'rating' | 'upload_date' | 'view_count';
|
||||
export type Feature = 'hd' | 'subtitles' | 'creative_commons' | '3d' | 'live' | 'purchased' | '4k' | '360' | 'location' | 'hdr' | 'vr180';
|
||||
|
||||
export type SearchFilters = {
|
||||
upload_date?: UploadDate;
|
||||
type?: SearchType;
|
||||
duration?: Duration;
|
||||
sort_by?: SortBy;
|
||||
features?: Feature[];
|
||||
};
|
||||
|
||||
export type UpdateVideoMetadataOptions = Partial<{
|
||||
title: string;
|
||||
description: string;
|
||||
tags: string[];
|
||||
category: number;
|
||||
license: string;
|
||||
age_restricted: boolean;
|
||||
made_for_kids: boolean;
|
||||
privacy: 'PUBLIC' | 'PRIVATE' | 'UNLISTED';
|
||||
}>;
|
||||
|
||||
export type UploadedVideoMetadataOptions = Partial<{
|
||||
title: string;
|
||||
description: string;
|
||||
privacy: 'PUBLIC' | 'PRIVATE' | 'UNLISTED';
|
||||
is_draft: boolean;
|
||||
}>;
|
||||
|
||||
export type MusicSearchType = 'all' | 'song' | 'video' | 'album' | 'playlist' | 'artist';
|
||||
|
||||
export type MusicSearchFilters = {
|
||||
type?: MusicSearchType;
|
||||
};
|
||||
@@ -2,6 +2,6 @@ export type { default as PlatformShim } from './PlatformShim.js';
|
||||
|
||||
export * from './Cache.js';
|
||||
export * from './PlatformShim.js';
|
||||
export * from './Clients.js';
|
||||
export * from './Misc.js';
|
||||
export * from './Endpoints.js';
|
||||
export * from './FormatUtils.js';
|
||||
Reference in New Issue
Block a user