Skip to content

Commit

Permalink
added: "Remove Movie/TVEpisode/TVShow" in Kodi Interface (autosync an…
Browse files Browse the repository at this point in the history
…d context menu)
  • Loading branch information
DanCooper committed Apr 11, 2016
1 parent 4a9bbef commit 745df0d
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 104 deletions.
347 changes: 268 additions & 79 deletions Addons/generic.Interface.Kodi/Interface.Kodi.vb

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Addons/generic.Interface.Kodi/My Project/Resources.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Addons/generic.Interface.Kodi/My Project/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
GR5llcXmiNwEAAAAAElFTkSuQmCC
</value>
</data>
<data name="menuRemove" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\menuRemove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="menuSync" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\menuSync.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 138 additions & 3 deletions Addons/generic.Interface.Kodi/clsAPIKodi.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ Namespace Kodi
''' </summary>
''' <param name="mDBElement">TVSeason as DBElement</param>
''' <param name="SendHostNotification">Send notification to host</param>
''' <returns>true=Update successfull, false=error or movieset not found in KodiDB</returns>
''' <returns>true=Update successfull, false=error or season not found in KodiDB</returns>
''' <remarks>
''' 2015/06/27 Cocotus - First implementation, main code by DanCooper
''' updates all movieset fields which are filled/set in Ember (also paths of images)
Expand All @@ -1343,7 +1343,7 @@ Namespace Kodi
Try
logger.Trace(String.Format("[APIKodi] [{0}] UpdateTVSeasonInfo: ""{1}: Season {2}"" | Start syncing process...", _currenthost.Label, mDBElement.ShowPath, mDBElement.TVSeason.Season))

'search Movie ID in Kodi DB
'search TVSeason ID in Kodi DB
Dim KodiElement As Video.Details.Season = Await GetFullDetailsByID_TVSeason(Await GetMediaID(mDBElement))

'scan tv show path
Expand Down Expand Up @@ -1434,7 +1434,7 @@ Namespace Kodi
Try
logger.Trace(String.Format("[APIKodi] [{0}] UpdateTVShowInfo: ""{1}"" | Start syncing process...", _currenthost.Label, mDBElement.TVShow.Title))

'search Movie ID in Kodi DB
'search TVShow ID in Kodi DB
Dim KodiElement As Video.Details.TVShow = Await GetFullDetailsByID_TVShow(Await GetMediaID(mDBElement))

'scan tv show path
Expand Down Expand Up @@ -1723,6 +1723,141 @@ Namespace Kodi
End Try
End Function
''' <summary>
''' Remove Movie details at Kodi
''' </summary>
''' <param name="mDBElement">Movie as DBElement</param>
''' <param name="SendHostNotification">Send notification to host</param>
''' <returns>true=Remove successfull, false=error or movie not found in KodiDB</returns>
''' <remarks>
''' </remarks>
Public Async Function Remove_Movie(ByVal mDBElement As Database.DBElement, ByVal blnSendHostNotification As Boolean, ByVal GenericSubEvent As IProgress(Of GenericSubEventCallBackAsync), ByVal GenericMainEvent As IProgress(Of GenericEventCallBackAsync)) As Task(Of Boolean)
If _kodi Is Nothing Then
logger.Error("[APIKodi] [Remove_Movie]: No host initialized! Abort!")
Return False
End If

Try
logger.Trace(String.Format("[APIKodi] [{0}] [Remove_Movie]: ""{1}"" | Start removing process...", _currenthost.Label, mDBElement.Movie.Title))

'search Movie ID in Kodi DB
Dim KodiElement As Video.Details.Movie = Await GetFullDetailsByID_Movie(Await GetMediaID(mDBElement))

If KodiElement IsNot Nothing Then
Dim response = Await _kodi.VideoLibrary.RemoveMovie(KodiElement.movieid).ConfigureAwait(False)

If response.Contains("error") Then
logger.Error(String.Format("[APIKodi] [{0}] [Remove_Movie]: {1}", _currenthost.Label, response))
Return False
Else
'Send message to Kodi?
If blnSendHostNotification = True Then
Await SendMessage("Ember Media Manager", String.Format("{0}: {1}", Master.eLang.GetString(1024, "Removed"), mDBElement.Movie.Title)).ConfigureAwait(False)
End If
logger.Trace(String.Format("[APIKodi] [{0}] [Remove_Movie]: ""{1}"" | {2} on host", _currenthost.Label, mDBElement.Movie.Title, "Removed"))
Return True
End If
Else
logger.Error(String.Format("[APIKodi] [{0}] [Remove_Movie]: ""{1}"" | NOT found on host! Abort!", _currenthost.Label, mDBElement.Movie.Title))
Return False
End If

Catch ex As Exception
logger.Error(ex, New StackFrame().GetMethod().Name)
Return False
End Try
End Function
''' <summary>
''' Remove TVEpisode details at Kodi
''' </summary>
''' <param name="mDBElement">TVEpisode as DBElement</param>
''' <param name="SendHostNotification">Send notification to host</param>
''' <returns>true=Remove successfull, false=error or episode not found in KodiDB</returns>
''' <remarks>
''' </remarks>
Public Async Function Remove_TVEpisode(ByVal mDBElement As Database.DBElement, ByVal blnSendHostNotification As Boolean, ByVal GenericSubEvent As IProgress(Of GenericSubEventCallBackAsync), ByVal GenericMainEvent As IProgress(Of GenericEventCallBackAsync)) As Task(Of Boolean)
If _kodi Is Nothing Then
logger.Error("[APIKodi] [Remove_TVEpisode]: No host initialized! Abort!")
Return False
End If

Try
logger.Trace(String.Format("[APIKodi] [{0}] [Remove_TVEpisode]: ""{1}"" | Start removing process...", _currenthost.Label, mDBElement.TVEpisode.Title))

'search TV Episode ID in Kodi DB
Dim KodiElement As Video.Details.Episode = Await GetFullDetailsByID_TVEpisode(Await GetMediaID(mDBElement))

If KodiElement IsNot Nothing Then
Dim response = Await _kodi.VideoLibrary.RemoveEpisode(KodiElement.episodeid).ConfigureAwait(False)

If response.Contains("error") Then
logger.Error(String.Format("[APIKodi] [{0}] [Remove_TVEpisode]: {1}", _currenthost.Label, response))
Return False
Else
'Send message to Kodi?
If blnSendHostNotification = True Then
Await SendMessage("Ember Media Manager", String.Format("{0}: {1}: {2}", Master.eLang.GetString(1024, "Removed"), mDBElement.TVShow.Title, mDBElement.TVEpisode.Title)).ConfigureAwait(False)
End If
logger.Trace(String.Format("[APIKodi] [{0}] [Remove_TVEpisode]: ""{1}"" | {2} on host", _currenthost.Label, mDBElement.TVEpisode.Title, "Removed"))
Return True
End If
Else
logger.Error(String.Format("[APIKodi] [{0}] [Remove_TVEpisode]: ""{1}"" | NOT found on host! Abort!", _currenthost.Label, mDBElement.TVEpisode.Title))
Return False
End If

Catch ex As Exception
logger.Error(ex, New StackFrame().GetMethod().Name)
Return False
End Try
End Function
''' <summary>
''' Remove TVShow details at Kodi
''' </summary>
''' <param name="mDBElement">TVShow as DBElement</param>
''' <param name="SendHostNotification">Send notification to host</param>
''' <returns>true=Remove successfull, false=error or tv show not found in KodiDB</returns>
''' <remarks>
''' </remarks>
Public Async Function Remove_TVShow(ByVal mDBElement As Database.DBElement, ByVal blnSendHostNotification As Boolean, ByVal GenericSubEvent As IProgress(Of GenericSubEventCallBackAsync), ByVal GenericMainEvent As IProgress(Of GenericEventCallBackAsync)) As Task(Of Boolean)
If _kodi Is Nothing Then
logger.Error("[APIKodi] [Remove_TVShow]: No host initialized! Abort!")
Return False
End If

Try
logger.Trace(String.Format("[APIKodi] [{0}] [Remove_TVShow]: ""{1}"" | Start removing process...", _currenthost.Label, mDBElement.TVShow.Title))

