def general_commands(self, data): ''' General commands from Jellyfin to control the Kodi interface. ''' command = data['Name'] args = data['Arguments'] if command in ('Mute', 'Unmute', 'SetVolume', 'SetSubtitleStreamIndex', 'SetAudioStreamIndex', 'SetRepeatMode'): if command == 'Mute': xbmc.executebuiltin('Mute') elif command == 'Unmute': xbmc.executebuiltin('Mute') elif command == 'SetVolume': xbmc.executebuiltin('SetVolume(%s[,showvolumebar])' % args['Volume']) elif command == 'SetRepeatMode': xbmc.executebuiltin('xbmc.PlayerControl(%s)' % args['RepeatMode']) elif command == 'SetAudioStreamIndex': self.player.set_audio_subs(args['Index']) elif command == 'SetSubtitleStreamIndex': self.player.set_audio_subs(None, args['Index']) self.player.report_playback() elif command == 'DisplayMessage': dialog("notification", heading=args['Header'], message=args['Text'], icon="{jellyfin}", time=int(settings('displayMessage')) * 1000) elif command == 'SendString': JSONRPC('Input.SendText').execute({ 'text': args['String'], 'done': False }) elif command == 'GoHome': JSONRPC('GUI.ActivateWindow').execute({'window': "home"}) elif command == 'Guide': JSONRPC('GUI.ActivateWindow').execute({'window': "tvguide"}) elif command in ('MoveUp', 'MoveDown', 'MoveRight', 'MoveLeft'): actions = { 'MoveUp': "Input.Up", 'MoveDown': "Input.Down", 'MoveRight': "Input.Right", 'MoveLeft': "Input.Left" } JSONRPC(actions[command]).execute() else: builtin = { 'ToggleFullscreen': 'Action(FullScreen)', 'ToggleOsdMenu': 'Action(OSD)', 'ToggleContextMenu': 'Action(ContextMenu)', 'Select': 'Action(Select)', 'Back': 'Action(back)', 'PageUp': 'Action(PageUp)', 'NextLetter': 'Action(NextLetter)', 'GoToSearch': 'VideoLibrary.Search', 'GoToSettings': 'ActivateWindow(Settings)', 'PageDown': 'Action(PageDown)', 'PreviousLetter': 'Action(PrevLetter)', 'TakeScreenshot': 'TakeScreenshot', 'ToggleMute': 'Mute', 'VolumeUp': 'Action(VolumeUp)', 'VolumeDown': 'Action(VolumeDown)', } if command in builtin: xbmc.executebuiltin(builtin[command])
def get_next_episodes(item_id, limit): ''' Only for synced content. ''' with Database('jellyfin') as jellyfindb: db = jellyfin_db.JellyfinDatabase(jellyfindb.cursor) library = db.get_view_name(item_id) if not library: return result = JSONRPC('VideoLibrary.GetTVShows').execute({ 'sort': { 'order': "descending", 'method': "lastplayed" }, 'filter': { 'and': [{ 'operator': "true", 'field': "inprogress", 'value': "" }, { 'operator': "is", 'field': "tag", 'value': "%s" % library }] }, 'properties': ['title', 'studio', 'mpaa', 'file', 'art'] }) try: items = result['result']['tvshows'] except (KeyError, TypeError): return list_li = [] for item in items: if settings('ignoreSpecialsNextEpisodes.bool'): params = { 'tvshowid': item['tvshowid'], 'sort': { 'method': "episode" }, 'filter': { 'and': [{ 'operator': "lessthan", 'field': "playcount", 'value': "1" }, { 'operator': "greaterthan", 'field': "season", 'value': "0" }] }, 'properties': [ "title", "playcount", "season", "episode", "showtitle", "plot", "file", "rating", "resume", "tvshowid", "art", "streamdetails", "firstaired", "runtime", "writer", "dateadded", "lastplayed" ], 'limits': { "end": 1 } } else: params = { 'tvshowid': item['tvshowid'], 'sort': { 'method': "episode" }, 'filter': { 'operator': "lessthan", 'field': "playcount", 'value': "1" }, 'properties': [ "title", "playcount", "season", "episode", "showtitle", "plot", "file", "rating", "resume", "tvshowid", "art", "streamdetails", "firstaired", "runtime", "writer", "dateadded", "lastplayed" ], 'limits': { "end": 1 } } result = JSONRPC('VideoLibrary.GetEpisodes').execute(params) try: episodes = result['result']['episodes'] except (KeyError, TypeError): pass else: for episode in episodes: li = create_listitem(episode) list_li.append((episode['file'], li)) if len(list_li) == limit: break xbmcplugin.addDirectoryItems(PROCESS_HANDLE, list_li, len(list_li)) xbmcplugin.setContent(PROCESS_HANDLE, 'episodes') xbmcplugin.endOfDirectory(PROCESS_HANDLE)
def set_web_server(self): ''' Enable the webserver if not enabled. This is used to cache artwork. Will only test once, if it fails, user will be notified only once. ''' if settings('enableTextureCache.bool'): get_setting = JSONRPC('Settings.GetSettingValue') if not self.get_web_server(): set_setting = JSONRPC('Settings.SetSetingValue') set_setting.execute({ 'setting': "services.webserverport", 'value': 8080 }) set_setting.execute({ 'setting': "services.webserver", 'value': True }) if not self.get_web_server(): settings('enableTextureCache.bool', False) dialog("ok", heading="{jellyfin}", line1=translate(33103)) return result = get_setting.execute({'setting': "services.webserverport"}) settings('webServerPort', str(result['result']['value'] or "")) result = get_setting.execute( {'setting': "services.webserverusername"}) settings('webServerUser', str(result['result']['value'] or "")) result = get_setting.execute( {'setting': "services.webserverpassword"}) settings('webServerPass', str(result['result']['value'] or "")) settings('useWebServer.bool', True)