I hope someone who knows JavaScript could help me fix this script. It's for a chat server called sb0t which uses plugin scripts. Unfortunately this youtube script which prints the title of a video link when pasted in the chat, stopped working a while ago because it used a link "http://api.meow.tf" to retrieve the title, and this no longer exists.
I found a tutorial on using the Youtube API here, so you need a "key" to do this: https://medium.com/analytics-vidhya...itles-using-the-youtube-data-api-45d3f4998486
But I also found something interesting, a command-line downloader that can retrieve all sorts of things: https://stackoverflow.com/questions...-music-in-this-video-info-from-video-metadata This says it uses Python and shows how to retrieve title info, but I doubt this would be useful for this purpose.
Since I don't know Java, I really have no clue how complex it might be to get this script to function again, but maybe it's pretty simple?
Thanks!
I found a tutorial on using the Youtube API here, so you need a "key" to do this: https://medium.com/analytics-vidhya...itles-using-the-youtube-data-api-45d3f4998486
But I also found something interesting, a command-line downloader that can retrieve all sorts of things: https://stackoverflow.com/questions...-music-in-this-video-info-from-video-metadata This says it uses Python and shows how to retrieve title info, but I doubt this would be useful for this purpose.
Since I don't know Java, I really have no clue how complex it might be to get this script to function again, but maybe it's pretty simple?
Thanks!
JavaScript:
print("youtube decoder v1.2 - by oobe");
var can_use = false;
String.prototype.startsWith = function (str)
{
if (this.length < str.length)
return false;
return this.substr(0, str.length) == str;
}
function onLoad()
{
if (Room.version != null)
if (Room.version >= 2016)
can_use = true;
if (!can_use)
print("please update your Callisto if you want to use youtube script");
}
function onTextAfter(userobj, text)
{
if (!can_use)
return;
var words = text.split(" ");
for (var i = 0; i < words.length; i++)
{
if (words[i].indexOf("youtube.com/watch?v=") > -1)
{
var splitter = words[i].split("?v=");
if (splitter.length == 2)
{
var http = new HttpRequest();
http.utf = true;
http.src = "http://api.meow.tf/youtube/info/" + splitter[1].split("&")[0];
http.oncomplete = onHttp;
http.download(splitter[1].split("&")[0]);
break;
}
}
else if (words[i].indexOf("youtu.be/") > -1)
{
var splitter = words[i].split("be/");
if (splitter.length == 2)
{
var http = new HttpRequest();
http.utf = true;
http.src = "http://api.meow.tf/youtube/info/" + splitter[1].split("&")[0];
http.oncomplete = onHttp;
http.download(splitter[1].split("&")[0]);
break;
}
}
}
}
function onHttp(e)
{
if (e)
{
var obj = JSON.parse(this.page);
if(obj.snippet) {
print("\x0314Youtube: " + obj.snippet.title + " - [" + parseISO8601Duration(obj.contentDetails.duration) + "]");
}
}
}
function parseISO8601Duration(DurationString) {
var matches = DurationString.match(/^P([0-9]+Y|)?([0-9]+M|)?([0-9]+D|)?T?([0-9]+H|)?([0-9]+M|)?([0-9]+S|)?$/),
result = {};
if (matches) {
var year = parseInt(matches[1]);
var month = parseInt(matches[2]);
var day = parseInt(matches[3]);
var hour = parseInt(matches[4]);
var minute = parseInt(matches[5]);
var second = parseInt(matches[6]);
var string = '';
if (year) string += year + ' Year' + (year == 1 ? '' : 's') + ' ';
if (month) string += month + ' Month' + (month == 1 ? '' : 's') + ' ';
if (day) string += day + ' Day' + (day == 1 ? '' : 's') + ' ';
if (hour) string += hour + ' Hour' + (hour == 1 ? '' : 's') + ' ';
string += (minute ? (minute < 10 ? '0' : '') + minute : '00') + ':';
string += (second ? (second < 10 ? '0' : '') + second : '00');
return string.replace(/\s+$/, '');
}
return "";
}
function videoLength(t)
{
var tmp = parseInt(parseFloat(t));
var mins = Math.floor(tmp / 60);
var secs = tmp - (mins * 60);
return mins + ":" + (secs < 10 ? ("0" + secs) : secs);
}