'search TVShow ID in Kodi DB
Dim KodiElement As Video.Details.TVShow = Await GetFullDetailsByID_TVShow(Await GetMediaID(mDBElement))

If KodiElement IsNot Nothing Then
Dim response = Await _kodi.VideoLibrary.RemoveTVShow(KodiElement.tvshowid).ConfigureAwait(False)

If response.Contains("error") Then
logger.Error(String.Format("[APIKodi] [{0}] [Remove_TVShow]: {1}", _currenthost.Label, response))
Return False
Else
'Remove old textures (cache)
Await RemoveTextures(mDBElement)

'Send message to Kodi?
If blnSendHostNotification = True Then
Await SendMessage("Ember Media Manager", String.Format("{0}: {1}", Master.eLang.GetString(1024, "Removed"), mDBElement.TVShow.Title)).ConfigureAwait(False)
End If

logger.Trace(String.Format("[APIKodi] [{0}] [Remove_TVShow]: ""{1}"" | {2} on host", _currenthost.Label, mDBElement.TVShow.Title, "Removed"))
Return True
End If
Else
logger.Error(String.Format("[APIKodi] [{0}] [Remove_TVShow]: ""{1}"" | NOT found on host! Abort!", _currenthost.Label, mDBElement.TVShow.Title))
Return False
End If
Catch ex As Exception
logger.Error(ex, New StackFrame().GetMethod().Name)
Return False
End Try
End Function
''' <summary>
''' Remove a cached image by Texture ID
''' </summary>
''' <param name="ID">ID of Texture</param>
Expand Down
3 changes: 3 additions & 0 deletions Addons/generic.Interface.Kodi/generic.Interface.Kodi.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\menuRemove.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
41 changes: 23 additions & 18 deletions EmberAPI/clsAPICommon.vb
Original file line number Diff line number Diff line change
Expand Up @@ -728,56 +728,61 @@ Public Class Enums
OnThemeSave_Movie = 36
OnTrailerSave_Movie = 37
RandomFrameExtrator = 38
Remove_Movie = 39
Remove_MovieSet = 40
Remove_TVEpisode = 41
Remove_TVSeason = 42
Remove_TVShow = 43
''' <summary>
''' Called during auto scraping
''' </summary>
''' <remarks></remarks>
ScraperMulti_Movie = 39
ScraperMulti_Movie = 44
''' <summary>
''' Called during auto scraping
''' </summary>
''' <remarks></remarks>
ScraperMulti_TVEpisode = 40
ScraperMulti_TVEpisode = 45
''' <summary>
''' Called during manual scraping
''' </summary>
''' <remarks></remarks>
ScraperSingle_Movie = 41
ScraperSingle_Movie = 46
''' <summary>
''' Called during manual scraping
''' </summary>
''' <remarks></remarks>
ScraperSingle_TVEpisode = 42
ShowMovie = 43
ShowTVShow = 44
SyncModuleSettings = 45
Sync_Movie = 46
Sync_MovieSet = 47
Sync_TVEpisode = 48
Sync_TVSeason = 49
Sync_TVShow = 50
Task = 51
ScraperSingle_TVEpisode = 47
ShowMovie = 48
ShowTVShow = 49
SyncModuleSettings = 50
Sync_Movie = 51
Sync_MovieSet = 52
Sync_TVEpisode = 53
Sync_TVSeason = 54
Sync_TVShow = 55
Task = 56
''' <summary>
''' Called during auto scraping
''' </summary>
''' <remarks></remarks>
ScraperMulti_TVShow = 53
ScraperMulti_TVShow = 57
''' <summary>
''' Called during manual scraping
''' </summary>
''' <remarks></remarks>
ScraperSingle_TVShow = 54
ScraperSingle_TVShow = 58
''' <summary>
''' Called during auto scraping
''' </summary>
''' <remarks></remarks>
ScraperMulti_TVSeason = 55
ScraperMulti_TVSeason = 59
''' <summary>
''' Called during manual scraping
''' </summary>
''' <remarks></remarks>
ScraperSingle_TVSeason = 56
DuringUpdateDB_TV = 57
ScraperSingle_TVSeason = 60
DuringUpdateDB_TV = 61
End Enum

