Version 0.9.0.0

Aliases

_guc() = GetURLCached()
_gu() = GetURL()
_gur() = GetURLxR()
_gux() = GetURLX()
_guxr() = GetURLXxR()
_sr() = str_replace()
_sp() = str_split()
_sf() = str_find()
_sfl() = str_findlast()
_se() = str_escape()
_su() = str_unescape()
_she() = str_html_encode()
_shd() = str_html_decode()
_sst() = str_strip_tags()
_sgb() = str_get_between()
_sgba() = str_get_between_a()
_st() = str_trim()
_vr() = VideoResource()
_vrx() = VideoResourceX()
_ar() = AudioResource()
_ir() = ImageResource()
_ct() = ConvertTime()
_vf() = VirtualFolder()
_dvf() = DynamicVirtualFolder()
_rx() = ResolveXML()
_srx() = SpecialResolveXML()
_v() = Version()
_l() = Log()
_dl() = DebuggerLog()
_sm() = ShowMsg()

Functions

GetURL
GetURLxR
GetURLX
GetURLXxR
GetLastHeader
GetURLCached
ImageResource
AudioResource
VideoResource
VideoResourceX
GetVideoPerformanceLevel
FormatRTMP
ResolveXML
SpecialResolveXML
VirtualFolder
DynamicVirtualFolder
RestartServer
VideoRestartServer
ConvertTime
SetTimeOut
str_replace
str_split
str_get_between
str_find
str_findlast
str_escape
str_unescape
str_html_encode
str_html_decode
str_strip_tags
str_trim
SaveFile
OpenFile
FileExists
DownloadAndSaveFile
GetCurrentPath
GetDirListing
GetDirListTable
GetFileInfo
ExecuteFile
GetTime
RunScript
LoadScript
LoadNetLib
ShowMsg
Log
DebuggerLog
Version
GetStringFromAMF
GetScriptOption
GetScriptOptionX
SetScriptOption
SetScriptOptionX
isnumeric

string GetURL(string url);
returns the contents of the url
local s=GetURL("http://www.google.com/search?q=hello+world");

string GetURLxR(string url);
returns the contents of the URL, without automatically following any redirect commands supplied by the server
local s=GetURLxR("http://www.google.com/search?q=hello+world");

string GetURLX(string url, string postData, string method, string referer, string userAgent, string contentType, int contentLength, string accept, string headersParse);
returns the contents of the URL
local s=GetURLX("http://www.google.com/","search?q=hello+world","POST","","Mozilla 4.0 etc","32","","Accept-Languageen-US,en;q=0.8");

string GetURLXxR(string url, string postData, string method, string referer, string userAgent, string contentType, int contentLength, string accept, string headersParse);
returns the contents of the URL, without automatically following any redirect commands supplied by the server
local s=GetURLXxR("http://www.google.com/","search?q=hello+world","POST","","Mozilla 4.0 etc","32","","Accept-Languageen-US,en;q=0.8");

string GetLastHeader();
returns the last complete header received after calling GetURL or GetURLX
local s=GetLastHeader();

string GetURLCached(string url, int lengthInMinutes);
returns the contents of the url, if not cached. If it is cached it will serve only that cache file until lengthInMinutes is met
local s=GetURLCached("http://www.google.com/search?q=hello+world");

nil ImageResource(string title, string url, string description, string thumbnail); not fully supported
sends a image "link" to the media device
ImageResource("Image Name", "http://www.url.com/image.jpg", "Image Description", "http://www.url.com/thumbnail.jpg");

nil AudioResource(string title, string url, string description, string thumbnail, int duration); not fully supported
sends a audio "link" to the media device
AudioResource("Audio Name", "http://www.url.com/audio.mp3", "Audio Description", "http://www.url.com/audio.mp3", 10000);

nil VideoResource(string title, string url, string description, string thumbnail, int duration)
sends a video "link" to the media device
VideoResource("Video", "http://www.url.com/video.mp4", "Video Description", "http://www.url.com/video.jpg", 10000);
--the URL field can also accept code:
VideoResource("Video", "func:nameOfFunction", "Video Description", "http://www.url.com/video.jpg", 10000);
VideoResource("Video", "code:_SPECIAL_resolve_xml=ResolveXML('http://www.url.com/video.mp4');", "Video Description", "http://www.url.com/video.jpg", 10000);
VideoResource("Video", "exec:Script Name.lua", "Video Description", "http://www.url.com/video.jpg", 10000);
--to include the date of a video, add the special XML to the description
VideoResource("Video", "http://www.url.com/video.mp4", 'Video Description<special date=\"1.0\"><year>2009</year><month>11</month><day>23</day></special>', "http://www.url.com/video.jpg", 10000);

