-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: Add initial support for YouTube clip links #9532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from 4 commits
36f7eaf
091e8bd
9f06cb5
a92ee52
9675e80
755a46d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { ClientType, Constants, Innertube, Misc, Mixins, Parser, Platform, Player, Session, UniversalCache, Utils, YT, YTNodes } from 'youtubei.js' | ||
| import { ClipParams } from '../../../../node_modules/youtubei.js/dist/protos/generated/misc/params' | ||
| import Autolinker from 'autolinker' | ||
| import { parseLooseJSON } from 'bgutils-js/utils' | ||
|
|
||
|
|
@@ -2486,3 +2487,21 @@ export async function getLocalCommunityPostComments(postId, channelId) { | |
|
|
||
| return await innertube.getPostComments(postId, channelId) | ||
| } | ||
|
|
||
| export async function getLocalClip(clipId) { | ||
| const innertube = await createInnertube() | ||
|
|
||
| const clipResponse = await innertube.resolveURL('https://www.youtube.com/clip/' + clipId) | ||
|
|
||
| const videoId = clipResponse?.payload?.videoId | ||
|
|
||
| const parsedParams = ClipParams.decode(Utils.base64ToU8(decodeURIComponent(clipResponse.payload.params))) | ||
|
|
||
| return { | ||
| videoId, | ||
| startTime: parsedParams.clipParamData.startTime / 1000, // convert to seconds | ||
| endTime: parsedParams.clipParamData.endTime / 1000, // convert to seconds | ||
| clipTitle: parsedParams.clipParamData.clipTitle, | ||
| clipMetadata: parsedParams.clipParamData.clipMetadata | ||
| } | ||
|
Comment on lines
+2498
to
+2506
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this section of the code is the same for the local and Invidious APIs apart from where the video ID and params string is read from, could you please extract it into a shared function that takes the video ID and params text as the input, decodes it and returns the object. |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.