Public Enum ScraperEventType As Integer
Expand Down
11 changes: 10 additions & 1 deletion EmberAPI/clsAPIDatabase.vb
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,9 @@ Public Class Database
Public Function Delete_Movie(ByVal ID As Long, ByVal BatchMode As Boolean) As Boolean
If ID < 0 Then Throw New ArgumentOutOfRangeException("idMovie", "Value must be >= 0, was given: " & ID)

Dim _movieDB As Database.DBElement = Load_Movie(ID)
ModulesManager.Instance.RunGeneric(Enums.ModuleEventType.Remove_Movie, Nothing, Nothing, False, _movieDB)

Try
Dim SQLtransaction As SQLiteTransaction = Nothing
If Not BatchMode Then SQLtransaction = _myvideosDBConn.BeginTransaction()
Expand Down Expand Up @@ -1089,6 +1092,9 @@ Public Class Database
Dim SQLtransaction As SQLiteTransaction = Nothing
Dim doesExist As Boolean = False

Dim _tvepisodeDB As Database.DBElement = Load_TVEpisode(ID, True)
ModulesManager.Instance.RunGeneric(Enums.ModuleEventType.Remove_TVEpisode, Nothing, Nothing, False, _tvepisodeDB)

If Not BatchMode Then SQLtransaction = _myvideosDBConn.BeginTransaction()
Using SQLcommand As SQLiteCommand = _myvideosDBConn.CreateCommand()
SQLcommand.CommandText = String.Concat("SELECT idFile, Episode, Season, idShow FROM episode WHERE idEpisode = ", ID, ";")
Expand Down Expand Up @@ -1235,6 +1241,9 @@ Public Class Database
Public Function Delete_TVShow(ByVal ID As Long, ByVal BatchMode As Boolean) As Boolean
If ID < 0 Then Throw New ArgumentOutOfRangeException("idShow", "Value must be >= 0, was given: " & ID)

Dim _tvshowDB As Database.DBElement = Load_TVShow_Full(ID)
ModulesManager.Instance.RunGeneric(Enums.ModuleEventType.Remove_TVShow, Nothing, Nothing, False, _tvshowDB)

Try
Dim SQLtransaction As SQLiteTransaction = Nothing
If Not BatchMode Then SQLtransaction = _myvideosDBConn.BeginTransaction()
Expand Down Expand Up @@ -2337,7 +2346,7 @@ Public Class Database
''' <remarks></remarks>
Public Function Load_TVShow_Full(ByVal ShowID As Long) As DBElement
If ShowID < 0 Then Throw New ArgumentOutOfRangeException("ShowID", "Value must be >= 0, was given: " & ShowID)
Return Master.DB.Load_TVShow(ShowID, True, True)
Return Master.DB.Load_TVShow(ShowID, True, True, True)
End Function
''' <summary>
''' Load all the information for a TV Season
Expand Down
6 changes: 3 additions & 3 deletions EmberMediaManager/Langs/English_(en_US).xml
Original file line number Diff line number Diff line change
Expand Up @@ -1113,15 +1113,15 @@
<string id="1021">Select Tag</string>
<string id="1022">There was a problem communicating with host or there are no sources configured in Kodi</string>
<string id="1023">Preselect in "Image Select" dialog</string>
<string id="1024"></string>
<string id="1024">Removed</string>
<string id="1025">All Seasons Banner</string>
<string id="1026">All Seasons Fanart</string>
<string id="1027">Minimum Quality:</string>
<string id="1028">Select the folder where you wish to store your tv themes...</string>
<string id="1029">Select the folder where you wish to store your watched files...</string>
<string id="1030">Select the folder where you wish to store your movie sets images...</string>
<string id="1031"></string>
<string id="1032"></string>
<string id="1031">Removal OK</string>
<string id="1032">Removal failed</string>
<string id="1033"></string>
<string id="1034"></string>
<string id="1035">Landscape</string>
Expand Down

0 comments on commit 745df0d

Please sign in to comment.