def getShowOnly(myMedia, myRow, level): prefsLevel = Prefs['TV_Level'] if prefsLevel in ['Show Only 1', 'Show Only 2', 'Show Only 3']: for key, value in tvfields.Show_1: element = myMedia.get(value[1:]) if element == None: element = 'N/A' element = misc.WrapStr(misc.fixCRLF(element).encode('utf8')) if key == 'MetaDB Link': myRow[key] = misc.metaDBLink(element) elif key in myRow: myRow[key] = myRow[key] + Prefs['Seperator'] + element else: myRow[key] = element if prefsLevel in ['Show Only 2', 'Show Only 3']: for key, value in tvfields.Show_2: myRow[key] = misc.GetArrayAsString(myMedia, value, default = consts.DEFAULT) # Additional call needed for level 3 if prefsLevel in ['Show Only 3']: directURL = misc.GetLoopBack() + '/library/metadata/' + myRow['Media ID'] directMedia = XML.ElementFromURL(directURL, timeout=float(consts.PMSTIMEOUT)) for key, value in tvfields.Show_3: if key == 'MetaDB Link': myRow[key] = misc.metaDBLink(str(directMedia.xpath('//Directory/@guid'))) else: myRow[key] = misc.GetArrayAsString(directMedia, value, default = consts.DEFAULT) return myRow
def getShowOnly(myMedia, myRow, level): ''' Export TV Show info only ''' if level: prefsLevel = level else: prefsLevel = Prefs['TV_Level'] if prefsLevel in ['Show Only 1', 'Show Only 2', 'Show Only 3']: for key, value in tvfields.Show_1: element = myMedia.get(value[1:]) if element is None: element = consts.DEFAULT element = misc.WrapStr(misc.fixCRLF(element).encode('utf8')) if key == 'MetaDB Link': myRow[key] = misc.metaDBLink(element) # Is it a dateStamp? elif value[1:] in tvfields.dateTimeFields: myRow[key] = misc.ConvertDateStamp(element) elif key in myRow: myRow[key] = myRow[key] + Prefs['Seperator'] + element else: myRow[key] = element if prefsLevel in ['Show Only 2', 'Show Only 3']: for key, value in tvfields.Show_2: myRow[key] = misc.GetArrayAsString(myMedia, value, default=consts.DEFAULT) # Additional call needed for level 3 if prefsLevel in ['Show Only 3']: directURL = misc.GetLoopBack() + '/library/metadata/' + \ myRow['Media ID'] directMedia = XML.ElementFromURL(directURL, timeout=float(consts.PMSTIMEOUT)) for key, value in tvfields.Show_3: if key == 'MetaDB Link': try: myRow[key] = misc.metaDBLink( str(directMedia.xpath('//Directory/@guid'))) except Exception, e: myRow[key] = consts.DEFAULT pass elif key == 'Delete Item Watched after days': try: deleteDays = directMedia.xpath( '//Directory/@autoDeletionItemPolicyWatchedLibrary') if deleteDays == ['100']: deleteDays = 'Next Refresh' elif deleteDays == []: deleteDays = 'Never' elif deleteDays == ['0']: deleteDays = 'Never' elif deleteDays == ['1']: deleteDays = '1 Day' elif deleteDays == ['7']: deleteDays = '7 Days' myRow[key] = deleteDays except Exception, e: myRow[key] = consts.DEFAULT pass
def getShowOnly(myMedia, myRow, level): prefsLevel = Prefs['TV_Level'] for key, value in tvfields.Show_1: element = myMedia.get(value[1:]) if element == None: element = 'N/A' element = misc.WrapStr(misc.fixCRLF(element).encode('utf8')) if key in myRow: myRow[key] = myRow[key] + Prefs['Seperator'] + element else: myRow[key] = element # Now we sadly needs to make a call for each show :-( if '2' in prefsLevel: myExtendedInfoURL = misc.GetLoopBack( ) + '/library/metadata/' + myMedia.get('ratingKey') for key, value in tvfields.Show_2: if key == 'MetaDB Link': myRow[key] = misc.metaDBLink( XML.ElementFromURL( myExtendedInfoURL, timeout=float(consts.PMSTIMEOUT))[0].xpath('@guid')[0]) return myRow