diff --git a/YoutubeConfig.json b/YoutubeConfig.json index 108ce172dcf4183d7fadea947c619087ba636f21..7c5357c0f276c5ef287b67ade8e11c222552c8e5 100644 --- a/YoutubeConfig.json +++ b/YoutubeConfig.json @@ -7,7 +7,7 @@ "sourceUrl": "https://plugins.grayjay.app/Youtube/YoutubeConfig.json", "repositoryUrl": "https://futo.org", "scriptUrl": "./YoutubeScript.js", - "version": 156, + "version": 157, "iconUrl": "./youtube.png", "id": "35ae969a-a7db-11ed-afa1-0242ac120002", diff --git a/YoutubeScript.js b/YoutubeScript.js index b9a67c45eafc5ddd58dedc8a840265e27766ecda..6cfe98e5c6daf2a54f6375890eec0cc6bf2463d5 100644 --- a/YoutubeScript.js +++ b/YoutubeScript.js @@ -459,6 +459,44 @@ source.getContentDetails = (url, useAuth) => { }; source.getContentChapters = function(url, initialData) { //return []; + if(REGEX_VIDEO_URL_CLIP.test(url)) { + const videoPage = http.GET(url, getRequestHeaders({}), false); + + if(videoPage.isOk && throwIfCaptcha(videoPage)) { + const initialData = getInitialData(videoPage.body); + const playerData = getInitialPlayerData(videoPage.body); + + console.log("Clip data", playerData?.clipConfig); + const clipConfig = playerData?.clipConfig; + if(clipConfig?.endTimeMs && clipConfig?.startTimeMs) { + const startTime = parseInt(clipConfig.startTimeMs) / 1000; + const endTime = parseInt(clipConfig.endTimeMs) / 1000; + return [ + { + name: "Non-Clip", + timeStart: 0, + timeEnd: startTime, + type: Type.Chapter.SKIPPABLE + }, + { + name: "Clip", + timeStart: startTime, + timeEnd: endTime, + type: Type.Chapter.NORMAL + }, + { + name: "Non-Clip", + timeStart: endTime, + timeEnd: 99999999, + type: Type.Chapter.SKIPPABLE + }, + ]; + } + else + return []; + } + else return []; + } const videoId = extractVideoIDFromUrl(url);