Last active
July 4, 2024 22:19
-
-
Save FichteFoll/947f9ac40a74c5e8e3e8 to your computer and use it in GitHub Desktop.
Highlight all your twitch VoDs, automatically. READ INSTRUCTIONS
This file contains hidden or 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
/* For when you need to delete a range of videos or highlights. | |
* | |
* Use the first snippet once to show video indicies. Then use the second | |
* snippet and DON'T FORGET TO UPDATE THE RANGE INDICIES!!!!!!!!!!! | |
* | |
* The start index is inclusive, the end index is exclusive. Both may be | |
* negative numbers (going from behind). End index may be omitted. | |
* | |
* For other information, refer to `highlight_twitch_vods.js`'s comments. | |
* | |
* | |
* FichteFoll <[email protected]>, http://twitch.tv/fichtefoll | |
* | |
* Code under public domain. No warranty whatsoever; you have to clean | |
* up potential mess created by this script on your own. | |
*/ | |
// This shows the video's index below the thumbnail | |
(function ($) { | |
$(".video .thumb").each(function (i, elem) { | |
$(elem).html($(elem).html() + i); | |
}); | |
})(jQuery); | |
// This deletes the actual videos. Get index numbers from script above | |
(function ($) { | |
var $buttons = $(".actions .dropmenu .dropmenu_action"); | |
function delete_video(i, maxi) { | |
var btn = $buttons.get(i); | |
if (!btn || (maxi && btn == $buttons.get(maxi))) | |
return; | |
// trigger modal popup | |
btn.click(); | |
setTimeout( | |
function () { | |
$(".modal-form .primary").click(); | |
// recursive | |
setTimeout( | |
function () { | |
delete_video(i + 1, maxi); | |
}, 2000 | |
); | |
}, 500 | |
); | |
} | |
// SET RANGE HERE (end exclusive) | |
delete_video(83, -2); | |
})(jQuery); |
This file contains hidden or 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
/* Instructions - MUST READ | |
* | |
* Tested and developed with FireFox and FireBug console (no guarantees for other setups)! | |
* | |
* 1. Open your "Video Manager" on twitch.tv (the new one) http://twitch.tv/fichtefoll/manager. | |
* 2. All VoDs must be visible. For this, scroll down until no more videos are | |
* loaded. It is recommended to mute the twitch player. | |
* 3. Open FireBug (F12) | |
* 4. Enable popups for twitch.tv. | |
* For this, just run "window.open()" in the FireBug console and accept. | |
* 5. Paste this entire script into the console. Then run it. | |
* | |
* FireFox will create a lot of tabs (if you set "open in new tab instead of | |
* window", which I recommend) in the process, which makes it unusable during | |
* the time. However, you are free to minimize it and check back after a few | |
* minutes, depending on how many VoDs you have. | |
* | |
* When finished, you can check the console for some (potentially wrong) debug | |
* output. | |
* | |
* NOTE: It's possible that some videos are not highlighted on first instance. | |
* The console output here is NOT RELIABLE! You will probably have to run the | |
* script a second time, and eventually delete duplicates because the | |
* automatic detection does NOT work 100%, only like 40%. | |
* | |
* You can use this to get the number of total "past broadcasts" or | |
* "highlights", assuming all are visible: | |
* | |
* $(".actions .action-menu-list li:nth-of-type(1) a").length | |
* | |
* | |
* FichteFoll <[email protected]>, http://twitch.tv/fichtefoll | |
* | |
* Code under public domain. No warranty whatsoever; you have to clean | |
* up potential mess created by this script on your own. | |
*/ | |
(function ($) { | |
// This will be used if no description was set for the VoD | |
var DEFAULT_DESCR = "No description set"; | |
// If true, no highlights will be created for videos that already have a highlight created from them. | |
// | |
// If you happen to have created highlights before but still want to highlight the entire VoD, | |
// I recommend you to check the console for the VoD's name and do it manually instead. | |
// For any non-first run, you SHOULD enable this. | |
var CHECK_PREV_HLS = false; | |
// counters | |
var success = 0, | |
counter = 0; | |
//////////////////////////////////////////////////////////////////////////// | |
// utils | |
function time_formatted(s) { | |
return (new Date()) | |
.clearTime() | |
.addSeconds(s) | |
.toString('HH:mm:ss'); | |
} | |
function time_seconds(str) { | |
var p = str.split(':'), | |
s = 0, m = 1; | |
while (p.length > 0) { | |
s += m * parseInt(p.pop(), 10); | |
m *= 60; | |
} | |
return s; | |
} | |
//////////////////////////////////////////////////////////////////////////// | |
// get hl links | |
var $buttons = $(".actions .action-menu-list li:nth-of-type(1) a"); | |
function highlight_video (i) { | |
var a = $buttons.get(i); | |
if (a === undefined) | |
return; | |
// get title | |
var $a_title = $(a).parents(".meta").find(".title a"); | |
var title = $.trim($a_title.text()); | |
console.log("checking: " + title); | |
console.log(++counter); | |
// open the highlight edit page | |
var w = window.open(a.href); | |
w.onload = function () { | |
var $ = w.jQuery; | |
$(function () { | |
// TODO maybe check highlights for same title as VoD (also unreliable) | |
var old_hls = $(".created-highlights .highlights .video.item").length; | |
if (CHECK_PREV_HLS && old_hls) { | |
console.log("Found " + old_hls + " highlights created from this video. Skipping..."); | |
w.close(); | |
return highlight_video(i - 1); | |
} | |
var $form = $(".highlight-form"); | |
// Set highlight times | |
var fake_dur = $.trim($form.find(".duration").text()); | |
// we need to trigger changed() because twitch seems to read | |
// values from the sliders before submitting | |
$form.find(".start-time").val("0:00").change(); | |
// calculate the video's actual length | |
fake_dur = time_seconds(fake_dur); // this is 70% of the original length | |
var dur = Math.round(fake_dur / 0.7); | |
$form.find(".end-time").val(time_formatted(dur)).change(); | |
// set title | |
$form.find('input[name="title"]').val(title); | |
//get description (need to load page for that) | |
var w_descr = window.open($a_title.attr("href")); | |
w_descr.onload = function () { | |
var descr = w_descr.ChannelInfo.broadcast.description || ""; | |
if (!descr) | |
console.log("No description found."); | |
w_descr.close(); | |
// set description | |
$form.find('textarea[name="description"]').val(descr || DEFAULT_DESCR); | |
// submit | |
$form.find("fieldset:nth-of-type(2) .primary").click(); | |
setTimeout(function () { | |
// for some reason this rarely works | |
if ($.trim($(".form-container h4").text()) != "Highlight Created!") { | |
console.log("Highlighting failed!"); | |
} else { | |
success++; | |
} | |
w.close(); | |
highlight_video(i - 1); | |
}, 2000); | |
// that's an arbitrary timeout, but it shouldn't take this long to submit ~500 bytes | |
}; | |
}); | |
}; | |
} | |
// Iterate buttons backwards | |
highlight_video(-1); | |
}) | |
(jQuery); |
I have no interest in working on this 10-year-old script that I don't even know whether it still works, no.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could you upgrade the auto highlight script to add descriptions with the meta data of the original vod, like:
origianlstream:
stream title
stream description
June 30, 2024 hh:mm CEST (vod date and time )
2:24:53 (vod length)
5 views
Past Broadcast (vod type)
https://www.twitch.tv/videos/218550xyza (url to original vod)
thanks in advance