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

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 "<div style=""left: 500px; top: 50px;"">"
    html "<object width=""425"" height=""355"">"
    html "<param name=""movie"" value=""http://www.youtube.com/v/" + key$ + """></param>"
    html "<param name=""wmode"" value=""transparent""></param>"
    html "<embed src=""http://www.youtube.com/v/" + key$ + """ type=""application/x-shockwave-flash"" "
    html "wmode=""transparent"" width=""425"" height=""355""></embed>"
    html "</object>"
    html "</div>"
  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