Last active
August 29, 2015 14:05
-
-
Save magdiel01/5e2e10a6f7c6783bab3f to your computer and use it in GitHub Desktop.
This file contains 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
/*************************************************************************/ | |
/* Configuration parameters */ | |
var server = "Ftp.indielectro.net" // Ftp.indielectro.net | |
var userName = "indielectro.net" // indielectro.net | |
var password = "Penguin21" // Penguin21 | |
var localFile = "C:\\FtpUpload.html" // a temporary local file name | |
var remoteFile = "public/00/FtpUpload.html" // file name on the remote server | |
/*************************************************************************/ | |
var ftp; | |
var currentSong = ""; | |
var previousSong = ""; | |
var nextSong = ""; | |
var BLUE = 128*256*256; | |
var RED = 128; | |
// The Application::Startup event is fired on startup of Raduga | |
function Application::Startup() | |
{ | |
Application.Console.Visible = true; | |
DebugOutput( "FtpUpload started" ); | |
} | |
// The Application::Shutdown event is fired on shutdown of Raduga | |
function Application::Shutdown() | |
{ | |
if( ftp != null ) | |
ftp.Close(); | |
} | |
// The Player::Start event is fired by Raduga whenever a new track starts | |
function Player::Start() | |
{ | |
var playlist = Application.Playlist; | |
previousSong = currentSong; | |
currentSong = playlist.DisplayNameOf( Player.FileName ) | |
nextSong = playlist.DisplayNameOf( playlist.Item( playlist.NextIndex ) ) | |
WriteFile(); | |
UploadFile(); | |
} | |
function WriteFile() | |
{ | |
Application.Statusbar = "Writing file " + localFile; | |
DebugOutput( "Writing file " + localFile ); | |
var ForWriting = 2; | |
var FormatAscii = 0; | |
var fso = new ActiveXObject( "Scripting.FileSystemObject" ) | |
fso.CreateTextFile( localFile ); | |
var file = fso.GetFile( localFile ); | |
var ts = file.OpenAsTextStream( ForWriting, FormatAscii ); | |
ts.WriteLine( "<HTML><HEAD>" ); | |
ts.WriteLine( "<META HTTP-EQUIV=\"Refresh\" Content=\"10\">" ); | |
ts.WriteLine( "<TITLE>Indielectro</TITLE>" ); | |
ts.WriteLine( "<STYLE>TD { font-family: sans-serif }</STYLE>" ); | |
ts.WriteLine( "</HEAD>" ); | |
ts.WriteLine( "<BODY>" ); | |
ts.WriteLine( "<TABLE>" ); | |
ts.WriteLine( "<TR><TD>On Air : " + currentSong.toString().split('~')[0] + "</B></TD></TR>" ); | |
ts.WriteLine( "</TABLE>" ); | |
ts.WriteLine( "</BODY></HTML>" ); | |
ts.Close(); | |
Application.Statusbar = ""; | |
} | |
function UploadFile() | |
{ | |
Application.Statusbar = "Uploading file " + localFile + " to " + remoteFile; | |
try | |
{ | |
if( ftp == null ) | |
{ | |
ftp = new ActiveXObject( "Raduga.Ftp" ); | |
ftp.Server = server; | |
ftp.UserName = userName; | |
ftp.Password = password; | |
DebugOutput( "Connecting to FTP server " + ftp.Server ); | |
ftp.Open(); | |
} | |
DebugOutput( "Uploading file " + localFile + " to " + remoteFile ); | |
ftp.PutFile( localFile, remoteFile ); | |
} | |
catch( error ) | |
{ | |
HandleError( error ); | |
ftp = null; | |
} | |
Application.Statusbar = ""; | |
} | |
function HandleError( error ) | |
{ | |
Application.StatusBar = "FtpUpload Error: " + error.description; | |
Application.Console.WriteLineColor( error.description, RED ); | |
} | |
function DebugOutput( text ) | |
{ | |
Application.Console.WriteLineColor( text, BLUE ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment