Skip to content

Commit

Permalink
Re-Added: New IMDB Scraper setting "Save country abbreviation instead…
Browse files Browse the repository at this point in the history
… of full name" (from v13)
  • Loading branch information
Cocotus committed Sep 21, 2014
1 parent c60ee6f commit 60c5177
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 92 deletions.
12 changes: 8 additions & 4 deletions Addons/scraper.IMDB.Data/IMDB_Data.vb
Expand Up @@ -153,7 +153,7 @@ Public Class IMDB_Data
_setup.chkPopularTitles.Checked = _MySettings.SearchPopularTitles
_setup.chkTvTitles.Checked = _MySettings.SearchTvTitles
_setup.chkVideoTitles.Checked = _MySettings.SearchVideoTitles

_setup.chkCountryAbbreviation.Checked = _MySettings.CountryAbbreviation

_setup.orderChanged()
SPanel.Name = String.Concat(Me._Name, "Scraper")
Expand Down Expand Up @@ -205,6 +205,7 @@ Public Class IMDB_Data
_MySettings.SearchPopularTitles = clsAdvancedSettings.GetBooleanSetting("SearchPopularTitles", True)
_MySettings.SearchTvTitles = clsAdvancedSettings.GetBooleanSetting("SearchTvTitles", False)
_MySettings.SearchVideoTitles = clsAdvancedSettings.GetBooleanSetting("SearchVideoTitles", False)
_MySettings.CountryAbbreviation = clsAdvancedSettings.GetBooleanSetting("CountryAbbreviation", False)

End Sub

Expand Down Expand Up @@ -241,6 +242,7 @@ Public Class IMDB_Data
settings.SetBooleanSetting("SearchPopularTitles", _MySettings.SearchPopularTitles)
settings.SetBooleanSetting("SearchTvTitles", _MySettings.SearchTvTitles)
settings.SetBooleanSetting("SearchVideoTitles", _MySettings.SearchVideoTitles)
settings.SetBooleanSetting("CountryAbbreviation", _MySettings.CountryAbbreviation)
End Using
End Sub

Expand Down Expand Up @@ -275,6 +277,7 @@ Public Class IMDB_Data
_MySettings.SearchPopularTitles = _setup.chkPopularTitles.Checked
_MySettings.SearchTvTitles = _setup.chkTvTitles.Checked
_MySettings.SearchVideoTitles = _setup.chkVideoTitles.Checked
_MySettings.CountryAbbreviation = _setup.chkCountryAbbreviation.Checked

SaveSettings()
'ModulesManager.Instance.SaveSettings()
Expand Down Expand Up @@ -444,10 +447,10 @@ Public Class IMDB_Data
If Master.GlobalScrapeMod.NFO AndAlso Not Master.GlobalScrapeMod.DoSearch Then
If Not String.IsNullOrEmpty(DBMovie.Movie.IMDBID) Then
'IMDB-ID already available -> scrape and save data into an empty movie container (nMovie)
_scraper.GetMovieInfo(DBMovie.Movie.IMDBID, nMovie, filterOptions.bFullCrew, False, filterOptions, False, _MySettings.FallBackWorldwide, _MySettings.ForceTitleLanguage)
_scraper.GetMovieInfo(DBMovie.Movie.IMDBID, nMovie, filterOptions.bFullCrew, False, filterOptions, False, _MySettings.FallBackWorldwide, _MySettings.ForceTitleLanguage, _MySettings.CountryAbbreviation)
ElseIf Not ScrapeType = Enums.ScrapeType.SingleScrape Then
'no IMDB-ID for movie --> search first!
DBMovie.Movie = _scraper.GetSearchMovieInfo(DBMovie.Movie.Title, DBMovie, nMovie, ScrapeType, filterOptions, filterOptions.bFullCrew, _MySettings.FallBackWorldwide, _MySettings.ForceTitleLanguage)
DBMovie.Movie = _scraper.GetSearchMovieInfo(DBMovie.Movie.Title, DBMovie, nMovie, ScrapeType, filterOptions, filterOptions.bFullCrew, _MySettings.FallBackWorldwide, _MySettings.ForceTitleLanguage, _MySettings.CountryAbbreviation)
'if still no ID retrieved -> exit
If String.IsNullOrEmpty(DBMovie.Movie.IMDBID) Then Return New Interfaces.ModuleResult With {.breakChain = False, .Cancelled = True}
End If
Expand Down Expand Up @@ -538,7 +541,7 @@ Public Class IMDB_Data
End If
If Not String.IsNullOrEmpty(DBMovie.Movie.IMDBID) AndAlso Master.GlobalScrapeMod.NFO Then
'IMDB-ID available -> scrape and save data into an empty movie container (nMovie)
_scraper.GetMovieInfo(DBMovie.Movie.IMDBID, nMovie, filterOptions.bFullCrew, False, filterOptions, False, _MySettings.FallBackWorldwide, _MySettings.ForceTitleLanguage)
_scraper.GetMovieInfo(DBMovie.Movie.IMDBID, nMovie, filterOptions.bFullCrew, False, filterOptions, False, _MySettings.FallBackWorldwide, _MySettings.ForceTitleLanguage, _MySettings.CountryAbbreviation)
DBMovie.Movie.OriginalTitle = nMovie.OriginalTitle
DBMovie.Movie.Title = nMovie.Title
DBMovie.Movie.ID = nMovie.ID
Expand Down Expand Up @@ -592,6 +595,7 @@ Public Class IMDB_Data
Dim SearchPopularTitles As Boolean
Dim SearchTvTitles As Boolean
Dim SearchVideoTitles As Boolean
Dim CountryAbbreviation As Boolean
#End Region 'Fields

