def filterTvShows(self, data, rem_episodes=False, rem_seasons=False): listitems = [] for item in data['assetList']: asset_class = maxdome.getAssetClass(item['@class']) if asset_class == 'tvepisode' and rem_episodes: continue elif asset_class == 'tvseason' and rem_seasons: continue listitems.append(item) return listitems
def buildAssetUrl(self, asset): asset_class = maxdome.getAssetClass(asset['@class']) param_action = '' param_id = '' if asset_class == 'tvshow' or asset_class == 'tvseason' or asset_class == 'theme': param_action = 'list' param_id = 'parentid~%s' % (asset['id']) elif asset_class == 'movie' or asset_class == 'tvepisode': param_action = 'play' param_id = asset['id'] return self.buildUrl({'action': param_action, 'id': param_id})
def contextMenuItemsForAsset(self, asset): listitems = [] #ZAHLUNGSPFLICHTIGE INHALTE if not asset['green']: asset_class = maxdome.getAssetClass(asset['@class']) strTitle = '' if asset_class == 'movie': strTitle = 'Film ' elif asset_class == 'tvseason': strTitle = 'Staffel ' elif asset_class == 'tvepisode': strTitle = 'Episode ' if not asset_class == 'tvshow' and not asset_class == 'theme': listitems.append( (strTitle + 'leihen/kaufen', 'RunPlugin(' + self.buildUrl({ 'action': 'buy', 'id': str(asset['id']) }) + ')')) #MERKLISTE mem_param = '' mem_str = '' if asset['remembered']: mem_str = 'Von Merkliste entfernen' mem_param = 'del' else: mem_str = 'Zur Merkliste hinzufügen' mem_param = 'add' listitems.append( (mem_str, 'RunPlugin(' + self.buildUrl({ 'action': mem_param, 'id': str(asset['id']) }) + ')')) #ZEIGE PAKET/STORE view_str = 'Zeige ' if package_only: view_str += 'alle Inhalte' else: view_str += 'nur Paketinhalte' listitems.append( (view_str, 'RunPlugin(' + plugin_base_url + sys.argv[2] + '&switchview=1)')) #EXPORT FOR LIBRARY if addon.getSetting('enablelibraryfolder') == 'true' and not asset[ '@class'].startswith('MultiAssetTheme'): listitems.append( ('Für Bibliothek exportieren', 'RunPlugin(' + self.buildUrl({ 'action': 'export', 'id': str(asset['id']) }) + ')')) return listitems
def playAsset(self, assetid): asset_info = self.mxd.Assets.getAssetInformation(assetid) asset_class = maxdome.getAssetClass(asset_info['@class']) #ASSET WITHOUT ACTIVE LICENSE - BUY/RENT? if not asset_info['green']: options = self.showSalesOptions(asset_info) if options: r = self.mxd.Assets.orderAsset( assetid, orderType=options['orderType'], orderQuality=options['orderQuality']) if '@class' in r: if r['@class'] == 'SelectPaymentQuestionStep': dlg = xbmcgui.Dialog() if not self.paymentOptionAvailable(r): dlg.ok( 'Fehler', 'Video kann nicht per ' + self.mxd.payment_type.title() + ' bezahlt werden.') return False doOrder = dlg.yesno( 'Maxdome Store', r['title'], r['priceInfo'], 'Zahlungsmethode: ' + self.mxd.payment_type.title()) if doOrder: if not self.mxd.Assets.confirmPayment( assetid, options['orderType'], options['orderQuality']): dlg.ok( 'Fehler', 'Video konnte nicht geliehen/gekauft werden' ) return False else: return False if asset_class != 'movie' and asset_class != 'tvepisode': return False if self.mxd.Assets.orderAsset(assetid): li = xbmcgui.ListItem(path=self.mxd.video_url) info = self.getInfoItem(asset_info) li.setInfo('video', info) li.setProperty('inputstream.mpd.license_type', 'com.widevine.alpha') li.setProperty('inputstream.mpd.license_key', self.mxd.license_url) li.setProperty('inputstreamaddon', 'inputstream.mpd') xbmcplugin.setResolvedUrl(addon_handle, True, listitem=li) return True return False
def getTitle(self, asset): asset_class = maxdome.getAssetClass(asset['@class']) if asset_class == 'movie' or asset_class == 'tvshow': return asset['title'] elif asset_class == 'tvseason': r = 'Staffel %02d' % (int(asset['number'])) if not 'de' in asset['languageList']: r += ' (OV)' return r elif asset_class == 'tvepisode': return 'S%02dE%02d - %s' % (int(asset['seasonNumber']), int(asset['episodeNumber']), asset['episodeTitle']) else: return asset['title']
def getTitle(self, asset): asset_class = maxdome.getAssetClass(asset['@class']) if asset_class == 'movie' or asset_class == 'tvshow': return asset['title'] elif asset_class == 'tvseason': r = 'Staffel %02d' % (int(asset['number'])) if not 'de' in asset['languageList']: r += ' (OV)' if self.mxd.Assets.isBuyonly(asset): r = r + '[COLOR orange] - not included in package[/COLOR]' return r elif asset_class == 'tvepisode': return 'S%02dE%02d - %s' % (int(asset['seasonNumber']), int(asset['episodeNumber']), asset['episodeTitle']) else: return asset['title']
def showSalesOptions(self, asset): sales_options = self.mxd.Assets.getSalesOptions(asset) asset_class = maxdome.getAssetClass(asset['@class']) dlg = xbmcgui.Dialog() dlgitems = [] for item in sales_options: dlgitems.append(item['label']) dlgtitle = asset['title'] if asset_class == 'tvseason': dlgtitle += ' - Staffel: ' + str(asset['number']) elif asset_class == 'tvepisode': dlgtitle += ' - Episode: ' + str(asset['episodeTitle']) s = dlg.select(dlgtitle, dlgitems) if s<0: return None return sales_options[s]
def showSalesOptions(self, asset): sales_options = self.mxd.Assets.getSalesOptions(asset) asset_class = maxdome.getAssetClass(asset['@class']) dlg = xbmcgui.Dialog() dlgitems = [] for item in sales_options: dlgitems.append(item['label']) dlgtitle = asset['title'] if asset_class == 'tvseason': dlgtitle += ' - Staffel: ' + str(asset['number']) elif asset_class == 'tvepisode': dlgtitle += ' - Episode: ' + str(asset['episodeTitle']) s = dlg.select(dlgtitle, dlgitems) if s < 0: return None return sales_options[s]
def playAsset(self, assetid): asset_info = self.mxd.Assets.getAssetInformation(assetid) asset_class = maxdome.getAssetClass(asset_info['@class']) #ASSET WITHOUT ACTIVE LICENSE - BUY/RENT? if not asset_info['green']: options = self.showSalesOptions(asset_info) if options: r = self.mxd.Assets.orderAsset(assetid, orderType=options['orderType'], orderQuality=options['orderQuality']) if '@class' in r: if r['@class'] == 'SelectPaymentQuestionStep': dlg = xbmcgui.Dialog() if not self.paymentOptionAvailable(r): dlg.ok('Fehler', 'Video kann nicht per ' + self.mxd.payment_type.title() + ' bezahlt werden.') return False doOrder = dlg.yesno('Maxdome Store', r['title'], r['priceInfo'], 'Zahlungsmethode: ' + self.mxd.payment_type.title()) if doOrder: if not self.mxd.Assets.confirmPayment(assetid, options['orderType'], options['orderQuality']): dlg.ok('Fehler', 'Video konnte nicht geliehen/gekauft werden') return False else: return False if asset_class != 'movie' and asset_class != 'tvepisode': return False if self.mxd.Assets.orderAsset(assetid): li = xbmcgui.ListItem(path=self.mxd.video_url) info = self.getInfoItem(asset_info) li.setInfo('video', info) # Inputstream settings is_addon = getInputstreamAddon() if not is_addon: xbmcgui.Dialog().notification('Maxdome Fehler', 'Inputstream Addon fehlt!', xbmcgui.NOTIFICATION_ERROR, 2000, True) return False li.setProperty(is_addon + '.license_type', 'com.widevine.alpha') li.setProperty(is_addon + '.manifest_type', 'mpd') li.setProperty(is_addon + '.license_key', self.mxd.license_url) li.setProperty('inputstreamaddon', is_addon) xbmcplugin.setResolvedUrl(addon_handle, True, listitem=li) return True return False
def getInfoItem(self, asset): # xbmc.log('%s' % (asset)) # For Debugging info = {} info['plot'] = asset['descriptionShort'] if 'descriptionLong' in asset: info['plot'] = asset['descriptionLong'] info['userrating'] = asset['userrating']['averageRating'] if 'duration' in asset: info['duration'] = int(asset['duration'])*60 if 'fskLevelList' in asset: info['mpaa'] = str(asset['fskLevelList'][0]) info['plot'] = '[COLOR red]'+ info['mpaa'] +'[/COLOR] \n\n' + info['plot'] if 'userrating' in asset: info['rating'] = asset['userrating']['averageRating'] info['plot'] = '[COLOR blue]' + str(asset['userrating']['countTotal']) +' Users rated: '+ str(info['rating']) +' / 5[/COLOR] - ' + info['plot'] if 'productionYear' in asset: info['year'] = asset['productionYear'] asset_class = maxdome.getAssetClass(asset['@class']) if asset_class == 'movie': info['mediatype'] = 'movie' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE) elif asset_class == 'tvshow': info['mediatype'] = 'tvshow' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE) elif asset_class == 'tvseason': info['mediatype'] = 'season' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL) elif asset_class == 'tvepisode': info['mediatype'] = 'episode' info['tvshowtitle'] = asset['title'] info['title'] = asset['episodeTitle']#self.getTitle(asset) info['plot'] = asset['descriptionShort'] info['season'] = int(asset['seasonNumber']) info['episode'] = int(asset['episodeNumber']) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_EPISODE) if not asset['green'] and not self.mxd.Assets.isPackageContent(asset): if 'title' in info: #info['title'] += ' (p)' # old way to separate payed and unpayed content info['title'] = info['title'] + '[COLOR orange] - Buy only[/COLOR]' return info
def getInfoItem(self, asset): info = {} info['plot'] = asset['descriptionShort'] if 'descriptionLong' in asset: info['plot'] = asset['descriptionLong'] info['userrating'] = asset['userrating']['averageRating'] if 'duration' in asset: info['duration'] = int(asset['duration']) * 60 if 'productionYear' in asset: info['year'] = asset['productionYear'] asset_class = maxdome.getAssetClass(asset['@class']) if asset_class == 'movie': info['mediatype'] = 'movie' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE) elif asset_class == 'tvshow': info['mediatype'] = 'tvshow' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE) elif asset_class == 'tvseason': info['mediatype'] = 'season' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL) elif asset_class == 'tvepisode': info['mediatype'] = 'episode' info['tvshowtitle'] = asset['title'] info['title'] = asset['episodeTitle'] #self.getTitle(asset) info['plot'] = asset['descriptionShort'] info['season'] = int(asset['seasonNumber']) info['episode'] = int(asset['episodeNumber']) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_EPISODE) if not asset['green'] and not self.mxd.Assets.isPackageContent(asset): if 'title' in info: info['title'] += ' (p)' return info
def getInfoItem(self, asset): info = {} info['plot'] = asset['descriptionShort'] if 'descriptionLong' in asset: info['plot'] = asset['descriptionLong'] info['userrating'] = asset['userrating']['averageRating'] if 'duration' in asset: info['duration'] = int(asset['duration'])*60 if 'productionYear' in asset: info['year'] = asset['productionYear'] asset_class = maxdome.getAssetClass(asset['@class']) if asset_class == 'movie': info['mediatype'] = 'movie' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE) elif asset_class == 'tvshow': info['mediatype'] = 'tvshow' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE) elif asset_class == 'tvseason': info['mediatype'] = 'season' info['title'] = asset['title'] xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL) elif asset_class == 'tvepisode': info['mediatype'] = 'episode' info['tvshowtitle'] = asset['title'] info['title'] = asset['episodeTitle']#self.getTitle(asset) info['plot'] = asset['descriptionShort'] info['season'] = int(asset['seasonNumber']) info['episode'] = int(asset['episodeNumber']) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_EPISODE) if not asset['green'] and not self.mxd.Assets.isPackageContent(asset): if 'title' in info: info['title'] += ' (p)' return info
def contextMenuItemsForAsset(self, asset): listitems = [] #ZAHLUNGSPFLICHTIGE INHALTE if not asset['green']: asset_class = maxdome.getAssetClass(asset['@class']) strTitle = '' if asset_class == 'movie': strTitle = 'Film ' elif asset_class == 'tvseason': strTitle = 'Staffel ' elif asset_class == 'tvepisode': strTitle = 'Episode ' if not asset_class == 'tvshow' and not asset_class == 'theme': listitems.append((strTitle + 'leihen/kaufen', 'RunPlugin(' + self.buildUrl({'action': 'buy', 'id': str(asset['id'])}) + ')')) #MERKLISTE mem_param = '' mem_str = '' if asset['remembered']: mem_str = 'Von Merkliste entfernen' mem_param = 'del' else: mem_str = 'Zur Merkliste hinzufügen' mem_param = 'add' listitems.append((mem_str, 'RunPlugin(' + self.buildUrl({'action': mem_param, 'id': str(asset['id'])}) + ')')) #ZEIGE PAKET/STORE view_str = 'Zeige ' if package_only: view_str += 'alle Inhalte' else: view_str += 'nur Paketinhalte' listitems.append((view_str, 'RunPlugin(' + plugin_base_url + sys.argv[2] + '&switchview=1)')) #EXPORT FOR LIBRARY if addon.getSetting('enablelibraryfolder') == 'true' and not asset['@class'].startswith('MultiAssetTheme'): listitems.append(('Für Bibliothek exportieren', 'RunPlugin(' + self.buildUrl({'action': 'export', 'id': str(asset['id'])}) + ')')) return listitems