Skip to content

Commit 1025003

Browse files
committed
fixed: Videobuster.de does only scrape if the movie page already has been generated
also added more entries for video resolution
1 parent dec3f7a commit 1025003

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

Addons/scraper.Trailer.VideobusterDE/Scraper/clsScrapeTrailerVidebusterDE.vb

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Imports NLog
2323
Imports HtmlAgilityPack
2424
Imports System.IO
2525
Imports System.Text.RegularExpressions
26+
Imports System.Net
2627

2728
Public Class Scraper
2829

@@ -37,7 +38,7 @@ Public Class Scraper
3738
Dim nVideoStream As New MediaContainers.MediaFile.VideoStream With {
3839
.Codec = ConvertVideoCodec(codec),
3940
.FileExtension = Path.GetExtension(url),
40-
.Resolution = ConvertVideoResolution(height),
41+
.Resolution = ConvertVideoResolution(width, height),
4142
.StreamUrl = url
4243
}
4344

@@ -55,16 +56,27 @@ Public Class Scraper
5556
End Select
5657
End Function
5758

58-
Private Shared Function ConvertVideoResolution(ByVal height As String) As Enums.VideoResolution
59-
Select Case height.ToLower
60-
Case "360"
59+
Private Shared Function ConvertVideoResolution(ByVal width As String, ByVal height As String) As Enums.VideoResolution
60+
Select Case width
61+
Case "426"
62+
Return Enums.VideoResolution.SQ240p
63+
Case "480"
6164
Return Enums.VideoResolution.SQ360p
62-
Case "720"
65+
Case "640"
66+
Return Enums.VideoResolution.HQ480p
67+
Case "1280"
6368
Return Enums.VideoResolution.HD720p
64-
Case "1080"
69+
Case "1920"
6570
Return Enums.VideoResolution.HD1080p
6671
Case Else
67-
Return Enums.VideoResolution.Any
72+
Select Case height
73+
Case "320", "362"
74+
Return Enums.VideoResolution.SQ360p
75+
Case "480"
76+
Return Enums.VideoResolution.HQ480p
77+
Case Else
78+
Return Enums.VideoResolution.UNKNOWN
79+
End Select
6880
End Select
6981
End Function
7082

@@ -89,8 +101,19 @@ Public Class Scraper
89101
'take first search result and search the movie page in the attributes
90102
Dim strMovieUrl = dnSearchResults(0).SelectSingleNode("//a[@class=""title""]").GetAttributeValue("href", String.Empty)
91103
If Not String.IsNullOrEmpty(strMovieUrl) Then
92-
'load the movie page
93-
Dim htmldocMoviePage As HtmlDocument = webParsing.Load(String.Concat(strMainUrl, strMovieUrl))
104+
'-----------------------------------------------------------------------------------------
105+
' load the movie page
106+
'-----------------------------------------------------------------------------------------
107+
' "HtmlWeb.Load" does not work because of Java script doesn't get finished before parsing
108+
' so we use HTTP.DownloadData to get the HTML and load that into a HtmlDocument
109+
'-----------------------------------------------------------------------------------------
110+
111+
Dim sHTTP As New HTTP
112+
Dim MoviePage As String = sHTTP.DownloadData(String.Concat(strMainUrl, strMovieUrl))
113+
sHTTP = Nothing
114+
115+
Dim htmldocMoviePage As New HtmlDocument
116+
If Not String.IsNullOrEmpty(MoviePage) Then htmldocMoviePage.LoadHtml(MoviePage)
94117
If htmldocMoviePage IsNot Nothing Then
95118
Dim dnTrailers = htmldocMoviePage.DocumentNode.SelectNodes("//div[@id=""trailer""]//div[@class=""playlist""]//div[@class=""item""]")
96119
If dnTrailers IsNot Nothing Then
@@ -108,6 +131,7 @@ Public Class Scraper
108131
.Scraper = "Videobuster.de",
109132
.Source = "Videobuster.de",
110133
.Title = strTitle,
134+
.URLWebsite = String.Concat(strMainUrl, strMovieUrl, "#trailer"),
111135
.VideoType = GetVideoType(strTitle)
112136
}
113137

@@ -122,7 +146,11 @@ Public Class Scraper
122146
nTrailer.Streams.VideoStreams.Add(BuildStream(strUrl, strWidth, strHeight, strCodec))
123147
Next
124148

125-
nTrailerList.Add(nTrailer)
149+
'get best quality
150+
If nTrailer.StreamsSpecified Then
151+
nTrailer.VideoResolution = nTrailer.Streams.VideoStreams(0).Resolution
152+
nTrailerList.Add(nTrailer)
153+
End If
126154
Next
127155
End If
128156
End If
@@ -152,4 +180,4 @@ Public Class Scraper
152180

153181
#End Region 'Methods
154182

155-
End Class
183+
End Class

0 commit comments

Comments
 (0)