End Structure
Expand Down
43 changes: 20 additions & 23 deletions Addons/scraper.IMDB.Data/Scraper/clsScrapeIMDB.vb
Expand Up @@ -165,7 +165,7 @@ Namespace IMDB
''' <returns>True: success, false: no success</returns>
''' <remarks>Cocotus/Dan 2014/08/30 - Reworked structure: Scraper module should NOT use global scraper settings/locks in Ember, just scraper options of module
''' Instead of directly saving scraped results into DBMovie we use empty nMovie movie container to store retrieved information of scraper</remarks>
Public Function GetMovieInfo(ByVal strID As String, ByRef nMovie As MediaContainers.Movie, ByVal FullCrew As Boolean, ByVal GetPoster As Boolean, ByVal Options As Structures.ScrapeOptions_Movie, ByVal IsSearch As Boolean, ByVal WorldWideTitleFallback As Boolean, ByVal ForceTitleLanguage As String) As Boolean
Public Function GetMovieInfo(ByVal strID As String, ByRef nMovie As MediaContainers.Movie, ByVal FullCrew As Boolean, ByVal GetPoster As Boolean, ByVal Options As Structures.ScrapeOptions_Movie, ByVal IsSearch As Boolean, ByVal WorldWideTitleFallback As Boolean, ByVal ForceTitleLanguage As String, ByVal CountryAbbreviation As Boolean) As Boolean
Try
If bwIMDB.CancellationPending Then Return Nothing

Expand Down Expand Up @@ -422,22 +422,19 @@ Namespace IMDB

'only update nMovie if scraped result is not empty/nothing!
If Cou.Count > 0 Then
'fix for display country flag in XBMC!
If Strings.Join(Cou.ToArray, " / ").Trim.ToUpper.Contains("USA") Then
' nMovie.Country = "United States of America"
nMovie.Countries.Add("United States of America")
ElseIf Strings.Join(Cou.ToArray, " / ").Trim.ToUpper.Contains("UK") Then
' nMovie.Country = "United Kingdom"
nMovie.Countries.Add("United Kingdom")
If CountryAbbreviation = False Then
For Each entry In Cou
entry = Replace(entry, "USA", "United States of America")
entry = Replace(entry, "UK", "United Kingdom")
nMovie.Countries.Add(entry)
Next
Else
' nMovie.Country = Strings.Join(Cou.ToArray, " / ").Trim()
nMovie.Countries.AddRange(Cou.ToList)
End If

End If
End If


End If

If bwIMDB.CancellationPending Then Return Nothing
Expand Down Expand Up @@ -705,7 +702,7 @@ mPlot: 'MOVIE PLOT
Return alStudio
End Function

Public Function GetSearchMovieInfo(ByVal sMovieName As String, ByRef dbMovie As Structures.DBMovie, ByRef nMovie As MediaContainers.Movie, ByVal iType As Enums.ScrapeType, ByVal Options As Structures.ScrapeOptions_Movie, ByVal FullCrew As Boolean, ByVal WorldWideTitleFallback As Boolean, ByVal ForceTitleLanguage As String) As MediaContainers.Movie
Public Function GetSearchMovieInfo(ByVal sMovieName As String, ByRef dbMovie As Structures.DBMovie, ByRef nMovie As MediaContainers.Movie, ByVal iType As Enums.ScrapeType, ByVal Options As Structures.ScrapeOptions_Movie, ByVal FullCrew As Boolean, ByVal WorldWideTitleFallback As Boolean, ByVal ForceTitleLanguage As String, ByVal CountryAbbreviation As Boolean) As MediaContainers.Movie
Dim r As MovieSearchResults = SearchMovie(sMovieName)
Dim b As Boolean = False

Expand All @@ -719,19 +716,19 @@ mPlot: 'MOVIE PLOT
Case Enums.ScrapeType.FullAsk, Enums.ScrapeType.UpdateAsk, Enums.ScrapeType.NewAsk, Enums.ScrapeType.MarkAsk, Enums.ScrapeType.FilterAsk

If r.ExactMatches.Count = 1 Then 'AndAlso r.PopularTitles.Count = 0 AndAlso r.PartialMatches.Count = 0 Then 'redirected to imdb info page
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
ElseIf r.PopularTitles.Count = 1 AndAlso r.PopularTitles(0).Lev <= 5 Then
b = GetMovieInfo(r.PopularTitles.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.PopularTitles.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
ElseIf r.ExactMatches.Count = 1 AndAlso r.ExactMatches(0).Lev <= 5 Then
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
Else
Master.tmpMovie.Clear()
Using dIMDB As New dlgIMDBSearchResults
If dIMDB.ShowDialog(r, sMovieName, dbMovie.Filename) = Windows.Forms.DialogResult.OK Then
If String.IsNullOrEmpty(Master.tmpMovie.IMDBID) Then
b = False
Else
b = GetMovieInfo(Master.tmpMovie.IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(Master.tmpMovie.IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
End If
Else
b = False
Expand All @@ -741,7 +738,7 @@ mPlot: 'MOVIE PLOT

Case Enums.ScrapeType.FilterSkip, Enums.ScrapeType.FullSkip, Enums.ScrapeType.MarkSkip, Enums.ScrapeType.NewSkip, Enums.ScrapeType.UpdateSkip
If r.ExactMatches.Count = 1 Then
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
End If

Case Enums.ScrapeType.FullAuto, Enums.ScrapeType.UpdateAuto, Enums.ScrapeType.NewAuto, Enums.ScrapeType.MarkAuto, Enums.ScrapeType.SingleScrape, Enums.ScrapeType.FilterAuto
Expand All @@ -766,17 +763,17 @@ mPlot: 'MOVIE PLOT
' b = GetMovieInfo(r.PartialMatches.Item(0).IMDBID, imdbMovie, Master.eSettings.FullCrew, Master.eSettings.FullCast, False, Options, True)
'End If
If r.ExactMatches.Count = 1 Then
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
ElseIf r.ExactMatches.Count > 1 AndAlso exactHaveYear >= 0 Then
b = GetMovieInfo(r.ExactMatches.Item(exactHaveYear).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.ExactMatches.Item(exactHaveYear).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
ElseIf r.PopularTitles.Count > 0 AndAlso popularHaveYear >= 0 Then
b = GetMovieInfo(r.PopularTitles.Item(popularHaveYear).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.PopularTitles.Item(popularHaveYear).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
ElseIf r.ExactMatches.Count > 0 AndAlso (r.ExactMatches(0).Lev <= 5 OrElse useAnyway) Then
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.ExactMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
ElseIf r.PopularTitles.Count > 0 AndAlso (r.PopularTitles(0).Lev <= 5 OrElse useAnyway) Then
b = GetMovieInfo(r.PopularTitles.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.PopularTitles.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
ElseIf r.PartialMatches.Count > 0 AndAlso (r.PartialMatches(0).Lev <= 5 OrElse useAnyway) Then
b = GetMovieInfo(r.PartialMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage)
b = GetMovieInfo(r.PartialMatches.Item(0).IMDBID, nMovie, FullCrew, False, Options, True, WorldWideTitleFallback, ForceTitleLanguage, CountryAbbreviation)
End If
End Select

Expand Down Expand Up @@ -846,7 +843,7 @@ mPlot: 'MOVIE PLOT
Dim r As MovieSearchResults = SearchMovie(Args.Parameter)
e.Result = New Results With {.ResultType = SearchType.Movies, .Result = r}
Case SearchType.SearchDetails
Dim s As Boolean = GetMovieInfo(Args.Parameter, Args.IMDBMovie, False, True, Args.Options, True, True, "")
Dim s As Boolean = GetMovieInfo(Args.Parameter, Args.IMDBMovie, False, True, Args.Options, True, True, "", False)
e.Result = New Results With {.ResultType = SearchType.SearchDetails, .Success = s}
End Select
Catch ex As Exception
Expand Down

0 comments on commit 60c5177

Please sign in to comment.