def start(self): # clear property for auto close menu xbmcgui.Window(10000).clearProperty(__addon_id__ + '_autoclose') # open sync dialog if no parameter if (len(sys.argv) == 0 or len(sys.argv[0]) == 0): import menu menu.MENU().start() return # get id and type from service try: id = sys.argv[1] type = sys.argv[2] except: return # get movie link import searchLink link = searchLink.LINK().start(id, type) debug.debug(str(link)) if link is None: debug.notify(__lang__(32110)) return # prepare users import dialog accounts = function.readAccounts() xbmcgui.Window(10000).setProperty(__addon_id__ + '_autoclose', '1' if 'true' in __addon__.getSetting('autoclose') else '0') for user in accounts.values(): ret = dialog.DIALOG().start('script-facebook-watching-now-menu.xml', labels={10030: user['name']}, buttons=[__lang__(32100)], list=10040) if ret is not None: self.prepare(user, link)
def start(self, mode): xbmcgui.Window(10000).clearProperty(ADDON_ID + '_autoclose') # check is profiles is set if 'true' not in sProfile.values(): debug.notify(ADDON_LANG(32105)) xbmcaddon.Addon(id=ADDON_ID).openSettings() if mode is False: self.save() return if mode == 'popup': enabledProfiles = self.getEnabledProfiles() xbmcgui.Window(10000).setProperty( ADDON_ID + '_autoclose', '1' if 'true' in ADDON.getSetting('player_autoclose') else '0') ret = dialog.DIALOG().start('script-audio-profiles-menu.xml', labels={10071: ADDON_LANG(32106)}, buttons=enabledProfiles[1], list=10070) if ret is not None: self.profile(str(enabledProfiles[0][ret])) return if mode == '0' or mode == '1' or mode == '2' or mode == '3' or mode == '4': if self.check(mode) is False: return if mode == '0': self.toggle(mode) else: self.profile(mode) return debug.error('Wrong arg, use like RunScript("' + ADDON_ID + ',x") x - number of profile')
def start(self): ret = dialog.DIALOG().start('script-user-rating-menu.xml', labels={10060: __lang__(32143)}, buttons=['TMDb', 'TVDb', 'Filmweb'], list=10050) # TMDB if ret == 0: ret = dialog.DIALOG().start( 'script-user-rating-menu.xml', labels={10060: __lang__(32120)}, buttons=['KODI => TMDb', 'TMDb => KODI'], list=10050) if ret == 0: ret = dialog.DIALOG().start('script-user-rating-menu.xml', labels={10060: __lang__(32121)}, buttons=[ __lang__(32122), __lang__(32123), __lang__(32124) ], list=10050) if ret == 0: self.syncKODItoSITE('movie', 'tmdb') if ret == 1: self.syncKODItoSITE('tvshow', 'tmdb') if ret == 2: self.syncKODItoSITE('episode', 'tmdb') return if ret == 1: ret = dialog.DIALOG().start('script-user-rating-menu.xml', labels={10060: __lang__(32121)}, buttons=[ __lang__(32122), __lang__(32123), __lang__(32124) ], list=10050) if ret == 0: self.syncSITEtoKODI('movie', 'tmdb') if ret == 1: self.syncSITEtoKODI('tvshow', 'tmdb') if ret == 2: self.syncSITEtoKODI('episode', 'tmdb') return return # TVDB if ret == 1: ret = dialog.DIALOG().start( 'script-user-rating-menu.xml', labels={10060: __lang__(32120)}, buttons=['KODI => TVDB', 'TVDB => KODI'], list=10050) if ret == 0: ret = dialog.DIALOG().start( 'script-user-rating-menu.xml', labels={10060: __lang__(32121)}, buttons=[__lang__(32123), __lang__(32124)], list=10050) if ret == 0: self.syncKODItoSITE('tvshow', 'tvdb') if ret == 1: self.syncKODItoSITE('episode', 'tvdb') return if ret == 1: ret = dialog.DIALOG().start( 'script-user-rating-menu.xml', labels={10060: __lang__(32121)}, buttons=[__lang__(32123), __lang__(32124)], list=10050) if ret == 0: self.syncSITEtoKODI('tvshow', 'tvdb') if ret == 1: self.syncSITEtoKODI('episode', 'tvdb') return return # Filmweb if ret == 2: ret = dialog.DIALOG().start( 'script-user-rating-menu.xml', labels={10060: __lang__(32120)}, buttons=['KODI => Filmweb', 'Filmweb => KODI'], list=10050) if ret == 0: self.syncKODItoSITE('movie', 'filmweb') if ret == 1: self.syncSITEtoKODI('movie', 'filmweb') return return
def syncSITEtoKODI(self, type, site): if 'tmdb' in site: import tmdb siteClass = tmdb.TMDB(True) siteLabel = 'TMDB' if 'tvdb' in site: import tvdb siteClass = tvdb.TVDB(True) siteLabel = 'TVDB' if 'filmweb' in site: import filmweb siteClass = filmweb.FILMWEB(True) siteLabel = 'FILMWEB' # set bar bar = xbmcgui.DialogProgress() bar.create(__addonname__, '') bar.update( 50, __lang__(32125) + ' ' + __LANGTYPE__[type + 's'] + ' ' + __lang__(32127) + ' ' + siteLabel) # get rated from SITE SITErated = siteClass.getRated(type) debug.debug(siteLabel + 'rated' + type.title() + 's: ' + str(SITErated)) if SITErated is False: bar.close() debug.notify(__lang__(32141)) return if len(SITErated) == 0: bar.close() debug.notify(__lang__(32126) + ' ' + __LANGTYPE__[type + 's']) return if bar.iscanceled(): bar.close() return bar.update( 100, __lang__(32125) + ' ' + __LANGTYPE__[type + 's'] + ' ' + __lang__(32127) + ' KODI') # get rated from KODI KODIrated = self.getRatedKODI(type) debug.debug('KODIrated' + type.title() + 's: ' + str(KODIrated)) bar.close() # check for existed ratings SITEratedExistRate = {} SITEratedNotexistRate = {} for key, item in SITErated.items(): if key in KODIrated.keys(): SITEratedExistRate[key] = item else: SITEratedNotexistRate[key] = item # prepare labels for not existed ratings labels_title = __lang__(32128) + ' (' + str( len(SITEratedNotexistRate)) + ') ' + __lang__(32131) + ':\r\n' for id, data in SITEratedNotexistRate.items(): labels_title = labels_title + '[COLOR=green]>>[/COLOR] ' labels_title = labels_title + data['title'] + ' (' + __lang__( 32132) + ': ' + str(data['rating']) + ')\r\n' labels_title = labels_title + '\r\n' # prepare labels for existed ratings labels_title = labels_title + __lang__(32128) + ' (' + str( len(SITEratedExistRate)) + ') ' + __lang__(32133) + ':\r\n' for id, data in SITEratedExistRate.items(): labels_title = labels_title + '[COLOR=red]>>[/COLOR] ' color = 'green' if data['rating'] == KODIrated[id][ 'new_rating'] else "red" labels_title = labels_title + data['title'] + ' (' + __lang__( 32132) + ': ' + str(data['rating']) + ' - ' + __lang__( 32134) + ': [COLOR=' + color + ']' + str( KODIrated[id]['new_rating']) + '[/COLOR])\r\n' ret = dialog.DIALOG().start( 'script-user-rating-text.xml', labels={ 10062: __lang__(32137) + ' ' + siteLabel + ' ' + __lang__(32142) + ' KODI' }, textboxes={10063: labels_title}, buttons=[__lang__(32138), __lang__(32139), __lang__(32140)], list=10050) if ret == 0: self.saveRatings(SITErated, type) if ret == 1: self.saveRatings(SITEratedNotexistRate, type) if ret == 2: return
def syncKODItoSITE(self, type, site): if 'tmdb' in site: import tmdb siteClass = tmdb.TMDB(True) siteLabel = 'TMDB' if 'tvdb' in site: import tvdb siteClass = tvdb.TVDB(True) siteLabel = 'TVDB' if 'filmweb' in site: import filmweb siteClass = filmweb.FILMWEB(True) siteLabel = 'FILMWEB' # set bar bar = xbmcgui.DialogProgress() bar.create(__addonname__, '') bar.update( 50, __lang__(32125) + ' ' + __LANGTYPE__[type + 's'] + ' ' + __lang__(32127) + ' KODI') # get rated from KODI KODIrated = self.getRatedKODI(type) debug.debug('KODIrated' + type.title() + 's: ' + str(KODIrated)) if len(KODIrated) == 0: bar.close() debug.notify(__lang__(32126) + ' ' + __LANGTYPE__[type + 's']) return bar.update( 100, __lang__(32125) + ' ' + __LANGTYPE__[type + 's'] + ' ' + __lang__(32127) + ' ' + siteLabel) # get rated from Site SITErated = siteClass.getRated(type) debug.debug(siteLabel + 'rated' + type.title() + 's: ' + str(SITErated)) bar.close() # try find siteIDs for KODIrated KODIratedWithIDExistRate = {} KODIratedWithIDNotxistRate = {} KODIratedWithoutID = {} for key, item in KODIrated.items(): if 'movie' in type: siteID = siteClass.searchMovieID(item) if 'tvshow' in type: siteID = siteClass.searchTVshowID(item) if 'episode' in type: siteID = siteClass.searchEpisodeID(item) if len(siteID) == 0: siteID = 0 if siteID == 0: KODIratedWithoutID[key] = item else: if key in SITErated.keys(): KODIratedWithIDExistRate[key] = item else: KODIratedWithIDNotxistRate[key] = item debug.debug('KODIrated' + type.title() + 'sWithoutID: ' + str(KODIratedWithoutID)) debug.debug('KODIrated' + type.title() + 'sWithIDExistRate: ' + str(KODIratedWithIDExistRate)) debug.debug('KODIrated' + type.title() + 'sWithIDNotexistRate: ' + str(KODIratedWithIDNotxistRate)) # prepare labels with siteID and not exist rate labels_title = __lang__(32128) + ' (' + str( len(KODIratedWithIDExistRate) + len(KODIratedWithIDNotxistRate)) + ') ' + __lang__( 32129) + ' ' + siteLabel + ' ' + __lang__(32130) + ':\r\n' labels_title = labels_title + ' ' + __lang__(32128) + ' (' + str( len(KODIratedWithIDNotxistRate)) + ') ' + __lang__(32131) + ':\r\n' for id, data in KODIratedWithIDNotxistRate.items(): labels_title = labels_title + '[COLOR=green] >>[/COLOR] ' labels_title = labels_title + data['title'] + ' (' + __lang__( 32132) + ': ' + str(data['new_rating']) + ')\r\n' labels_title = labels_title + '\r\n' # prepare labels with siteID and exist rate labels_title = labels_title + ' ' + __lang__(32128) + ' (' + str( len(KODIratedWithIDExistRate)) + ') ' + __lang__(32133) + ':\r\n' for id, data in KODIratedWithIDExistRate.items(): labels_title = labels_title + '[COLOR=green] >>[/COLOR] ' color = 'green' if data['new_rating'] == SITErated[id][ 'rating'] else "red" labels_title = labels_title + data['title'] + ' (' + __lang__( 32132) + ': ' + str(data['new_rating']) + ' - ' + __lang__( 32134) + ': [COLOR=' + color + ']' + str( SITErated[id]['rating']) + '[/COLOR])\r\n' labels_title = labels_title + '\r\n' # prepare labels without siteID labels_title = labels_title + __lang__(32128) + ' (' + str( len(KODIratedWithoutID)) + ') ' + __lang__( 32135) + ' ' + siteLabel + ' ' + __lang__(32136) + ':\r\n' for id, data in KODIratedWithoutID.items(): labels_title = labels_title + '[COLOR=red]>>[/COLOR] ' labels_title = labels_title + data['title'] + ' (' + __lang__( 32132) + ': ' + str(data['new_rating']) + ')\r\n' ret = dialog.DIALOG().start( 'script-user-rating-text.xml', labels={ 10062: __lang__(32137) + ' KODI ' + __lang__(32142) + ' ' + siteLabel }, textboxes={10063: labels_title}, buttons=[__lang__(32138), __lang__(32139), __lang__(32140)], list=10050) toUpdate = [] if ret == 0: siteClass.sendRating(KODIratedWithIDExistRate.values() + KODIratedWithIDNotxistRate.values()) if ret == 1: siteClass.sendRating(KODIratedWithIDNotxistRate.values()) if ret == 2: return
def save(self): xbmc_version = int(xbmc.getInfoLabel('System.BuildVersion')[0:2]) debug.debug('[XBMC VERSION]: ' + str(xbmc_version)) enabledProfiles = self.getEnabledProfiles() ret = dialog.DIALOG().start('script-audio-profiles-menu.xml', labels={10071: ADDON_LANG(32100)}, buttons=enabledProfiles[1], list=10070) if ret is None: return False else: button = enabledProfiles[0][ret] settingsToSave = {} if xbmc_version < 17: json_s = [ # get all settings from System / Audio section '{"jsonrpc":"2.0","method":"Settings.GetSettings", "params":{"level": "expert", "filter":{"section":"system","category":"audiooutput"}},"id":1}', # get volume level '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": {"properties": ["volume"]}, "id": 1}', # get all settings from Video / Playback section '{"jsonrpc":"2.0","method":"Settings.GetSettings", "params":{"level": "expert", "filter":{"section":"videos","category":"videoplayer"}}, "id":1}', # get all settings from System / Video section '{"jsonrpc":"2.0","method":"Settings.GetSettings", "params":{"level": "expert", "filter":{"section":"system","category":"videoscreen"}}, "id":1}' ] else: json_s = [ # get all settings from System / Audio section '{"jsonrpc":"2.0","method":"Settings.GetSettings", "params":{"level": "expert", "filter":{"section":"system","category":"audio"}},"id":1}', # get volume level '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": {"properties": ["volume"]}, "id": 1}', # get all settings from Video / Playback section '{"jsonrpc":"2.0","method":"Settings.GetSettings", "params":{"level": "expert", "filter":{"section":"player","category":"videoplayer"}}, "id":1}', # get all settings from System / Video section '{"jsonrpc":"2.0","method":"Settings.GetSettings", "params":{"level": "expert", "filter":{"section":"system","category":"display"}}, "id":1}' ] # send json requests for j in json_s: jsonGet = xbmc.executeJSONRPC(j) jsonGet = json.loads(unicode(jsonGet, 'utf-8')) debug.debug('[JSON]: ' + str(jsonGet)) if 'result' in jsonGet: if 'settings' in jsonGet['result']: for set in jsonGet['result']['settings']: if 'value' in set.keys(): if set['value'] == True or set[ 'value'] == False: # lowercase bolean values settingsToSave[set['id']] = str( set['value']).lower() else: if type(set['value']) is int: settingsToSave[set['id']] = str( set['value']) else: settingsToSave[set['id']] = str( set['value']).encode('utf-8') if 'volume' in jsonGet['result']: settingsToSave['volume'] = str(jsonGet['result']['volume']) # prepare JSON string to save to file jsonToWrite = json.dumps(settingsToSave) # create dir in addon data if not exist if not xbmcvfs.exists(ADDON_PATH_DATA): xbmcvfs.mkdir(ADDON_PATH_DATA) # save profile file debug.notice('[SAVING SETTING]: ' + sName[button]) f = xbmcvfs.File(ADDON_PATH_DATA + 'profile' + str(button) + '.json', 'w') result = f.write(jsonToWrite) f.close() debug.notify( ADDON_LANG(32102) + ' ' + str(button) + ' (' + sName[button] + ')')