'////////////////////////////////////////////////////////////////////////
'// EZTV SCRIPT FOR 9.4
'// WRITTEN BY: Chriso
'// Return the latest feeds from EZTV.it
'////////////////////////////////////////////////////////////////////////

'// Return Script Information
Sub Script(Name, Major, Minor, Build, Author, Commands, Description)
	Name = "EZTV Script"
	Major = 1
	Minor = 1
	Build = 0
	Author = "Chriso"
	Commands = "eztv"
	Description = "Return the latest feeds from EZTV.it"
End Sub

'// Called when the script is loaded for a particular bot
Sub Event_Load()
    CreateCommand "eztv", "EZTV", "Command_EZTV", "", "[limit]", "Return the latest feeds from EZTV.it", 1, True
End Sub

'// Callback for "test" Command
Sub Command_EZTV(CS)	
	Dim Total
	Total = 0
	If Len(CS.Message) Then Total = CInt(CS.Message)
	If Total = 0 Then Total = 999999
	
    If scInet.StillExecuting Then
		AddChat vbRed, "Still executing last request..."
    Else
		Dim XML, F, C
		C = 1
		XML = scInet.OpenURL("http://www.ezrss.it/feed/")
		F = InStr(XML, "<item>")
		AddChat &H808080, "-----------------------------------------------------------------------------"
		AddChat &H808080, "LATEST RSS FEEDS FROM EZTV"
		AddChat &H808080, "-----------------------------------------------------------------------------"
		
		Do Until F = 0 Or C > Total
			XML = Mid(XML, F + 6)
			C = C + 1
			Dim Feed, Title, Link, PubDate
			Feed = Split(XML, "</item>")(0)
			Title = Split(Feed, "<title>")(1)
			Title = Split(Title, "</title>")(0)
			Link = Split(Feed, "<link>")(1)
			Link = Split(Link, "</link>")(0)
			PubDate = Split(Feed, "<pubDate>")(1)
			PubDate = Split(PubDate, "</pubDate>")(0)
			
			AddChat &H00AB7424&, "<b>" & Title & "</b>"
			AddChat vbWhite, "- <b>Published: </b>" & PubDate
			AddChat vbWhite, "- <b>Download:</b> " & Link 
			AddChat vbWhite, ""
			
			F = InStr(XML, "<item>")
		Loop
	End If 
End Sub