Source: site.view [edit]
Function name: play
Arguments: music
Description: A command to play some music -> input may be song name or artist, but must be in lowercase Requires tLID 0-1-7 -> Example input: music='ray charles'
Page type: webl
Render function:   tlidRender
Module: global

Page source:

var P;
var tmp1;
var context;

context = NLUtil_InitContext();

//|| go to http://radioblogclub.com/
context = NLUtil_GetUrl(context, "http://radioblogclub.com/", nil, nil);
P = NLUtil_GetContext(context, `P`);

//|| find all forms
P = NLUtil_GetContext(context,`P`);
context = NLUtil_SetContext(context,`form`, Elem(P, `form`) );

//|| select the first one
context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1));

//|| field action is "http://radioblogclub.com/search/0/" + the music
context = NLUtil_SetField(context, "action", `http://radioblogclub.com/search/0/` + music);

//|| submit the form
context = NLUtil_submitForm(context);
P = NLUtil_GetContext(context, `P`);

//|| find all links that contain the music
P = NLUtil_GetContext(context,`P`);
context = NLUtil_SetContext(context,`a`, Elem(P, `a`)  contain Pat(P, `(?i)` + music));

//|| select the first one
context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1));

//|| click it
context = NLUtil_clickLink(context);
P = NLUtil_GetContext(context, `P`);

context = NLUtil_SetContext(context, `P`, P);

if Size(OPTIONALARGS) == 0 then
   NLUtil_LastSet(context);
else
   context;
end;