/Scraper dll sources/TVDB/TVDB/TVDB.vb
Visual Basic | 430 lines | 387 code | 32 blank | 11 comment | 0 complexity | e1282fbec01458c12806dd6f6a3ac1e5 MD5 | raw file
Possible License(s): GPL-2.0
- Imports System.IO
- Imports System.Net
- Imports System.Threading
- Imports System.Xml
-
- Public Class tvdbscraper
- Private Structure possibleshowlist
- Dim showtitle As String
- Dim showid As String
- Dim showbanner As String
- End Structure
-
- Public Function getposterlist(ByVal tvdbid As String)
- Monitor.Enter(Me)
- Try
- Dim mirrors As New List(Of String)
- Dim xmlfile As String
- Dim wrGETURL As WebRequest
- Dim mirrorsurl As String = "http://www.thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/banners.xml"
- wrGETURL = WebRequest.Create(mirrorsurl)
- Dim myProxy As New WebProxy("myproxy", 80)
- myProxy.BypassProxyOnLocal = True
- Dim objStream As Stream
- objStream = wrGETURL.GetResponse.GetResponseStream()
- Dim objReader As New StreamReader(objStream)
- xmlfile = objReader.ReadToEnd
- Dim bannerslist As New XmlDocument
- 'Try
- Dim bannerlist As String = "<banners>"
- bannerslist.LoadXml(xmlfile)
- Dim thisresult As XmlNode = Nothing
- For Each thisresult In bannerslist("Banners")
-
- Select Case thisresult.Name
- Case "Banner"
- bannerlist = bannerlist & "<banner>"
- Dim bannerselection As XmlNode = Nothing
- For Each bannerselection In thisresult.ChildNodes
- Select Case bannerselection.Name
- Case "BannerPath"
-
- bannerlist = bannerlist & "<url>http://thetvdb.com/banners/" & bannerselection.InnerXml & "</url>"
- Case "BannerType"
- bannerlist = bannerlist & "<bannertype>" & bannerselection.InnerXml & "</bannertype>"
- Case "BannerType2"
- bannerlist = bannerlist & "<resolution>" & bannerselection.InnerXml & "</resolution>"
- Case "Language"
- bannerlist = bannerlist & "<language>" & bannerselection.InnerXml & "</language>"
- Case "Season"
- bannerlist = bannerlist & "<season>" & bannerselection.InnerXml & "</season>"
- Case ""
- End Select
- Next
- bannerlist = bannerlist & "</banner>"
- End Select
- Next
- bannerlist = bannerlist & "</banners>"
- Return bannerlist
-
- Catch EX As Exception
- Return EX.ToString
- Finally
- Monitor.Exit(Me)
- End Try
- End Function
-
- Public Function getmirrors()
- Monitor.Enter(Me)
- Try
- Dim mirrors As New List(Of String)
- Dim xmlfile As String
- Dim wrGETURL As WebRequest
- Dim mirrorsurl As String = "http://www.thetvdb.com/api/6E82FED600783400/mirrors.xml"
- wrGETURL = WebRequest.Create(mirrorsurl)
- Dim myProxy As New WebProxy("myproxy", 80)
- myProxy.BypassProxyOnLocal = True
- Dim objStream As Stream
- objStream = wrGETURL.GetResponse.GetResponseStream()
- Dim objReader As New StreamReader(objStream)
- xmlfile = objReader.ReadToEnd
- Dim mirrorslist As New XmlDocument
- 'Try
- mirrorslist.LoadXml(xmlfile)
- Dim thisresult As XmlNode = Nothing
- For Each thisresult In mirrorslist("Mirrors")
-
- Select Case thisresult.Name
- Case "Mirror"
- Dim mirrorselection As XmlNode = Nothing
- For Each mirrorselection In thisresult.ChildNodes
- Select Case mirrorselection.Name
- Case "mirrorpath"
- If mirrorselection.InnerText <> Nothing Then
- mirrors.Add(mirrorselection.InnerText)
- End If
- End Select
- Next
- End Select
- Next
- Return mirrors
-
- Catch EX As Exception
- Return EX.ToString
- Finally
- Monitor.Exit(Me)
- End Try
- End Function
-
- Public Function findshows(ByVal title As String, Optional ByVal mirror As String = "http://thetvdb.com")
- Monitor.Enter(Me)
- 'Try
- Dim possibleshows As New List(Of possibleshowlist)
- Dim xmlfile As String
- Dim wrGETURL As WebRequest
- Dim mirrorsurl As String = "http://www.thetvdb.com/api/GetSeries.php?seriesname=" & title & "&language=all"
- wrGETURL = WebRequest.Create(mirrorsurl)
- Dim myProxy As New WebProxy("myproxy", 80)
- myProxy.BypassProxyOnLocal = True
- Dim objStream As Stream
- objStream = wrGETURL.GetResponse.GetResponseStream()
- Dim objReader As New StreamReader(objStream)
- xmlfile = objReader.ReadToEnd
- Dim showlist As New XmlDocument
- Try
- showlist.LoadXml(xmlfile)
- Dim thisresult As XmlNode = Nothing
- For Each thisresult In showlist("Data")
-
- Select Case thisresult.Name
- Case "Series"
- Dim newshow As New possibleshowlist
- Dim mirrorselection As XmlNode = Nothing
- For Each mirrorselection In thisresult.ChildNodes
- Select Case mirrorselection.Name
- Case "seriesid"
- newshow.showid = mirrorselection.InnerXml
- Case "SeriesName"
- newshow.showtitle = mirrorselection.InnerXml
- Case "banner"
- newshow.showbanner = "http://www.thetvdb.com/banners/" & mirrorselection.InnerXml
- End Select
- Next
- possibleshows.Add(newshow)
- End Select
- Next
- Dim returnstring As String
- Dim ok As Boolean = False
- If possibleshows.Count > 0 Then
- returnstring = "<allshows>"
- For Each show In possibleshows
- If show.showid <> Nothing Then
- returnstring = returnstring & "<show>"
- returnstring = returnstring & "<showid>" & show.showid & "</showid>"
- ok = True
- If show.showtitle <> Nothing Then
- returnstring = returnstring & "<showtitle>" & show.showtitle & "</showtitle>"
- End If
- If show.showbanner <> Nothing Then
- returnstring = returnstring & "<showbanner>" & show.showbanner & "</showbanner>"
- End If
- returnstring = returnstring & "</show>"
- End If
- Next
- returnstring = returnstring & "</allshows>"
- Else
- returnstring = "none"
- End If
- If ok = False Then returnstring = "none"
- Return returnstring
- 'Catch EX As Exception
- ' Return EX.ToString
- 'End Try
- Catch EX As Exception
- Return "error"
- Finally
- Monitor.Exit(Me)
- End Try
- End Function
-
- Public Function getshow(ByVal tvdbid As String, ByVal language As String)
- Monitor.Enter(Me)
- Try
- Dim tvshowdetails As String = "<fulltvshow>"
- Dim xmlfile As String
- Dim wrGETURL As WebRequest
- Dim episodeguideurl As String = "http://www.thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/all/" & language & ".zip"
- Dim mirrorsurl As String = "http://www.thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/" & language & ".xml"
- wrGETURL = WebRequest.Create(mirrorsurl)
- Dim myProxy As New WebProxy("myproxy", 80)
- myProxy.BypassProxyOnLocal = True
- Dim objStream As Stream
- objStream = wrGETURL.GetResponse.GetResponseStream()
- Dim objReader As New StreamReader(objStream)
- xmlfile = objReader.ReadToEnd
- Dim showlist As New XmlDocument
- 'Try
- showlist.LoadXml(xmlfile)
- Dim thisresult As XmlNode = Nothing
- For Each thisresult In showlist("Data")
-
- Select Case thisresult.Name
- Case "Series"
- Dim newshow As New possibleshowlist
- Dim mirrorselection As XmlNode = Nothing
- For Each mirrorselection In thisresult.ChildNodes
- Select Case mirrorselection.Name
- Case "SeriesName"
- tvshowdetails = tvshowdetails & "<title>" & mirrorselection.InnerXml & "</title>"
- Case "ContentRating"
- tvshowdetails = tvshowdetails & "<mpaa>" & mirrorselection.InnerXml & "</mpaa>"
- Case "FirstAired"
- tvshowdetails = tvshowdetails & "<premiered>" & mirrorselection.InnerXml & "</premiered>"
- Case "Genre"
- tvshowdetails = tvshowdetails & "<genre>" & mirrorselection.InnerXml & "</genre>"
- Case "IMDB_ID"
- tvshowdetails = tvshowdetails & "<imdbid>" & mirrorselection.InnerXml & "</imdbid>"
- Case "Network"
- tvshowdetails = tvshowdetails & "<studio>" & mirrorselection.InnerXml & "</studio>"
- Case "Overview"
- tvshowdetails = tvshowdetails & "<plot>" & mirrorselection.InnerXml & "</plot>"
- Case "Rating"
- tvshowdetails = tvshowdetails & "<rating>" & mirrorselection.InnerXml & "</rating>"
- Case "Runtime"
- tvshowdetails = tvshowdetails & "<runtime>" & mirrorselection.InnerXml & "</runtime>"
- Case "banner"
- tvshowdetails = tvshowdetails & "<banner>" & "http://thetvdb.com/banners/" & mirrorselection.InnerXml & "</banner>"
- Case "fanart"
- tvshowdetails = tvshowdetails & "<fanart>" & "http://thetvdb.com/banners/" & mirrorselection.InnerXml & "</fanart>"
- Case "poster"
- tvshowdetails = tvshowdetails & "<poster>" & "http://thetvdb.com/banners/" & mirrorselection.InnerXml & "</poster>"
- End Select
- Next
- End Select
- Next
-
- tvshowdetails = tvshowdetails & "<episodeguideurl>" & episodeguideurl & "</episodeguideurl>"
-
-
-
- mirrorsurl = "http://www.thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/actors.xml"
- wrGETURL = WebRequest.Create(mirrorsurl)
- Dim objStream2 As Stream
- objStream2 = wrGETURL.GetResponse.GetResponseStream()
- Dim objReader2 As New StreamReader(objStream2)
- xmlfile = objReader2.ReadToEnd
- Dim showlist2 As New XmlDocument
- 'Try
- showlist2.LoadXml(xmlfile)
- thisresult = Nothing
- For Each thisresult In showlist2("Actors")
-
- Select Case thisresult.Name
- Case "Actor"
- tvshowdetails = tvshowdetails & "<actor>"
- Dim newshow As New possibleshowlist
- Dim mirrorselection As XmlNode = Nothing
- For Each mirrorselection In thisresult.ChildNodes
- Select Case mirrorselection.Name
- Case "id"
- tvshowdetails = tvshowdetails & "<actorid>" & mirrorselection.InnerXml & "</actorid>"
- Case "Image"
- If mirrorselection.InnerXml <> Nothing Then
- If mirrorselection.InnerXml <> "" Then
- tvshowdetails = tvshowdetails & "<thumb>" & "http://thetvdb.com/banners/" & mirrorselection.InnerXml & "</thumb>"
- End If
- End If
- Case "Name"
- tvshowdetails = tvshowdetails & "<name>" & mirrorselection.InnerXml & "</name>"
- Case "Role"
- If mirrorselection.InnerXml <> Nothing Then
- If mirrorselection.InnerXml <> "" Then
- tvshowdetails = tvshowdetails & "<role>" & mirrorselection.InnerXml & "</role>"
- End If
- End If
- End Select
- Next
- tvshowdetails = tvshowdetails & "</actor>"
- End Select
- Next
-
- mirrorsurl = "http://www.thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/actors.xml"
- wrGETURL = WebRequest.Create(mirrorsurl)
- Dim objStream3 As Stream
- objStream3 = wrGETURL.GetResponse.GetResponseStream()
- Dim objReader3 As New StreamReader(objStream3)
- xmlfile = objReader3.ReadToEnd
- Dim showlist3 As New XmlDocument
- 'Try
- showlist3.LoadXml(xmlfile)
- thisresult = Nothing
- For Each thisresult In showlist3("Actors")
-
- Select Case thisresult.Name
- Case "Actor"
- tvshowdetails = tvshowdetails & "<actor>"
- Dim newshow As New possibleshowlist
- Dim mirrorselection As XmlNode = Nothing
- For Each mirrorselection In thisresult.ChildNodes
- Select Case mirrorselection.Name
- Case "id"
- tvshowdetails = tvshowdetails & "<actorid>" & mirrorselection.InnerXml & "</actorid>"
- Case "Image"
- If mirrorselection.InnerXml <> Nothing Then
- If mirrorselection.InnerXml <> "" Then
- tvshowdetails = tvshowdetails & "<thumb>" & "http://thetvdb.com/banners/" & mirrorselection.InnerXml & "</thumb>"
- End If
- End If
- Case "Name"
- tvshowdetails = tvshowdetails & "<name>" & mirrorselection.InnerXml & "</name>"
- Case "Role"
- If mirrorselection.InnerXml <> Nothing Then
- If mirrorselection.InnerXml <> "" Then
- tvshowdetails = tvshowdetails & "<role>" & mirrorselection.InnerXml & "</role>"
- End If
- End If
- End Select
- Next
- tvshowdetails = tvshowdetails & "</actor>"
- End Select
- Next
-
-
- tvshowdetails = tvshowdetails & "</fulltvshow>"
-
- Return tvshowdetails
- Catch
- Return "!!!Error!!!"
- Finally
- Monitor.Exit(Me)
- End Try
-
-
- End Function
-
-
- Public Function getepisode(ByVal tvdbid As String, ByVal sortorder As String, ByVal seriesno As String, ByVal episodeno As String, ByVal language As String)
- Monitor.Enter(Me)
- Dim episodestring As String = ""
- Dim episodeurl As String = ""
- Try
- 'http://thetvdb.com/api/6E82FED600783400/series/70726/default/1/1/en.xml
-
- Dim xmlfile As String
- Dim wrGETURL As WebRequest
- If language.ToLower.IndexOf(".xml") = -1 Then
- language = language & ".xml"
- End If
- episodeurl = "http://thetvdb.com/api/6E82FED600783400/series/" & tvdbid & "/" & sortorder & "/" & seriesno & "/" & episodeno & "/" & language
- wrGETURL = WebRequest.Create(episodeurl)
- Dim myProxy As New WebProxy("myproxy", 80)
- myProxy.BypassProxyOnLocal = True
- Dim objStream As Stream
- objStream = wrGETURL.GetResponse.GetResponseStream()
- Dim objReader As New StreamReader(objStream)
- xmlfile = objReader.ReadToEnd
- Dim episode As New XmlDocument
-
- episode.LoadXml(xmlfile)
-
- episodestring = "<episodedetails>"
- episodestring = episodestring & "<url>" & episodeurl & "</url>"
- Dim mirrorslist As New XmlDocument
- 'Try
- mirrorslist.LoadXml(xmlfile)
- Dim thisresult As XmlNode = Nothing
- For Each thisresult In mirrorslist("Data")
-
- Select Case thisresult.Name
- Case "Episode"
- Dim mirrorselection As XmlNode = Nothing
- For Each mirrorselection In thisresult.ChildNodes
- Select Case mirrorselection.Name
- Case "EpisodeName"
- episodestring = episodestring & "<title>" & mirrorselection.InnerXml & "</title>"
- Case "FirstAired"
- episodestring = episodestring & "<premiered>" & mirrorselection.InnerXml & "</premiered>"
- Case "GuestStars"
- Dim tempstring As String = mirrorselection.InnerXml
- Try
- tempstring = tempstring.TrimStart("|")
- tempstring = tempstring.TrimEnd("|")
- Dim tvtempstring2 As String
- Dim tvtempint As Integer
- Dim a() As String
- Dim j As Integer
- tvtempstring2 = ""
- a = tempstring.Split("|")
- tvtempint = a.GetUpperBound(0)
- tvtempstring2 = a(0)
- If tvtempint >= 0 Then
- For j = 0 To tvtempint
- Try
- episodestring = episodestring & "<actor>" & "<name>" & a(j) & "</name></actor>"
- Catch
- End Try
- Next
- End If
- Catch
- End Try
- Case "Director"
- Dim tempstring As String = mirrorselection.InnerXml
- tempstring = tempstring.TrimStart("|")
- tempstring = tempstring.TrimEnd("|")
- episodestring = episodestring & "<director>" & tempstring & "</director>"
- Case "Writer"
- Dim tempstring As String = mirrorselection.InnerXml
- tempstring = tempstring.TrimStart("|")
- tempstring = tempstring.TrimEnd("|")
- episodestring = episodestring & "<credits>" & tempstring & "</credits>"
- Case "Overview"
- episodestring = episodestring & "<plot>" & mirrorselection.InnerXml & "</plot>"
- Case "Rating"
- episodestring = episodestring & "<rating>" & mirrorselection.InnerXml & "</rating>"
- Case "filename"
- episodestring = episodestring & "<thumb>http://www.thetvdb.com/banners/" & mirrorselection.InnerXml & "</thumb>"
- End Select
- Next
- End Select
- Next
- episodestring = episodestring & "</episodedetails>"
- Return episodestring
- Catch ex As Exception
- Return "ERROR - <url>" & episodeurl & "</url>"
- Finally
- Monitor.Exit(Me)
- End Try
-
- End Function
-
- End Class