From fe58ebdcf0bb6959c4b1257963d6040bebc20754 Mon Sep 17 00:00:00 2001 From: UKDTOM Date: Thu, 28 Jan 2021 00:56:33 +0100 Subject: [PATCH] Fix #159 --- Contents/Code/consts.py | 2 +- Contents/Code/misc.py | 26 +++++++++++++++++++++++++- Contents/Code/moviefields.py | 1 + Contents/Code/movies.py | 6 ++++++ Contents/Code/output.py | 2 +- Contents/Code/tvfields.py | 4 +++- Contents/Code/tvseries.py | 4 ++++ changelog.txt | 6 ++++++ 8 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Contents/Code/consts.py b/Contents/Code/consts.py index f34fbcb..c83a965 100644 --- a/Contents/Code/consts.py +++ b/Contents/Code/consts.py @@ -4,7 +4,7 @@ ######################################################################## # APP specific stuff -VERSION = ' V2.0.0.15' +VERSION = ' V2.0.0.16' APPNAME = 'ExportTools' NAME = APPNAME + VERSION DESCRIPTION = 'Export Plex libraries to csv-files or xlsx-files' diff --git a/Contents/Code/misc.py b/Contents/Code/misc.py index d55256b..75b8cc2 100644 --- a/Contents/Code/misc.py +++ b/Contents/Code/misc.py @@ -404,7 +404,7 @@ def getItemInfo(et, myRow, fieldList, mediaType='movie'): def getMediaPath(myMedia, myRow): - ''' return the media path info for movies ''' + ''' return the media path info ''' # Get tree info for media try: myMediaTreeInfoURL = GetLoopBack() + '/library/metadata/' + \ @@ -426,6 +426,30 @@ def getMediaPath(myMedia, myRow): return myRow +def getMetadataPath(myMedia, myRow): + ''' return the Metadata path info ''' + # Get tree info for media + try: + MediaHash = Hash.SHA1(GetRegInfo(myMedia, 'guid')) + mediaType = GetRegInfo(myMedia, 'type') + if mediaType == 'movie': + mediaType = 'Movies' + elif mediaType == 'show': + mediaType = 'TV Shows' + MetadataPath = os.path.join( + Core.app_support_path, + 'Metadata', + mediaType, + MediaHash[0], MediaHash[1:] + '.bundle' + ) + myRow['PMS Metadata Path'] = MetadataPath.encode('utf8') + return myRow + except Exception, e: + Log.Exception('Bad Metadata Path with error: %s' % (str(e))) + myRow['PMS Metadata Path'] = 'Error' + return myRow + + def getPlayCountLevel(myMedia, fieldlist): ''' return the playcount info for media ''' # Playcount level selected diff --git a/Contents/Code/moviefields.py b/Contents/Code/moviefields.py index ba54251..b2ba249 100644 --- a/Contents/Code/moviefields.py +++ b/Contents/Code/moviefields.py @@ -324,6 +324,7 @@ # Define rows and element name for level 666 (Two calls pr. movie) Level_666 = [ # ('PMS Media Path' , 'hash') # Field auto added + # ('PMS Metadata Path' , 'SHA1') # Field auto added ] # Define rows and element name for Special level 1 (one call pr. movie) diff --git a/Contents/Code/movies.py b/Contents/Code/movies.py index dd95566..53c5f36 100644 --- a/Contents/Code/movies.py +++ b/Contents/Code/movies.py @@ -36,6 +36,7 @@ def getMovieHeader(PrefsLevel): # Do we need the PMS path? if '666' in PrefsLevel: fieldnames.append('PMS Media Path') + fieldnames.append('PMS Metadata Path') return fieldnames elif PrefsLevel == 'PlayCount 1': fieldnames = misc.getLevelFields( @@ -91,6 +92,7 @@ def getMovieHeader(PrefsLevel): # PMS Path also needs to be exported if '666' in PrefsLevel: fieldnames.append('PMS Media Path') + fieldnames.append('PMS Metadata Path') return fieldnames @@ -111,6 +113,7 @@ def getMovieInfo(myMedia, myRow, prefsLevel): myRow = misc.getItemInfo(myMedia, myRow, moviefields.SLevel_666) if '666' in prefsLevel: myRow = misc.getMediaPath(myMedia, myRow) + myRow = misc.getMetadataPath(myMedia, myRow) return myRow else: # Get Simple Info @@ -183,4 +186,7 @@ def getMovieInfo(myMedia, myRow, prefsLevel): myRow = misc.getMediaPath( myMedia, myRow) + myRow = misc.getMetadataPath( + myMedia, + myRow) return myRow diff --git a/Contents/Code/output.py b/Contents/Code/output.py index e9c1645..41fc059 100644 --- a/Contents/Code/output.py +++ b/Contents/Code/output.py @@ -277,7 +277,7 @@ def createHeader(outFile, sectionType, playListType='', level=None): global wrap wrap = targetfile.add_format() wrap.set_text_wrap() - Log.Debug('CSVGED****** Header written okay') + Log.Debug('Header written okay') return diff --git a/Contents/Code/tvfields.py b/Contents/Code/tvfields.py index 854d86e..9b36eac 100644 --- a/Contents/Code/tvfields.py +++ b/Contents/Code/tvfields.py @@ -245,7 +245,9 @@ '//Guid[starts-with(@id, "tvdb")]/@id'), ('Labels', '//Label/@tag'), ('Collection', ''), - ('Delete Item Watched after days', '@autoDeletionItemPolicyWatchedLibrary') + ('Delete Item Watched after days', + '@autoDeletionItemPolicyWatchedLibrary'), + ('PMS Metadata Path', 'SHA1') # Field auto added ] # Define rows and element name for PlayCount 1 (one calls pr. episode) diff --git a/Contents/Code/tvseries.py b/Contents/Code/tvseries.py index c281ca8..53de6a3 100644 --- a/Contents/Code/tvseries.py +++ b/Contents/Code/tvseries.py @@ -241,6 +241,10 @@ def getShowOnly(myMedia, myRow, level): except Exception, e: myRow[key] = consts.DEFAULT pass + elif key == 'PMS Metadata Path': + myRow = misc.getMetadataPath( + myMedia, + myRow) elif key == 'Delete Item Watched after days': try: deleteDays = directMedia.xpath( diff --git a/changelog.txt b/changelog.txt index 08efe15..dd87fbc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +V2.0.0.16: + - New: + #159 Export PMS path to the Metadata bundle path + * Added to shows at level 3 + * Added to movies at level 666 + V2.0.0.15: - Fix: - #153 Blocker: CSV Export broken