This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added typescript type definitions (#17)
* added typescript type definitions * Update typescript declarations * Add isOfficialArtist to channel object * Use multi-line comments Co-authored-by: Alexandra <bug.graph@gmail.com> * remove playlist url from getChannelVideos * Squashed commit of the following: commit 243483f Author: SuperFurryCoder <100633427+SuperFurryCoder@users.noreply.github.com> Date: Tue Mar 15 20:07:14 2022 +0000 Fix for channels with no secondary links (#61) * Update youtube-grabber.js * Update youtube-grabber.js * Update youtube-grabber.js * Update youtube-grabber.js * remove unnecessary space Co-authored-by: PikachuEXE <pikachuexe@gmail.com> Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Co-authored-by: PikachuEXE <pikachuexe@gmail.com> commit 3291db3 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun Feb 13 14:02:57 2022 -0500 Bump follow-redirects from 1.14.7 to 1.14.8 (#60) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](follow-redirects/follow-redirects@v1.14.7...v1.14.8) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add getChannelStats and getChannelHome * fix HttpsProxyAgent reference * include types file in "files" Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Co-authored-by: Alexandra <bug.graph@gmail.com>
- Loading branch information
1 parent
1edd78f
commit fb63da4
Showing
3 changed files
with
259 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
import { HttpsProxyAgent } from 'https-proxy-agent'; | ||
|
||
declare module "yt-channel-info" { | ||
|
||
enum ChannelIdType { | ||
Default = 0, | ||
ChannelId, | ||
LegacyName, | ||
CustomURL | ||
} | ||
|
||
/** | ||
* A abstract ChannelInfoResponse containing a continuation string if there are more responses which can be loaded | ||
* and an array of items of the type T | ||
*/ | ||
interface ChannelInfoResponseContinuation<T> { | ||
items: T[]; | ||
/** | ||
* Will be null if no more results can be found. Used with getChannelPlaylistsMore() | ||
*/ | ||
continuation: string | null; | ||
} | ||
|
||
interface ChannelInfoResponse<T> extends ChannelInfoResponseContinuation<T> { | ||
channelIdType: ChannelIdType; | ||
alertMessage?: string; | ||
} | ||
|
||
interface ChannelCommunityPostsContinuationResponse extends ChannelInfoResponseContinuation<CommunityPost> { | ||
innerTubeApi: string; | ||
} | ||
interface ChannelCommunityPostsResponse extends ChannelCommunityPostsContinuationResponse { | ||
channelIdType: ChannelIdType; | ||
} | ||
|
||
interface RelatedChannel { | ||
channelName: string; | ||
channelId: string; | ||
channelUrl: string; | ||
thumbnail: Image[]; | ||
videoCount: number; | ||
subscriberText: string; | ||
subscriberCount: number; | ||
verified: boolean; | ||
officialArist: boolean; | ||
} | ||
|
||
interface ContinuationPayload { | ||
continuation: string; | ||
httpsAgent?: HttpsProxyAgent; | ||
} | ||
/** | ||
* ChannelInfo payload passed into getChannelInfo | ||
*/ | ||
|
||
interface ChannelInfoPayload { | ||
channelId: string; | ||
channelIdType?: ChannelIdType; | ||
httpsAgent?: HttpsProxyAgent; | ||
} | ||
|
||
interface CommunityPostContinuationPayload extends ContinuationPayload { | ||
innerTubeApi: string; | ||
} | ||
interface ChannelVideosPayload extends ChannelInfoPayload { | ||
sortBy?: "newest" | "oldest" | "popular"; | ||
} | ||
|
||
interface ChannelSearchPayload extends ChannelInfoPayload { | ||
query: string; | ||
} | ||
|
||
interface ChannelPlaylistPayload extends ChannelInfoPayload { | ||
sortBy?: "last" | "oldest" | "newest"; | ||
} | ||
|
||
/** | ||
* ChannelInfo type returned by getChannelVideos and getChannelInfoMore | ||
*/ | ||
interface ChannelInfo { | ||
author: string; | ||
authorId: string; | ||
authorUrl: string; | ||
/** | ||
* Is null if none exist | ||
**/ | ||
authorBanners: Image[] | null; | ||
/** | ||
* Is null if none exist | ||
**/ | ||
authorThumbnails: Image[] | null; | ||
subscriberText: string; | ||
subscriberCount: number; | ||
description: string; | ||
isFamilyFriendly: boolean; | ||
relatedChannels: RelatedChannel[]; | ||
allowedRegions: string[]; | ||
isVerified: boolean; | ||
isOfficialArtist: boolean; | ||
tags: string[]; | ||
channelIdType: number; | ||
alertMessage: string; | ||
} | ||
|
||
/** | ||
* An Image which represents all banners and thumbnails | ||
*/ | ||
interface Image { | ||
url: string; | ||
height: number; | ||
width: number; | ||
} | ||
|
||
/** | ||
* Video type returned by getChannelVideos and getChannelInfoMore | ||
*/ | ||
interface Video { | ||
author: string; | ||
authorId: string; | ||
durationText: string; | ||
lengthSeconds: number; | ||
liveNow: boolean; | ||
premiere: boolean; | ||
premium: boolean; | ||
publishedText: string; | ||
title: string; | ||
type: "video"; | ||
videoId: string; | ||
videoThumbnails: Image[] | null; | ||
viewCount: number; | ||
viewCountText: string; | ||
} | ||
|
||
/** | ||
* Playlist type returned by getChannelPlaylistInfo and getChannelPlaylistsMore | ||
*/ | ||
interface Playlist { | ||
author: string; | ||
authorId: string; | ||
authorUrl: string; | ||
playlistId: string; | ||
playlistThumbnail: string; | ||
playlistUrl: string; | ||
title: string; | ||
type: "playlist"; | ||
videoCount: number; | ||
} | ||
|
||
interface ImagePostContent { | ||
type: "image"; | ||
content: Image[] | ||
} | ||
|
||
interface PollPostContent { | ||
type: "poll"; | ||
content: { | ||
choices: string[]; | ||
totalVotes: string | ||
} | ||
} | ||
|
||
interface VideoPostContent { | ||
type: "video"; | ||
content: { | ||
videoId: string; | ||
title: string; | ||
description: string, | ||
publishedText: string, | ||
lengthText: string, | ||
viewCountText: string, | ||
ownerBadges: { | ||
verified: boolean; | ||
officialArtist: boolean; | ||
}, | ||
author: string; | ||
thumbnails: Image[]; | ||
} | ||
} | ||
interface PlaylistPostContent { | ||
type: 'playlist', | ||
content: { | ||
playlistId: string; | ||
title: string; | ||
playlistVideoRenderer: VideoPostContent[]; | ||
videoCountText: string; | ||
ownerBadges: { | ||
verified: boolean; | ||
officialArtist: boolean; | ||
}, | ||
author: String, | ||
thumbnails: Image[]; | ||
} | ||
} | ||
interface CommunityPost { | ||
postText: string; | ||
postId: string; | ||
author: string; | ||
authorThumbnails: string; | ||
publishedText: string; | ||
voteCount: string; | ||
postContent: ImagePostContent | PollPostContent | VideoPostContent | PlaylistPostContent | null | ||
} | ||
|
||
|
||
interface ChannelStatsResponse { | ||
joinedDate: number; | ||
viewCount: number; | ||
location: string; | ||
} | ||
|
||
interface Mix { | ||
playlistId: string; | ||
title: string; | ||
description: string; | ||
videoCount: number; | ||
url: string; | ||
thumbnails: Image[] | ||
} | ||
interface ChannelHomeResponse { | ||
featuredVideo : Video | ||
items: { | ||
shelfName: string; | ||
type: 'videos' | 'verticalVideoList' | 'playlist' | 'channels' | 'mix' | 'playlists' | 'video' | ||
items: Video[] | RelatedChannel[] | Playlist[] | Mix | ||
} | ||
} | ||
class YoutubeGrabber { | ||
static getChannelInfo(payload: ChannelInfoPayload): Promise<ChannelInfo>; | ||
|
||
static getChannelVideos(payload: ChannelVideosPayload): ChannelInfoResponse<Video>; | ||
|
||
static getChannelVideosMore(payload: ContinuationPayload): Promise<ChannelInfoResponseContinuation<Video>>; | ||
|
||
static getChannelPlaylistInfo(payload: ChannelPlaylistPayload): Promise<ChannelInfoResponse<Playlist>>; | ||
|
||
static getChannelPlaylistsMore(payload: ContinuationPayload): Promise<ChannelInfoResponseContinuation<Playlist>>; | ||
|
||
static searchChannel(payload: ChannelSearchPayload): Promise<ChannelInfoResponseContinuation<Video>>; | ||
|
||
static searchChannelMore(payload: ContinuationPayload): Promise<ChannelInfoResponseContinuation<Video>>; | ||
|
||
static getRelatedChannelsMore(payload: ContinuationPayload): Promise<ChannelInfoResponseContinuation<RelatedChannel>>; | ||
|
||
static getChannelCommunityPosts(payload: ChannelInfoPayload): Promise<ChannelCommunityPostsResponse> | ||
|
||
static getChannelCommunityPostsMore(payload: CommunityPostContinuationPayload): Promise<ChannelCommunityPostsContinuationResponse> | ||
|
||
static getChannelStats(payload: ChannelInfoPayload): Promise<ChannelStatsResponse> | ||
|
||
static getChannelHome(payload: ChannelInfoPayload): Promise<ChannelHomeResponse> | ||
} | ||
|
||
export = YoutubeGrabber; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters