-
Notifications
You must be signed in to change notification settings - Fork 185
/
MoviepilotDE_Data.vb
183 lines (147 loc) · 8.52 KB
/
MoviepilotDE_Data.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
' ################################################################################
' # EMBER MEDIA MANAGER #
' ################################################################################
' ################################################################################
' # This file is part of Ember Media Manager. #
' # #
' # Ember Media Manager is free software: you can redistribute it and/or modify #
' # it under the terms of the GNU General Public License as published by #
' # the Free Software Foundation, either version 3 of the License, or #
' # (at your option) any later version. #
' # #
' # Ember Media Manager is distributed in the hope that it will be useful, #
' # but WITHOUT ANY WARRANTY; without even the implied warranty of #
' # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
' # GNU General Public License for more details. #
' # #
' # You should have received a copy of the GNU General Public License #
' # along with Ember Media Manager. If not, see <http://www.gnu.org/licenses/>. #
' ################################################################################
Imports NLog
Imports EmberAPI
Public Class MoviepilotDE_Data
Implements Interfaces.ScraperModule_Data_Movie
#Region "Fields"
Shared logger As Logger = LogManager.GetCurrentClassLogger()
Public Shared ConfigScrapeOptions As New Structures.ScrapeOptions
Public Shared ConfigScrapeModifiers As New Structures.ScrapeModifiers
Public Shared _AssemblyName As String
Private _Name As String = "MoviepilotDE_Data"
Private _scraper As New MoviepilotDE.Scraper
Private _ScraperEnabled As Boolean = False
Private _setup As frmSettingsHolder
#End Region 'Fields
#Region "Events"
Public Event ModuleSettingsChanged() Implements Interfaces.ScraperModule_Data_Movie.ModuleSettingsChanged
Public Event MovieScraperEvent(ByVal eType As Enums.ScraperEventType, ByVal Parameter As Object) Implements Interfaces.ScraperModule_Data_Movie.ScraperEvent
Public Event SetupScraperChanged(ByVal name As String, ByVal State As Boolean, ByVal difforder As Integer) Implements Interfaces.ScraperModule_Data_Movie.ScraperSetupChanged
Public Event SetupNeedsRestart() Implements Interfaces.ScraperModule_Data_Movie.SetupNeedsRestart
#End Region 'Events
#Region "Properties"
ReadOnly Property ModuleName() As String Implements Interfaces.ScraperModule_Data_Movie.ModuleName
Get
Return _Name
End Get
End Property
ReadOnly Property ModuleVersion() As String Implements Interfaces.ScraperModule_Data_Movie.ModuleVersion
Get
Return FileVersionInfo.GetVersionInfo(Reflection.Assembly.GetExecutingAssembly.Location).FileVersion.ToString
End Get
End Property
Property ScraperEnabled() As Boolean Implements Interfaces.ScraperModule_Data_Movie.ScraperEnabled
Get
Return _ScraperEnabled
End Get
Set(ByVal value As Boolean)
_ScraperEnabled = value
End Set
End Property
#End Region 'Properties
#Region "Methods"
Private Sub Handle_ModuleSettingsChanged()
RaiseEvent ModuleSettingsChanged()
End Sub
Private Sub Handle_SetupScraperChanged(ByVal state As Boolean, ByVal difforder As Integer)
ScraperEnabled = state
RaiseEvent SetupScraperChanged(String.Concat(Me._Name, "Scraper"), state, difforder)
End Sub
Sub Init(ByVal sAssemblyName As String) Implements Interfaces.ScraperModule_Data_Movie.Init
_AssemblyName = sAssemblyName
LoadSettings()
End Sub
Function InjectSetupScraper() As Containers.SettingsPanel Implements Interfaces.ScraperModule_Data_Movie.InjectSetupScraper
Dim SPanel As New Containers.SettingsPanel
_setup = New frmSettingsHolder
LoadSettings()
_setup.chkEnabled.Checked = _ScraperEnabled
_setup.chkCertifications.Checked = ConfigScrapeOptions.bMainCertifications
_setup.chkOutline.Checked = ConfigScrapeOptions.bMainOutline
_setup.chkPlot.Checked = ConfigScrapeOptions.bMainPlot
_setup.orderChanged()
SPanel.Name = String.Concat(Me._Name, "Scraper")
SPanel.Text = "Moviepilot"
SPanel.Prefix = "MoviepilotDEMovieInfo_"
SPanel.Order = 110
SPanel.Parent = "pnlMovieData"
SPanel.Type = Master.eLang.GetString(36, "Movies")
SPanel.ImageIndex = If(_ScraperEnabled, 9, 10)
SPanel.Panel = _setup.pnlSettings
AddHandler _setup.SetupScraperChanged, AddressOf Handle_SetupScraperChanged
AddHandler _setup.ModuleSettingsChanged, AddressOf Handle_ModuleSettingsChanged
Return SPanel
End Function
Sub LoadSettings()
ConfigScrapeOptions.bMainOutline = clsAdvancedSettings.GetBooleanSetting("DoOutline", True)
ConfigScrapeOptions.bMainPlot = clsAdvancedSettings.GetBooleanSetting("DoPlot", True)
ConfigScrapeOptions.bMainCertifications = clsAdvancedSettings.GetBooleanSetting("DoCert", True)
End Sub
Sub SaveSettings()
Using settings = New clsAdvancedSettings()
settings.SetBooleanSetting("DoOutline", ConfigScrapeOptions.bMainOutline)
settings.SetBooleanSetting("DoPlot", ConfigScrapeOptions.bMainPlot)
settings.SetBooleanSetting("DoCert", ConfigScrapeOptions.bMainCertifications)
End Using
End Sub
Private Sub Handle_PostModuleSettingsChanged()
RaiseEvent ModuleSettingsChanged()
End Sub
Sub SaveSetupScraper(ByVal DoDispose As Boolean) Implements Interfaces.ScraperModule_Data_Movie.SaveSetupScraper
ConfigScrapeOptions.bMainCertifications = _setup.chkCertifications.Checked
ConfigScrapeOptions.bMainOutline = _setup.chkOutline.Checked
ConfigScrapeOptions.bMainPlot = _setup.chkPlot.Checked
SaveSettings()
If DoDispose Then
RemoveHandler _setup.SetupScraperChanged, AddressOf Handle_SetupScraperChanged
RemoveHandler _setup.ModuleSettingsChanged, AddressOf Handle_ModuleSettingsChanged
_setup.Dispose()
End If
End Sub
''' <summary>
''' Scrape MovieDetails from Moviepilot.de (German site)
''' </summary>
''' <param name="DBMovie">Movie to be scraped. DBMovie as ByRef to use existing data for identifing movie and to fill with IMDB/TMDB ID for next scraper</param>
''' <param name="Options">What kind of data is being requested from the scrape(global scraper settings)</param>
''' <returns>Database.DBElement Object (nMovie) which contains the scraped data</returns>
''' <remarks></remarks>
Function Scraper_Movie(ByRef oDBMovie As Database.DBElement, ByRef ScrapeModifiers As Structures.ScrapeModifiers, ByRef ScrapeType As Enums.ScrapeType, ByRef ScrapeOptions As Structures.ScrapeOptions) As Interfaces.ModuleResult_Data_Movie Implements Interfaces.ScraperModule_Data_Movie.Scraper_Movie
logger.Trace("[MoviepilotDE_Data] [Scraper_Movie] [Start]")
LoadSettings()
Dim nMovie As New MediaContainers.Movie
Dim FilteredOptions As Structures.ScrapeOptions = Functions.ScrapeOptionsAndAlso(ScrapeOptions, ConfigScrapeOptions)
If ScrapeModifiers.MainNFO Then
nMovie = _scraper.GetMovieInfo(oDBMovie.Movie.OriginalTitle, oDBMovie.Movie.Title, oDBMovie.Movie.Year, FilteredOptions)
End If
logger.Trace("[MoviepilotDE_Data] [Scraper_Movie] [Done]")
Return New Interfaces.ModuleResult_Data_Movie With {.Result = nMovie}
End Function
Public Sub ScraperOrderChanged() Implements Interfaces.ScraperModule_Data_Movie.ScraperOrderChanged
_setup.orderChanged()
End Sub
Function GetMovieStudio(ByRef DBMovie As Database.DBElement, ByRef studio As List(Of String)) As Interfaces.ModuleResult Implements Interfaces.ScraperModule_Data_Movie.GetMovieStudio
Return New Interfaces.ModuleResult With {.breakChain = False}
End Function
Function GetTMDBID(ByVal sIMDBID As String, ByRef sTMDBID As String) As Interfaces.ModuleResult Implements Interfaces.ScraperModule_Data_Movie.GetTMDBID
Return New Interfaces.ModuleResult With {.breakChain = False}
End Function
#End Region 'Methods
End Class