From 440d80063dcae548174921b6e9ff52eb8e6c964f Mon Sep 17 00:00:00 2001 From: "luan.lrt4@gmail.com" Date: Sat, 16 Apr 2022 22:02:17 -0300 Subject: [PATCH] chore: update typings --- typings/index.d.ts | 210 ++++++++++++++++++++++++--------------------- 1 file changed, 113 insertions(+), 97 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 8ee7352b..72e572c8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,152 +1,168 @@ interface AuthInfo { - access_token: string - refresh_token: string - expires: Date + access_token: string; + refresh_token: string; + expires: Date; } interface AccountInfo { - name: string - photo: Record[] - country: string - language: string + name: string; + photo: Record[]; + country: string; + language: string; } interface SearchOptions { - client: 'YTMUSIC' | 'YOUTUBE' - period: 'any' | 'hour' | 'day' | 'week' | 'month' | 'year' - order: 'relevance' | 'rating' | 'age' | 'views' - duration: 'any' | 'short' | 'long' + client: 'YTMUSIC' | 'YOUTUBE'; + period: 'any' | 'hour' | 'day' | 'week' | 'month' | 'year'; + order: 'relevance' | 'rating' | 'age' | 'views'; + duration: 'any' | 'short' | 'long'; } -interface SearchOther { - query: string - corrected_query: string - estimated_results: number - videos: any[] +interface YouTubeSearch { + query: string; + corrected_query: string; + estimated_results: number; + videos: any[]; } -interface Results { - songs: any[] - videos: any[] - albums: any[] - playlists: any[] +interface YouTubeMusicSearch { + query: string; + corrected_query: string; + results: { + top_result?: any[]; + songs?: any[]; + albums?: any[]; + videos?: any[]; + community_playlists?: any[]; + artists?: any[]; + } } -type SearchResults = Results | SearchOther +type SearchResults = YouTubeSearch | YouTubeMusicSearch; + +type ClientOption = Pick; -type ClientOption = Pick interface Suggestion { - text: string - bold_text: string + text: string; + bold_text: string; } interface ApiStatus { - success: boolean - status_code: number - data: any - message?: string + success: boolean; + status_code: number; + data: object; + message?: string; } interface Comments { - comments: [] + comments: any[]; comment_count?: string; } interface Video { - title: string - description: string - thumbnail: [] - metadata: Record - like: () => Promise - dislike: () => Promise - removeLike: () => Promise - subscribe: () => Promise - unsubscribe: () => Promise - comment: (test: string) => Promise - getComments: () => Promise - getLivechat: () => any // TODO type LiveChat - changeNotificationPreferences: () => Promise + title: string; + description: string; + thumbnail: object; + metadata: Record; + like: () => Promise; + dislike: () => Promise; + removeLike: () => Promise; + subscribe: () => Promise; + unsubscribe: () => Promise; + comment: (text: string) => Promise; + getComments: () => Promise; + getLivechat: () => any; // TODO type LiveChat + changeNotificationPreferences: () => Promise; } interface Channel { - title: string - description: string - metadata: object - content: object + title: string; + description: string; + metadata: object; + content: object; } interface PlayList { - description: string - items: any[] - title: string - total_items: string | number - duration?: string - last_updated?: string - views?: string - year?: string + description: string; + items: any[]; + title: string; + total_items: string | number; + duration?: string; + last_updated?: string; + views?: string; + year?: string; } interface CommentData { - token: string - channel_id: string + token: string; + channel_id: string; } interface History { - items: [{ date: string; videos: any[] }] + items: { + date: string; + videos: any[]; + }[]; +} + +interface SubscriptionFeed { + items: { + date: string; + videos: any[]; + }[]; } interface HomeFeed { videos: { - id: string - title: string - description: string - channel: string - metadata: Record - }[] + id: string; + title: string; + description: string; + channel: string; + metadata: Record; + }[]; } -interface SubscriptionFeed { items: { date: string; videos: any[] } } - interface Notifications { items: { - title: string - sent_time: string - channel_name: string - channel_thumbnail: Record - video_thumbnail: Record - video_url: string - read: boolean - notification_id: string - }[] + title: string; + sent_time: string; + channel_name: string; + channel_thumbnail: Record; + video_thumbnail: Record; + video_url: string; + read: boolean; + notification_id: string; + }[]; } interface StreamingData { - selected_format: Record - formats: any[] + selected_format: Record; + formats: any[]; } interface StreamingOptions { - quality?: string - type?: string - format?: string + quality?: string; + type?: string; + format?: string; } export default class Innertube { constructor(cookie?: string) - public signIn(auth_info: AuthInfo): Promise - public getAccountInfo(): Promise - public search(query: string, options: SearchOptions): Promise - public getSearchSuggestions(options: ClientOption): Promise - public getDetails(video_id: string): Promise - public getChannel(id: string): Promise - public getLyrics(video_id: string): Promise - public getPlaylist(playlist_id: string, options?: ClientOption): Promise - public getComments(video_id: string, options?: CommentData): Promise - public getHistory(): Promise - public getHomeFeed(): Promise - public getSubscriptionsFeed(): Promise - public getNotifications(): Promise - public getUnseenNotificationsCount(): Promise - public getStreamingData(id: string, options?: StreamingOptions): Promise - public download(id: string, options?: StreamingOptions): ReadableStream -} + public signIn(auth_info: AuthInfo): Promise; + public signOut(): Promise.; + public getAccountInfo(): Promise; + public search(query: string, options: SearchOptions): Promise; + public getSearchSuggestions(options: ClientOption): Promise; + public getDetails(video_id: string): Promise; + public getChannel(id: string): Promise; + public getLyrics(video_id: string): Promise; + public getPlaylist(playlist_id: string, options?: ClientOption): Promise; + public getComments(video_id: string, options?: CommentData): Promise; + public getHistory(): Promise; + public getHomeFeed(): Promise; + public getSubscriptionsFeed(): Promise; + public getNotifications(): Promise; + public getUnseenNotificationsCount(): Promise; + public getStreamingData(id: string, options?: StreamingOptions): Promise; + public download(id: string, options?: StreamingOptions): ReadableStream; +} \ No newline at end of file