YouTube

A program for viewing videos on the "Recently Added" RSS feed at YouTube. (Inspired by Media player demo.)

code format="vb" global url$, rss$

url$ = "http://youtube.com/rss/global/recently_added.rss" rss$ = ""

Call RefreshList

' Displays the YouTube video Sub ShowTube cls

if key$ <> "" then html " " html "" html " " html " " html " " html " " html " " end if

Call MakeList rss$

wait End Sub

sub MakeList rss$ xmlparser #rss, rss$

#channel = #rss #element(1) rsslen = #channel elementCount

' Loads everything into the two arrays for x = 1 to rsslen

#item = #channel #element(x)

if (#item key$ = "item") then

#link = #item #element(3) vid$ = GetVal$(#link value$,"v")

#title = #item #element(2) title$ = #title value$

link #choose, title$, ShowTube #choose setkey(vid$) print ""

end if next x

print "" link #refresh, "Refresh List", RefreshList end sub

Sub RefreshList rss$ = FetchRss$(url$)

Call ShowTube End Sub

' Fetches the url function FetchRss$(url$) rss$ = ""

rss$ = httpget$(url$)

if rss$ = "" then rss$ = FetchRss$(url$) end if

FetchRss$ = rss$ end function

' Grabs a value from the url function GetVal$(string$, key$) value$ = "" key$ = key$ + "=" startit = instr(string$, key$)

if startit > 0 then startit = startit + len(key$)

endit = instr(string$, "&", startit)

if endit > 0 then endit = endit - startit value$ = mid$(string$, startit, endit) else value$ = mid$(string$, startit, len(string$)) end if end if

GetVal$ = value$ end function code