From 8ac3dfdb0fbc23783ca19cf479c642e6c80139b3 Mon Sep 17 00:00:00 2001
From: Kelvin <kelvin@revodux.com>
Date: Mon, 9 Oct 2023 12:42:21 +0200
Subject: [PATCH] WIP chapters and test cipher

---
 YoutubeScript.js | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/YoutubeScript.js b/YoutubeScript.js
index 0c43e9f..200dd58 100644
--- a/YoutubeScript.js
+++ b/YoutubeScript.js
@@ -418,15 +418,30 @@ source.getContentDetails = (url, useAuth) => {
 	}
 
 	const finalResult = videoDetails;
+	finalResult.__initialData = initialData;
 	if(!!_settings["youtubeActivity"] && useLogin) {
 		finalResult.__playerData = initialPlayerData;
 		finalResult.getPlaybackTracker = function(url) {
 			return source.getPlaybackTracker(url, initialPlayerData)
 		};
 	}
+	finalResult.getContentChapters = function() {
+		source.getContentChapters(url, finalResult.__initialData);
+	};
 
 	return finalResult;
 };
+source.getContentChapters = function(url, initialData) {
+	if(initialData == null) {
+		const html = requestPage(url);
+		initialData = getInitialData(html);
+	}
+	const rawObjects = initialData?.playerOverlays?.playerOverlayRenderer?.decoratedPlayerBarRenderer?.playerBar?.multiMarkersPlayerBarRenderer?.markersMap;
+	if(!rawObjects || rawObjects.length == 0)
+		return null;
+	
+}
+
 source.getLiveChatWindow = function(url) {
 	const id = extractVideoIDFromUrl(url);
 	if(!id)
@@ -3410,6 +3425,24 @@ function decryptN(encryptedN, jsUrl) {
 		throw new ScriptException("N Decryptor was not available [" + jsUrl + "]");
 	return _nDecrypt[jsUrl](encryptedN);
 }
+function testCipher(hash) {
+	const jsUrl = CIPHER_TEST_PREFIX + hash + CIPHER_TEST_SUFFIX;
+	try{
+		const result = prepareCipher(jsUrl);
+		clearCipher(jsUrl);
+		return {
+			success: result,
+			exception: ""
+		};
+	}
+	catch(ex) {
+		return {
+			success: false,
+			exception: ex
+		};
+	}
+}
+source.testCipher = testCipher;
 function testCiphers() {
 	let testResults = [];
 	for(hash of CIPHER_TEST_HASHES) {
-- 
GitLab