nil VideoResourceX(table date)
sends a video "link" to the media device
local vrTable = {
               title = "Tile of Video",
               path = "URL, Local Path, or code",
               description = "Video Description",
               thumbnail = "URL to image",
               date = "11/22/2009 12:33:00 PM",
               duration = ConvertTime("1:00:00"),
               bitrate = 0,
               resolution = "1920x1080",
               genre = "Funny",
               rating = "G",
               index = 1;
}
VideoResourceX(vrTable);
--the path field can also accept code, same as VideoResource.

int GetVideoPerformanceLevel();
returns the users Video Performance preference from the PlayOn Settings window
local max_performance = 2147483647;
local high_performance = 1600;
local medium_performance = 1000;
local low_performance = 500;
if GetVideoPerformanceLevel() == max_performance then
	ShowMsg("You have Max selected");
else if GetVideoPerformanceLevel() == high_performance then
	ShowMsg("You have high selected");
else if GetVideoPerformanceLevel() == medium_performance then
	ShowMsg("You have Medium selected");
else if GetVideoPerformanceLevel() == low_performance then
	ShowMsg("You have Low selected");
end;

string FormatRTMP(string app, string super, string mediaPath, string swfUrl, string pageUrl, string extra)
returns a formated XML string that can be sent as a RTMP handshake
local url = "streaming.video.themis-media.com/ondemand/"
local path = "mp4:mp4/escapist/unforgotten-realms/966-c02ecfcfa2f4008b262620469b1a10e0.mp4"
local purl = "http://theescapist.com/"
local swf = "http://cdn2.themis-media.com/media/global/movies/player/LiveRailPlugin315.swf"

local rtmpString = FormatRTMP(url, 1, path, swf, purl, nil);

VideoResource("Test", rtmpString, "Description", "http://www.url.com/thumbnail.jpg", 100000);

string ResolveXML(string url)
returns a formated XML string that can be set to _SPECIAL_resolve_xml which then will be passed to PlayOn
VideoResource("Test", "code:_SPECIAL_resolve_xml=ResolveXML('http://www.url.com/video.mp4');", "Description", "http://www.url.com/thumbnail.jpg", 100000);

nil SpecialResolveXML(string url)
combines _SPECIAL_resolve_xml and ResolveXML into one function which then will be passed to PlayOn
VideoResource("Test", "code:SpecialResolveXML('http://www.url.com/video.mp4');", "Description", "http://www.url.com/thumbnail.jpg", 100000);

nil VirtualFolder(string folderName, string folderAlias);
creates a folder in the media device called folderName, folderAlias must be set as the function to be called when folder is clicked
VirtualFolder("Test Folder", "testFolderClicked");
function testFolderClicked()
     --do something here
end

nil DynamicVirtualFolder(string folderName, string folderAlias);
works the same as VirtualFolder() only attempts to refresh the folder's contents
DynamicVirtualFolder("Test Folder", "testFolderClicked");
function testFolderClicked()
      do something here
end;

nil RestartServer();
immediatly restarts the playon server
VirtualFolder("Restart Server", "code:RestartServer()");

nil VideoRestartServer();
plays a custom video, and restarts the playon server after a short delay
VideoRestartServer();

int ConvertTime(string time);
converts a simple time stamp into milli-seconds
ConvertTime("16:39");

nil SetTimeOut(string functionToBeCalled, int intervalMilliSeconds);
waits until the interval has passed and then attempts to execute the function
functionToBeCalled works the same as VirtualFolder's folderAlias

function myfuncName()
     --do something
end;

SetTimeOut("myfuncName", 1000);

string str_replace(string subject, string find, string replace);
replaces one part of a string with another string
local s = str_replace("Hello world!", "world", "Friend");

string str_split(string subject, string delimeter);
returns an array of strings divided by delimeter
local arr = str_split("Hello World", " ");
Log(arr[1]); --prints Hello

string str_get_between(string subject, string findFirst, string findSecond, int start);
returnsn the string found between the first and second string, starting from start
local data = "<item>DATA</item>"
local str = str_get_between(data, "<item>", "</item>", 0);
string str_get_between_a(string subject, string findFirst, string findSecond, int start);
returns a array containing the string found between the first and second strings, starting from start, and the position of the first and second strings
local data = "<item>DATA</item>"
local tbl = str_get_between_a(data, "<item>", "</item>", 0);

string str_find(string subject, string find, int start);
returns the position one string inside another, starting from start
local a = str_find("hello", "ll", 0);

string str_findlast(string subject, string find, int start);
returns the last position one string inside another, searching backwards from start
local a = str_findlast("hello", "ll", 0);

string str_escape(string subject)
returns an url escaped string
local s = str_escape("test/this/"); --returns test%2fthis%2f

string str_unescape(string subject)
returns an url escaped string
local s =str_unescape("test%2fthis%2f"); --returns test/this/

string str_html_encode(string subject)
returns a string with html entities encoded
local s =str_html_encode("test&this"); --returns test&this

string str_html_decode(string subject)
returns a string with html entities decoded
local s =str_html_decode("test&amp;this"); --returns test&this

