footube—finds YouTube videos via fb2k, also integrates w/WSH Panel Mod
Reply #5 –
2012-02-16
NEW script for footube
I wonder when i listen to net-radio and music changed, on_playback_new_track is not called.
so using regexp, if RAW PATH include "http://",make timer and check if music has changed.
and other changes in detail.
learn detail
var WshShell = new ActiveXObject("WScript.Shell");
var exe = "footube.exe";
var delay = 3000;
var oExec = WshShell.Exec(exe+" "+window.ID+" "+delay);
var timer = window.CreateTimerInterval(delay+3000);
var stat = true;
var pipe = false;
var net_radio = false;
var net_radio_tit = "";
var cmd2pipe = "";
var mes_templ = "###############################\n";
mes_templ += "Message From fooTubeScript Host\n";
mes_templ += "###############################\n";
var bar_templ = "-------------------------------\n";
//---------------------------------------------------
function sendMes2pipe(cmd2pipe)
{
try
{
oExec.StdIn.WriteLine(cmd2pipe);
}
catch(e)
{
fb.trace(mes_templ+"pipe had been closed");
killAll();
}
}
function killAll()
{
stat = false;
pipe = false;
net_radio = false;
window.KillTimer(timer);
}
function checkBeforSend()
{
if (stat && pipe)
{
window.KillTimer(timer);
sendMes2pipe(fb.TitleFormat("%title%").Eval(true));
var url = new RegExp("http://", "i");
if(fb.TitleFormat("%_path_raw%").Eval(true).match(url))
{
net_radio = true;
net_radio_tit = fb.TitleFormat("%title%").Eval(true);
timer = window.CreateTimerInterval(6000);
}
else
{
net_radio = false;
}
}
}
//---------------------------------------------------
function on_playback_new_track(metadb){
checkBeforSend();
}
function on_timer(timer_id){
if (net_radio)
{
if (net_radio_tit != fb.TitleFormat("%title%").Eval(true))
{
net_radio_tit = fb.TitleFormat("%title%").Eval(true);
sendMes2pipe(net_radio_tit);
}
}
else if (stat && pipe == false)
{
window.KillTimer(timer);
var dt = new Date();
var start = dt.getMilliseconds();
fb.trace(mes_templ+"initialization pipe conection...");
dt = new Date();
fb.trace("Send SYN to footube.exe");
oExec.StdIn.WriteLine("SYN");
if(oExec.StdOut.ReadLine() == "SYN")
{
fb.trace("Recieve SYN from footube.exe\nSend ACK to footube.exe");
oExec.StdIn.WriteLine("ACK");
fb.trace("Recive TEST Message from footube.exe");
pipe = true;
fb.trace("\""+oExec.StdOut.ReadLine()+"\"");
var dt = new Date();
var end = dt.getMilliseconds();
if ((end - start) <= 0)
{
fb.trace((end+1000-start)+"ms took to pipe conection establishment\n"+bar_templ);
}
else
{
fb.trace((end-start)+"ms took to pipe conection establishment\n"+bar_templ);
}
checkBeforSend();
}
else
{
fb.trace("Error : Cannot Recieve SYN from footube.exe\n"+bar_templ);
killAll();
}
}
}
and I am a student so there are many other things to do.
so I make footube open sourced.please modify it by yourself
footube version3.6 with c# code