string str_strip_tags(string subject, string openTag, string closeTag);
returns a string without the supplied tags
local s =str_strip_tags("html is &lt;b&gt;cool", "<", ">"); --returns html is cool

string str_trim(string subject);
trims off leading and trailing spaces
local s =str_trim("    hello    "); --returns "hello"

string SaveFile(string path, string contents);
saves a file on the hard drive
local b = SaveFile("c:\\test.txt", "Hello World");
if b=="<error>" then Log("Could not save file"); end;

string OpenFile(string path);
open a file located on the hard drive
local s = OpenFile("c:\\test.txt");
if s=="<error>" then Log("Could not open file"); end;

string FileExists(string path);
check if a file exists on the local machine
local b = FileExist("c:\\test.txt");
if not b then Log("File does not exist"); end;

string DownloadAndSaveFile(string url, string filePath);
downloads the file at url and saves it to filePath
local b = DownloadAndSaveFile("http://www.url.com/image.jpg", "c:\\image.jpg");
if not b then Log("Could not download file"); end;

string GetCurrentPath();
returns the current path on the local machine when playon is installed
local path = GetCurrentPath();

string GetDirListing(string path); deprecated
returns parsable list of files in a dir
local s = GetDirListing("C:\\");

table GetDirListTable(string path);
returns a table of files in a directory
local tbl = GetDirListtable("C:\\");

table GetFileInfo(string filePath);
returns a table with information about a file
local arr = GetFileInfo("C:\\test.txt");
Log(arr["Length"]); --get the size of the file.
Log(arr["CreationTime"]);
Log(arr["CreationTimeUTC"]);
Log(arr["Directory"]);
Log(arr["DirectoryName"]);
Log(arr["Exists"]);
Log(arr["Extension"]);
Log(arr["FullName"]);
Log(arr["LastAccessTime"]);
Log(arr["LastAccessTimeUtc"]);
Log(arr["LastWriteTime"]);
Log(arr["LastWriteTimeUtc"]);
Log(arr["Length"]);
Log(arr["Name"]);

nil ExecuteFile(string filePath);
executes a local file, launching it's default application, can also open web pages.
ExecuteFile("http://www.google.com");

string GetTime(string type);
returns the types of time
local time = GetTime("utc"); --unix like time
local timeNow = GetTime("now"); --normal time
local timeHour = GetTime("hour");
local timeMinute = GetTime("minute");
local timeSecond = GetTime("second");
local timeDay = GetTime("day");
local timeMonth = GetTime("month");
local timeYear = GetTime("year");
--new in 0.6.0.0
local customDate = GetTime("month / day / year"); --will return: 11 / 10 / 2009

nil RunScript(string luaCode);
Executes the Lua formatted code in luaCode.
RunScript("local a = 1; Log(a+1);");

nil LoadScript(string luaFile);
Executes the Lua script file found in luaFile.
LoadScript("C:\\test.lua");

string LoadNetLib(string libName);
downloads and executes an external library
local success=LoadNetLib("http://www.myurl.com/lib.LibraryName.lua");
if not success then Log("Could not load Net Library"); end;

nil ShowMsg(string message);
Displays a VirtualFolder titled string, minus the code call.
ShowMsg("Clicking this will do nothing");

nil Log(string message);
writes to the text based log of the plugin
Log("This is a test for the log.");

nil DebuggerLog(string message);
opens the console debug notifier, if present, and displays the contents of message
DebuggerLog("This is a test for the debug notifier.");

int Version();
returns the current version of the Lua Scripts Plugin
if Version() < 500 then
     VirtualFolder("Please update your Lua Scripts Plugin");
     return;
end;

string GetStringFromAMF(string url, int totalChars);
returns a AMF string that can be evaluated
--url is the amf location and any qs arguments
--totalChars is how many we want to process in the request, we may not need the whole thing

string GetScriptOption(string optionName);
returns the of value the option name stored in Scripts Plugin.ini
local s=GetScriptOption("Name");
ShowMsg("Hi, "..s);

string GetScriptOptionX(string section, string optionName);
returns the of value the option name stored in Scripts Plugin.ini
local s=GetScriptOptionX("Test", "Name");
ShowMsg("Hi, "..s);

nil SetScriptOption(string optionName, string optionValue);
sets the value of the option name stored in Scripts Plugin.ini
SetScriptOption("Name", "Mayor McCheese");
local s=GetScriptOption("Name");
ShowMsg("Hi, "..s);

nil SetScriptOptionX(string section, string optionName, string optionValue);
sets the value of the option name stored in Scripts Plugin.ini
SetScriptOptionX("Test", "Name", "Mayor McCheese");
local s=GetScriptOptionX("Test", "Name");
ShowMsg("Hi, "..s);

bool isnumeric(string possibleNumber);
returns "true" if the supplied string is a number, returns nil if not
local s = "22";
if isnumber(s) then
	Log(s.." is a number");
end;