mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-01-24 08:56:10 +00:00
Byebye TheVoid
This commit is contained in:
parent
4b8f510325
commit
a009530434
8 changed files with 89 additions and 239 deletions
|
@ -381,43 +381,3 @@ class GetItemWorker(threading.Thread):
|
||||||
|
|
||||||
if window('jellyfin_should_stop.bool'):
|
if window('jellyfin_should_stop.bool'):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
class TheVoid(object):
|
|
||||||
|
|
||||||
def __init__(self, method, data):
|
|
||||||
|
|
||||||
''' If you call get, this will block until response is received.
|
|
||||||
This is used to communicate between entrypoints.
|
|
||||||
'''
|
|
||||||
if type(data) != dict:
|
|
||||||
raise Exception("unexpected data format")
|
|
||||||
|
|
||||||
data['VoidName'] = str(create_id())
|
|
||||||
LOG.info("---[ contact MU-TH-UR 6000/%s ]", method)
|
|
||||||
LOG.debug(data)
|
|
||||||
|
|
||||||
event(method, data)
|
|
||||||
self.method = method
|
|
||||||
self.data = data
|
|
||||||
|
|
||||||
def get(self):
|
|
||||||
|
|
||||||
while True:
|
|
||||||
|
|
||||||
response = window('jellyfin_%s.json' % self.data['VoidName'])
|
|
||||||
|
|
||||||
if response != "":
|
|
||||||
|
|
||||||
LOG.debug("--<[ nostromo/jellyfin_%s.json ]", self.data['VoidName'])
|
|
||||||
window('jellyfin_%s' % self.data['VoidName'], clear=True)
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
if window('jellyfin_should_stop.bool'):
|
|
||||||
LOG.info("Abandon mission! A black hole just swallowed [ %s/%s ]", self.method, self.data['VoidName'])
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
xbmc.sleep(100)
|
|
||||||
LOG.info("--[ void/%s ]", self.data['VoidName'])
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import division, absolute_import, print_function, unicode_literals
|
from __future__ import division, absolute_import, print_function, unicode_literals, annotations
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ from kodi_six import xbmc, xbmcaddon
|
||||||
import database
|
import database
|
||||||
from dialogs import context
|
from dialogs import context
|
||||||
from helper import translate, settings, dialog
|
from helper import translate, settings, dialog
|
||||||
from downloader import TheVoid
|
|
||||||
from helper import LazyLogger
|
from helper import LazyLogger
|
||||||
|
from jellyfin import Jellyfin
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -39,10 +39,11 @@ class Context(object):
|
||||||
try:
|
try:
|
||||||
self.kodi_id = sys.listitem.getVideoInfoTag().getDbId() or None
|
self.kodi_id = sys.listitem.getVideoInfoTag().getDbId() or None
|
||||||
self.media = self.get_media_type()
|
self.media = self.get_media_type()
|
||||||
self.server = sys.listitem.getProperty('jellyfinserver') or None
|
self.server_id = sys.listitem.getProperty('jellyfinserver') or None
|
||||||
|
self.api_client = Jellyfin(self.server_id).get_client().jellyfin
|
||||||
item_id = sys.listitem.getProperty('jellyfinid')
|
item_id = sys.listitem.getProperty('jellyfinid')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.server = None
|
self.server_id = None
|
||||||
|
|
||||||
if xbmc.getInfoLabel('ListItem.Property(jellyfinid)'):
|
if xbmc.getInfoLabel('ListItem.Property(jellyfinid)'):
|
||||||
item_id = xbmc.getInfoLabel('ListItem.Property(jellyfinid)')
|
item_id = xbmc.getInfoLabel('ListItem.Property(jellyfinid)')
|
||||||
|
@ -51,8 +52,8 @@ class Context(object):
|
||||||
self.media = xbmc.getInfoLabel('ListItem.DBTYPE')
|
self.media = xbmc.getInfoLabel('ListItem.DBTYPE')
|
||||||
item_id = None
|
item_id = None
|
||||||
|
|
||||||
if self.server or item_id:
|
if self.server_id or item_id:
|
||||||
self.item = TheVoid('GetItem', {'ServerId': self.server, 'Id': item_id}).get()
|
self.item = self.api_client.get_item(item_id)
|
||||||
else:
|
else:
|
||||||
self.item = self.get_item_id()
|
self.item = self.get_item_id()
|
||||||
|
|
||||||
|
@ -143,13 +144,13 @@ class Context(object):
|
||||||
selected = self._selected_option
|
selected = self._selected_option
|
||||||
|
|
||||||
if selected == OPTIONS['Refresh']:
|
if selected == OPTIONS['Refresh']:
|
||||||
TheVoid('RefreshItem', {'ServerId': self.server, 'Id': self.item['Id']})
|
self.api_client.refresh_item(self.item['Id'])
|
||||||
|
|
||||||
elif selected == OPTIONS['AddFav']:
|
elif selected == OPTIONS['AddFav']:
|
||||||
TheVoid('FavoriteItem', {'ServerId': self.server, 'Id': self.item['Id'], 'Favorite': True})
|
self.api_client.favorite(self.item['Id'], True)
|
||||||
|
|
||||||
elif selected == OPTIONS['RemoveFav']:
|
elif selected == OPTIONS['RemoveFav']:
|
||||||
TheVoid('FavoriteItem', {'ServerId': self.server, 'Id': self.item['Id'], 'Favorite': False})
|
self.api_client.favorite(self.item['Id'], False)
|
||||||
|
|
||||||
elif selected == OPTIONS['Addon']:
|
elif selected == OPTIONS['Addon']:
|
||||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.jellyfin)')
|
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.jellyfin)')
|
||||||
|
@ -159,7 +160,7 @@ class Context(object):
|
||||||
|
|
||||||
def delete_item(self):
|
def delete_item(self):
|
||||||
if settings('skipContextMenu.bool') and dialog("yesno", "{jellyfin}", translate(33015)):
|
if settings('skipContextMenu.bool') and dialog("yesno", "{jellyfin}", translate(33015)):
|
||||||
TheVoid('DeleteItem', {'ServerId': self.server, 'Id': self.item['Id']})
|
self.api_client.delete_item(self.item['Id'])
|
||||||
|
|
||||||
def transcode(self):
|
def transcode(self):
|
||||||
filename = xbmc.getInfoLabel("ListItem.Filenameandpath")
|
filename = xbmc.getInfoLabel("ListItem.Filenameandpath")
|
||||||
|
|
|
@ -11,12 +11,13 @@ from six.moves.urllib.parse import parse_qsl, urlencode
|
||||||
from kodi_six import xbmc, xbmcvfs, xbmcgui, xbmcplugin, xbmcaddon
|
from kodi_six import xbmc, xbmcvfs, xbmcgui, xbmcplugin, xbmcaddon
|
||||||
|
|
||||||
import client
|
import client
|
||||||
|
import downloader
|
||||||
from database import reset, get_sync, Database, jellyfin_db, get_credentials
|
from database import reset, get_sync, Database, jellyfin_db, get_credentials
|
||||||
from objects import Objects, Actions
|
from objects import Objects, Actions
|
||||||
from downloader import TheVoid
|
|
||||||
from helper import translate, event, settings, window, dialog, api, JSONRPC
|
from helper import translate, event, settings, window, dialog, api, JSONRPC
|
||||||
from helper.utils import JsonDebugPrinter
|
from helper.utils import JsonDebugPrinter
|
||||||
from helper import LazyLogger
|
from helper import LazyLogger
|
||||||
|
from jellyfin import Jellyfin
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -49,6 +50,8 @@ class Events(object):
|
||||||
|
|
||||||
mode = params.get('mode')
|
mode = params.get('mode')
|
||||||
server = params.get('server')
|
server = params.get('server')
|
||||||
|
jellyfin_client = Jellyfin(server).get_client()
|
||||||
|
api_client = jellyfin_client.jellyfin
|
||||||
|
|
||||||
if server == 'None':
|
if server == 'None':
|
||||||
server = None
|
server = None
|
||||||
|
@ -69,12 +72,16 @@ class Events(object):
|
||||||
|
|
||||||
elif mode == 'play':
|
elif mode == 'play':
|
||||||
|
|
||||||
item = TheVoid('GetItem', {'Id': params['id'], 'ServerId': server}).get()
|
item = api_client.get_item(params['id'])
|
||||||
item["resumePlayback"] = sys.argv[3].split(":")[1] == "true"
|
item["resumePlayback"] = sys.argv[3].split(":")[1] == "true"
|
||||||
Actions(server).play(item, params.get('dbid'), params.get('transcode') == 'true', playlist=params.get('playlist') == 'true')
|
Actions(server).play(item, params.get('dbid'), params.get('transcode') == 'true', playlist=params.get('playlist') == 'true')
|
||||||
|
|
||||||
elif mode == 'playlist':
|
elif mode == 'playlist':
|
||||||
event('PlayPlaylist', {'Id': params['id'], 'ServerId': server})
|
api_client.post_session(jellyfin_client.config.data['app.session'], "Playing", {
|
||||||
|
'PlayCommand': "PlayNow",
|
||||||
|
'ItemIds': params['id'],
|
||||||
|
'StartPositionTicks': 0
|
||||||
|
})
|
||||||
elif mode == 'deviceid':
|
elif mode == 'deviceid':
|
||||||
client.reset_device_id()
|
client.reset_device_id()
|
||||||
elif mode == 'reset':
|
elif mode == 'reset':
|
||||||
|
@ -253,6 +260,7 @@ def browse(media, view_id=None, folder=None, server_id=None):
|
||||||
return
|
return
|
||||||
|
|
||||||
folder = folder.lower() if folder else None
|
folder = folder.lower() if folder else None
|
||||||
|
api_client = Jellyfin(server_id).get_client().jellyfin
|
||||||
|
|
||||||
if folder is None and media in ('homevideos', 'movies', 'books', 'audiobooks'):
|
if folder is None and media in ('homevideos', 'movies', 'books', 'audiobooks'):
|
||||||
return browse_subfolders(media, view_id, server_id)
|
return browse_subfolders(media, view_id, server_id)
|
||||||
|
@ -262,7 +270,7 @@ def browse(media, view_id=None, folder=None, server_id=None):
|
||||||
|
|
||||||
if view_id:
|
if view_id:
|
||||||
|
|
||||||
view = TheVoid('GetItem', {'ServerId': server_id, 'Id': view_id}).get()
|
view = api_client.get_item(view_id)
|
||||||
xbmcplugin.setPluginCategory(PROCESS_HANDLE, view['Name'])
|
xbmcplugin.setPluginCategory(PROCESS_HANDLE, view['Name'])
|
||||||
|
|
||||||
content_type = "files"
|
content_type = "files"
|
||||||
|
@ -277,47 +285,45 @@ def browse(media, view_id=None, folder=None, server_id=None):
|
||||||
content_type = "artists"
|
content_type = "artists"
|
||||||
|
|
||||||
if folder == 'recentlyadded':
|
if folder == 'recentlyadded':
|
||||||
listing = TheVoid('RecentlyAdded', {'Id': view_id, 'ServerId': server_id}).get()
|
listing = api_client.get_recently_added(None, view_id, None)
|
||||||
elif folder == 'genres':
|
elif folder == 'genres':
|
||||||
listing = TheVoid('Genres', {'Id': view_id, 'ServerId': server_id}).get()
|
listing = api_client.get_genres(view_id)
|
||||||
elif media == 'livetv':
|
elif media == 'livetv':
|
||||||
listing = TheVoid('LiveTV', {'Id': view_id, 'ServerId': server_id}).get()
|
listing = api_client.get_channels()
|
||||||
elif folder == 'unwatched':
|
elif folder == 'unwatched':
|
||||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Filters': ['IsUnplayed']}).get()
|
listing = downloader.get_filtered_section(view_id, None, None, None, None, None, ['IsUnplayed'], None, server_id)
|
||||||
elif folder == 'favorite':
|
elif folder == 'favorite':
|
||||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Filters': ['IsFavorite']}).get()
|
listing = downloader.get_filtered_section(view_id, None, None, None, None, None, ['IsFavorite'], None, server_id)
|
||||||
elif folder == 'inprogress':
|
elif folder == 'inprogress':
|
||||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Filters': ['IsResumable']}).get()
|
listing = downloader.get_filtered_section(view_id, None, None, None, None, None, ['IsResumable'], None, server_id)
|
||||||
elif folder == 'boxsets':
|
elif folder == 'boxsets':
|
||||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type('boxsets'), 'Recursive': True}).get()
|
listing = downloader.get_filtered_section(view_id, get_media_type('boxsets'), None, True, None, None, None, None, server_id)
|
||||||
elif folder == 'random':
|
elif folder == 'random':
|
||||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Sort': "Random", 'Limit': 25, 'Recursive': True}).get()
|
listing = downloader.get_filtered_section(view_id, get_media_type(content_type), 25, True, "Random", None, None, None, server_id)
|
||||||
elif (folder or "").startswith('firstletter-'):
|
elif (folder or "").startswith('firstletter-'):
|
||||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Params': {'NameStartsWith': folder.split('-')[1]}}).get()
|
listing = downloader.get_filtered_section(view_id, get_media_type(content_type), None, None, None, None, None, {'NameStartsWith': folder.split('-')[1]}, server_id)
|
||||||
elif (folder or "").startswith('genres-'):
|
elif (folder or "").startswith('genres-'):
|
||||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Params': {'GenreIds': folder.split('-')[1]}}).get()
|
listing = downloader.get_filtered_section(view_id, get_media_type(content_type), None, None, None, None, None, {'GenreIds': folder.split('-')[1]}, server_id)
|
||||||
elif folder == 'favepisodes':
|
elif folder == 'favepisodes':
|
||||||
listing = TheVoid('Browse', {'Media': get_media_type(content_type), 'ServerId': server_id, 'Limit': 25, 'Filters': ['IsFavorite']}).get()
|
listing = downloader.get_filtered_section(None, get_media_type(content_type), 25, None, None, None, ['IsFavorite'], None, server_id)
|
||||||
elif folder and media == 'playlists':
|
elif folder and media == 'playlists':
|
||||||
listing = TheVoid('Browse', {'Id': folder, 'ServerId': server_id, 'Recursive': False, 'Sort': 'None'}).get()
|
listing = downloader.get_filtered_section(folder, get_media_type(content_type), None, False, 'None', None, None, None, server_id)
|
||||||
elif media == 'homevideos':
|
elif media == 'homevideos':
|
||||||
listing = TheVoid('Browse', {'Id': folder or view_id, 'Media': get_media_type(content_type), 'ServerId': server_id, 'Recursive': False}).get()
|
listing = downloader.get_filtered_section(folder or view_id, get_media_type(content_type), None, False, None, None, None, None, server_id)
|
||||||
elif media == 'movies':
|
elif media in ['movies', 'episodes']:
|
||||||
listing = TheVoid('Browse', {'Id': folder or view_id, 'Media': get_media_type(content_type), 'ServerId': server_id, 'Recursive': True}).get()
|
listing = downloader.get_filtered_section(folder or view_id, get_media_type(content_type), None, True, None, None, None, None, server_id)
|
||||||
elif media in ('boxset', 'library'):
|
elif media in ('boxset', 'library'):
|
||||||
listing = TheVoid('Browse', {'Id': folder or view_id, 'ServerId': server_id, 'Recursive': True}).get()
|
listing = downloader.get_filtered_section(folder or view_id, None, None, True, None, None, None, None, server_id)
|
||||||
elif media == 'episodes':
|
|
||||||
listing = TheVoid('Browse', {'Id': folder or view_id, 'Media': get_media_type(content_type), 'ServerId': server_id, 'Recursive': True}).get()
|
|
||||||
elif media == 'boxsets':
|
elif media == 'boxsets':
|
||||||
listing = TheVoid('Browse', {'Id': folder or view_id, 'ServerId': server_id, 'Recursive': False, 'Filters': ["Boxsets"]}).get()
|
listing = downloader.get_filtered_section(folder or view_id, None, None, False, None, None, ['Boxsets'], None, server_id)
|
||||||
elif media == 'tvshows':
|
elif media == 'tvshows':
|
||||||
listing = TheVoid('Browse', {'Id': folder or view_id, 'ServerId': server_id, 'Recursive': True, 'Media': get_media_type(content_type)}).get()
|
listing = downloader.get_filtered_section(folder or view_id, get_media_type(content_type), None, True, None, None, None, None, server_id)
|
||||||
elif media == 'seasons':
|
elif media == 'seasons':
|
||||||
listing = TheVoid('BrowseSeason', {'Id': folder, 'ServerId': server_id}).get()
|
listing = api_client.get_seasons(folder)
|
||||||
elif media != 'files':
|
elif media != 'files':
|
||||||
listing = TheVoid('Browse', {'Id': folder or view_id, 'ServerId': server_id, 'Recursive': False, 'Media': get_media_type(content_type)}).get()
|
listing = downloader.get_filtered_section(folder or view_id, get_media_type(content_type), None, False, None, None, None, None, server_id)
|
||||||
else:
|
else:
|
||||||
listing = TheVoid('Browse', {'Id': folder or view_id, 'ServerId': server_id, 'Recursive': False}).get()
|
listing = downloader.get_filtered_section(folder or view_id, None, None, False, None, None, None, None, server_id)
|
||||||
|
|
||||||
if listing:
|
if listing:
|
||||||
|
|
||||||
|
@ -405,7 +411,7 @@ def browse_subfolders(media, view_id, server_id=None):
|
||||||
'''
|
'''
|
||||||
from views import DYNNODES
|
from views import DYNNODES
|
||||||
|
|
||||||
view = TheVoid('GetItem', {'ServerId': server_id, 'Id': view_id}).get()
|
view = Jellyfin(server_id).get_client().jellyfin.get_item(view_id)
|
||||||
xbmcplugin.setPluginCategory(PROCESS_HANDLE, view['Name'])
|
xbmcplugin.setPluginCategory(PROCESS_HANDLE, view['Name'])
|
||||||
nodes = DYNNODES[media]
|
nodes = DYNNODES[media]
|
||||||
|
|
||||||
|
@ -431,7 +437,7 @@ def browse_letters(media, view_id, server_id=None):
|
||||||
'''
|
'''
|
||||||
letters = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
letters = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
|
||||||
view = TheVoid('GetItem', {'ServerId': server_id, 'Id': view_id}).get()
|
view = Jellyfin(server_id).get_client().jellyfin.get_item(view_id)
|
||||||
xbmcplugin.setPluginCategory(PROCESS_HANDLE, view['Name'])
|
xbmcplugin.setPluginCategory(PROCESS_HANDLE, view['Name'])
|
||||||
|
|
||||||
for node in letters:
|
for node in letters:
|
||||||
|
@ -501,12 +507,13 @@ def get_fanart(item_id, path, server_id=None):
|
||||||
objects = Objects()
|
objects = Objects()
|
||||||
list_li = []
|
list_li = []
|
||||||
directory = xbmc.translatePath("special://thumbnails/jellyfin/%s/" % item_id)
|
directory = xbmc.translatePath("special://thumbnails/jellyfin/%s/" % item_id)
|
||||||
server = TheVoid('GetServerAddress', {'ServerId': server_id}).get()
|
jellyfin_client = Jellyfin(server_id).get_client()
|
||||||
|
server = jellyfin_client.auth.get_server_info(self.server_id)['address']
|
||||||
|
|
||||||
if not xbmcvfs.exists(directory):
|
if not xbmcvfs.exists(directory):
|
||||||
|
|
||||||
xbmcvfs.mkdirs(directory)
|
xbmcvfs.mkdirs(directory)
|
||||||
item = TheVoid('GetItem', {'ServerId': server_id, 'Id': item_id}).get()
|
item = jellyfin_client.jellyfin.get_item(item_id)
|
||||||
obj = objects.map(item, 'Artwork')
|
obj = objects.map(item, 'Artwork')
|
||||||
backdrops = api.API(item, server).get_all_artwork(obj)
|
backdrops = api.API(item, server).get_all_artwork(obj)
|
||||||
tags = obj['BackdropTags']
|
tags = obj['BackdropTags']
|
||||||
|
@ -542,8 +549,8 @@ def get_video_extras(item_id, path, server_id=None):
|
||||||
if not item_id:
|
if not item_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
TheVoid('GetItem', {'ServerId': server_id, 'Id': item_id}).get()
|
# TODO implement????
|
||||||
# TODO: Investigate the void (issue #228)
|
# Jellyfin(server_id).get_client().jellyfin.get_item(item_id)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def getVideoFiles(jellyfinId,jellyfinPath):
|
def getVideoFiles(jellyfinId,jellyfinPath):
|
||||||
|
@ -737,8 +744,9 @@ def add_user():
|
||||||
if not window('jellyfin_online.bool'):
|
if not window('jellyfin_online.bool'):
|
||||||
return
|
return
|
||||||
|
|
||||||
session = TheVoid('GetSession', {}).get()
|
jellyfin_client = Jellyfin().get_client()
|
||||||
users = TheVoid('GetUsers', {'IsDisabled': False, 'IsHidden': False}).get()
|
session = jellyfin_client.get_device(jellyfin_client.config.app.device_id)
|
||||||
|
users = jellyfin_client.jellyfin.get_users()
|
||||||
current = session[0]['AdditionalUsers']
|
current = session[0]['AdditionalUsers']
|
||||||
|
|
||||||
result = dialog("select", translate(33061), [translate(33062), translate(33063)] if current else [translate(33062)])
|
result = dialog("select", translate(33061), [translate(33062), translate(33063)] if current else [translate(33062)])
|
||||||
|
@ -796,18 +804,19 @@ def get_themes():
|
||||||
views = [x[0] for x in all_views if x[2] in ('movies', 'tvshows', 'mixed')]
|
views = [x[0] for x in all_views if x[2] in ('movies', 'tvshows', 'mixed')]
|
||||||
|
|
||||||
items = {}
|
items = {}
|
||||||
server = TheVoid('GetServerAddress', {'ServerId': None}).get()
|
jellyfin_client = Jellyfin().get_client()
|
||||||
token = TheVoid('GetToken', {'ServerId': None}).get()
|
server = jellyfin_client.auth.get_server_address()
|
||||||
|
token = jellyfin_client.auth.jellyfin_token()
|
||||||
|
|
||||||
for view in views:
|
for view in views:
|
||||||
result = TheVoid('GetThemes', {'Type': "Video", 'Id': view}).get()
|
result = jellyfin_client.jellyfin.get_items_theme_video(view)
|
||||||
|
|
||||||
for item in result['Items']:
|
for item in result['Items']:
|
||||||
|
|
||||||
folder = normalize_string(item['Name'])
|
folder = normalize_string(item['Name'])
|
||||||
items[item['Id']] = folder
|
items[item['Id']] = folder
|
||||||
|
|
||||||
result = TheVoid('GetThemes', {'Type': "Song", 'Id': view}).get()
|
result = jellyfin_client.jellyfin.get_items_theme_song(view)
|
||||||
|
|
||||||
for item in result['Items']:
|
for item in result['Items']:
|
||||||
|
|
||||||
|
@ -822,7 +831,7 @@ def get_themes():
|
||||||
if not xbmcvfs.exists(nfo_path):
|
if not xbmcvfs.exists(nfo_path):
|
||||||
xbmcvfs.mkdir(nfo_path)
|
xbmcvfs.mkdir(nfo_path)
|
||||||
|
|
||||||
themes = TheVoid('GetTheme', {'Id': item}).get()
|
themes = jellyfin_client.jellyfin.get_themes(item)
|
||||||
paths = []
|
paths = []
|
||||||
|
|
||||||
for theme in themes['ThemeVideosResult']['Items'] + themes['ThemeSongsResult']['Items']:
|
for theme in themes['ThemeVideosResult']['Items'] + themes['ThemeSongsResult']['Items']:
|
||||||
|
|
|
@ -11,8 +11,8 @@ from kodi_six import xbmc, xbmcvfs
|
||||||
|
|
||||||
import client
|
import client
|
||||||
import requests
|
import requests
|
||||||
from downloader import TheVoid
|
|
||||||
from helper import LazyLogger
|
from helper import LazyLogger
|
||||||
|
from jellyfin import Jellyfin
|
||||||
|
|
||||||
from . import translate, settings, window, dialog, api
|
from . import translate, settings, window, dialog, api
|
||||||
|
|
||||||
|
@ -60,23 +60,19 @@ class PlayUtils(object):
|
||||||
'''
|
'''
|
||||||
self.item = item
|
self.item = item
|
||||||
self.item['PlaybackInfo'] = {}
|
self.item['PlaybackInfo'] = {}
|
||||||
|
self.jellyfin_client = Jellyfin(server_id).get_client()
|
||||||
self.info = {
|
self.info = {
|
||||||
'ServerId': server_id,
|
'ServerId': server_id,
|
||||||
'ServerAddress': server,
|
'ServerAddress': server,
|
||||||
'ForceTranscode': force_transcode,
|
'ForceTranscode': force_transcode,
|
||||||
'Token': token or TheVoid('GetToken', {'ServerId': server_id}).get()
|
'Token': token or self.jellyfin_client.auth.jellyfin_token()
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_sources(self, source_id=None):
|
def get_sources(self, source_id=None):
|
||||||
|
|
||||||
''' Return sources based on the optional source_id or the device profile.
|
''' Return sources based on the optional source_id or the device profile.
|
||||||
'''
|
'''
|
||||||
params = {
|
info = self.jellyfin_client.jellyfin.get_play_info(self.item['Id'], self.get_device_profile())
|
||||||
'ServerId': self.info['ServerId'],
|
|
||||||
'Id': self.item['Id'],
|
|
||||||
'Profile': self.get_device_profile()
|
|
||||||
}
|
|
||||||
info = TheVoid('GetPlaybackInfo', params).get()
|
|
||||||
LOG.info(info)
|
LOG.info(info)
|
||||||
self.info['PlaySessionId'] = info['PlaySessionId']
|
self.info['PlaySessionId'] = info['PlaySessionId']
|
||||||
sources = []
|
sources = []
|
||||||
|
@ -217,14 +213,7 @@ class PlayUtils(object):
|
||||||
|
|
||||||
''' Get live stream media info.
|
''' Get live stream media info.
|
||||||
'''
|
'''
|
||||||
params = {
|
info = self.jellyfin_client.jellyfin.get_live_stream(self.item['Id'], self.info['PlaySessionId'], source['OpenToken'], self.get_device_profile())
|
||||||
'ServerId': self.info['ServerId'],
|
|
||||||
'Id': self.item['Id'],
|
|
||||||
'Profile': self.get_device_profile(),
|
|
||||||
'PlaySessionId': self.info['PlaySessionId'],
|
|
||||||
'Token': source['OpenToken']
|
|
||||||
}
|
|
||||||
info = TheVoid('GetLiveStream', params).get()
|
|
||||||
LOG.info(info)
|
LOG.info(info)
|
||||||
|
|
||||||
if info['MediaSource'].get('RequiresClosing'):
|
if info['MediaSource'].get('RequiresClosing'):
|
||||||
|
@ -509,7 +498,7 @@ class PlayUtils(object):
|
||||||
mapping = {}
|
mapping = {}
|
||||||
kodi = 0
|
kodi = 0
|
||||||
|
|
||||||
server_settings = TheVoid('GetTranscodeOptions', {'ServerId': self.info['ServerId']}).get()
|
server_settings = self.jellyfin_client.jellyfin.get_transcode_settings()
|
||||||
|
|
||||||
for stream in source['MediaStreams']:
|
for stream in source['MediaStreams']:
|
||||||
if stream['SupportsExternalStream'] and stream['Type'] == 'Subtitle' and stream['DeliveryMethod'] == 'External':
|
if stream['SupportsExternalStream'] and stream['Type'] == 'Subtitle' and stream['DeliveryMethod'] == 'External':
|
||||||
|
@ -598,7 +587,7 @@ class PlayUtils(object):
|
||||||
subs_streams = collections.OrderedDict()
|
subs_streams = collections.OrderedDict()
|
||||||
streams = source['MediaStreams']
|
streams = source['MediaStreams']
|
||||||
|
|
||||||
server_settings = TheVoid('GetTranscodeOptions', {'ServerId': self.info['ServerId']}).get()
|
server_settings = self.jellyfin_client.jellyfin.get_transcode_settings()
|
||||||
allow_burned_subs = settings('allowBurnedSubs.bool')
|
allow_burned_subs = settings('allowBurnedSubs.bool')
|
||||||
|
|
||||||
for stream in streams:
|
for stream in streams:
|
||||||
|
@ -665,6 +654,7 @@ class PlayUtils(object):
|
||||||
if subtitle:
|
if subtitle:
|
||||||
|
|
||||||
index = subtitle
|
index = subtitle
|
||||||
|
server_settings = self.jellyfin_client.jellyfin.get_transcode_settings()
|
||||||
stream = streams[index]
|
stream = streams[index]
|
||||||
|
|
||||||
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:
|
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:
|
||||||
|
@ -683,6 +673,8 @@ class PlayUtils(object):
|
||||||
index = subs_streams[selection[resp]] if resp > -1 else source.get('DefaultSubtitleStreamIndex')
|
index = subs_streams[selection[resp]] if resp > -1 else source.get('DefaultSubtitleStreamIndex')
|
||||||
|
|
||||||
if index is not None:
|
if index is not None:
|
||||||
|
|
||||||
|
server_settings = self.jellyfin_client.jellyfin.get_transcode_settings()
|
||||||
stream = streams[index]
|
stream = streams[index]
|
||||||
|
|
||||||
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:
|
if server_settings['EnableSubtitleExtraction'] and stream['SupportsExternalStream']:
|
||||||
|
|
|
@ -54,6 +54,7 @@ class Jellyfin(object):
|
||||||
self.server_id = server_id or "default"
|
self.server_id = server_id or "default"
|
||||||
|
|
||||||
def get_client(self):
|
def get_client(self):
|
||||||
|
# type: () -> JellyfinClient
|
||||||
return self.client[self.server_id]
|
return self.client[self.server_id]
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
|
|
@ -204,6 +204,9 @@ class ConnectionManager(object):
|
||||||
if server['Id'] == server_id:
|
if server['Id'] == server_id:
|
||||||
return server
|
return server
|
||||||
|
|
||||||
|
def get_server_address(self, server_id):
|
||||||
|
return self.get_server_info(server_id or self.server_id).get('address')
|
||||||
|
|
||||||
def get_public_users(self):
|
def get_public_users(self):
|
||||||
return self.client.jellyfin.get_public_users()
|
return self.client.jellyfin.get_public_users()
|
||||||
|
|
||||||
|
|
|
@ -53,12 +53,7 @@ class Monitor(xbmc.Monitor):
|
||||||
if sender == 'plugin.video.jellyfin':
|
if sender == 'plugin.video.jellyfin':
|
||||||
method = method.split('.')[1]
|
method = method.split('.')[1]
|
||||||
|
|
||||||
if method not in ('GetItem', 'ReportProgressRequested', 'LoadServer', 'RandomItems', 'Recommended',
|
if method not in ('ReportProgressRequested', 'LoadServer', 'AddUser', 'PlayPlaylist', 'Play', 'Playstate', 'GeneralCommand'):
|
||||||
'GetServerAddress', 'GetPlaybackInfo', 'Browse', 'GetImages', 'GetToken',
|
|
||||||
'PlayPlaylist', 'Play', 'GetIntros', 'GetAdditionalParts', 'RefreshItem', 'Genres',
|
|
||||||
'FavoriteItem', 'DeleteItem', 'AddUser', 'GetSession', 'GetUsers', 'GetThemes',
|
|
||||||
'GetTheme', 'Playstate', 'GeneralCommand', 'GetTranscodeOptions', 'RecentlyAdded',
|
|
||||||
'BrowseSeason', 'LiveTV', 'GetLiveStream'):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
data = json.loads(data)[0]
|
data = json.loads(data)[0]
|
||||||
|
@ -122,116 +117,17 @@ class Monitor(xbmc.Monitor):
|
||||||
LOG.exception(error)
|
LOG.exception(error)
|
||||||
server = Jellyfin()
|
server = Jellyfin()
|
||||||
|
|
||||||
if method == 'GetItem':
|
server = server.get_client()
|
||||||
|
|
||||||
item = server.jellyfin.get_item(data['Id'])
|
if method == 'Play':
|
||||||
self.void_responder(data, item)
|
|
||||||
|
|
||||||
elif method == 'GetAdditionalParts':
|
items = server.jellyfin.get_items(data['ItemIds'])
|
||||||
|
|
||||||
item = server.jellyfin.get_additional_parts(data['Id'])
|
PlaylistWorker(data.get('ServerId'), items, data['PlayCommand'] == 'PlayNow',
|
||||||
self.void_responder(data, item)
|
data.get('StartPositionTicks', 0), data.get('AudioStreamIndex'),
|
||||||
|
data.get('SubtitleStreamIndex')).start()
|
||||||
elif method == 'GetIntros':
|
|
||||||
|
|
||||||
item = server.jellyfin.get_intros(data['Id'])
|
|
||||||
self.void_responder(data, item)
|
|
||||||
|
|
||||||
elif method == 'GetImages':
|
|
||||||
|
|
||||||
item = server.jellyfin.get_images(data['Id'])
|
|
||||||
self.void_responder(data, item)
|
|
||||||
|
|
||||||
elif method == 'GetServerAddress':
|
|
||||||
|
|
||||||
server_address = server.auth.get_server_info(server.auth.server_id)['address']
|
|
||||||
self.void_responder(data, server_address)
|
|
||||||
|
|
||||||
elif method == 'GetPlaybackInfo':
|
|
||||||
|
|
||||||
sources = server.jellyfin.get_play_info(data['Id'], data['Profile'])
|
|
||||||
self.void_responder(data, sources)
|
|
||||||
|
|
||||||
elif method == 'GetLiveStream':
|
|
||||||
|
|
||||||
sources = server.jellyfin.get_live_stream(data['Id'], data['PlaySessionId'], data['Token'], data['Profile'])
|
|
||||||
self.void_responder(data, sources)
|
|
||||||
|
|
||||||
elif method == 'GetToken':
|
|
||||||
|
|
||||||
token = server.auth.jellyfin_token()
|
|
||||||
self.void_responder(data, token)
|
|
||||||
|
|
||||||
elif method == 'GetSession':
|
|
||||||
|
|
||||||
session = server.jellyfin.get_device(self.device_id)
|
|
||||||
self.void_responder(data, session)
|
|
||||||
|
|
||||||
elif method == 'GetUsers':
|
|
||||||
|
|
||||||
users = server.jellyfin.get_users()
|
|
||||||
self.void_responder(data, users)
|
|
||||||
|
|
||||||
elif method == 'GetTranscodeOptions':
|
|
||||||
|
|
||||||
result = server.jellyfin.get_transcode_settings()
|
|
||||||
self.void_responder(data, result)
|
|
||||||
|
|
||||||
elif method == 'GetThemes':
|
|
||||||
|
|
||||||
if data['Type'] == 'Video':
|
|
||||||
theme = server.jellyfin.get_items_theme_video(data['Id'])
|
|
||||||
else:
|
|
||||||
theme = server.jellyfin.get_items_theme_song(data['Id'])
|
|
||||||
|
|
||||||
self.void_responder(data, theme)
|
|
||||||
|
|
||||||
elif method == 'GetTheme':
|
|
||||||
|
|
||||||
theme = server.jellyfin.get_themes(data['Id'])
|
|
||||||
self.void_responder(data, theme)
|
|
||||||
|
|
||||||
elif method == 'Browse':
|
|
||||||
|
|
||||||
result = downloader.get_filtered_section(data.get('Id'), data.get('Media'), data.get('Limit'),
|
|
||||||
data.get('Recursive'), data.get('Sort'), data.get('SortOrder'),
|
|
||||||
data.get('Filters'), data.get('Params'), data.get('ServerId'))
|
|
||||||
self.void_responder(data, result)
|
|
||||||
|
|
||||||
elif method == 'BrowseSeason':
|
|
||||||
|
|
||||||
result = server.jellyfin.get_seasons(data['Id'])
|
|
||||||
self.void_responder(data, result)
|
|
||||||
|
|
||||||
elif method == 'LiveTV':
|
|
||||||
|
|
||||||
result = server.jellyfin.get_channels()
|
|
||||||
self.void_responder(data, result)
|
|
||||||
|
|
||||||
elif method == 'RecentlyAdded':
|
|
||||||
|
|
||||||
result = server.jellyfin.get_recently_added(data.get('Media'), data.get('Id'), data.get('Limit'))
|
|
||||||
self.void_responder(data, result)
|
|
||||||
|
|
||||||
elif method == 'Genres':
|
|
||||||
|
|
||||||
result = server.jellyfin.get_genres(data.get('Id'))
|
|
||||||
self.void_responder(data, result)
|
|
||||||
|
|
||||||
elif method == 'Recommended':
|
|
||||||
|
|
||||||
result = server.jellyfin.get_recommendation(data.get('Id'), data.get('Limit'))
|
|
||||||
self.void_responder(data, result)
|
|
||||||
|
|
||||||
elif method == 'RefreshItem':
|
|
||||||
server.jellyfin.refresh_item(data['Id'])
|
|
||||||
|
|
||||||
elif method == 'FavoriteItem':
|
|
||||||
server.jellyfin.favorite(data['Id'], data['Favorite'])
|
|
||||||
|
|
||||||
elif method == 'DeleteItem':
|
|
||||||
server.jellyfin.delete_item(data['Id'])
|
|
||||||
|
|
||||||
|
# TODO no clue if this is called by anything
|
||||||
elif method == 'PlayPlaylist':
|
elif method == 'PlayPlaylist':
|
||||||
|
|
||||||
server.jellyfin.post_session(server.config.data['app.session'], "Playing", {
|
server.jellyfin.post_session(server.config.data['app.session'], "Playing", {
|
||||||
|
@ -240,14 +136,6 @@ class Monitor(xbmc.Monitor):
|
||||||
'StartPositionTicks': 0
|
'StartPositionTicks': 0
|
||||||
})
|
})
|
||||||
|
|
||||||
elif method == 'Play':
|
|
||||||
|
|
||||||
items = server.jellyfin.get_items(data['ItemIds'])
|
|
||||||
|
|
||||||
PlaylistWorker(data.get('ServerId'), items, data['PlayCommand'] == 'PlayNow',
|
|
||||||
data.get('StartPositionTicks', 0), data.get('AudioStreamIndex'),
|
|
||||||
data.get('SubtitleStreamIndex')).start()
|
|
||||||
|
|
||||||
elif method in ('ReportProgressRequested', 'Player.OnAVChange'):
|
elif method in ('ReportProgressRequested', 'Player.OnAVChange'):
|
||||||
self.player.report_playback(data.get('Report', True))
|
self.player.report_playback(data.get('Report', True))
|
||||||
|
|
||||||
|
@ -270,14 +158,9 @@ class Monitor(xbmc.Monitor):
|
||||||
elif method == 'VideoLibrary.OnUpdate':
|
elif method == 'VideoLibrary.OnUpdate':
|
||||||
on_update(data, server)
|
on_update(data, server)
|
||||||
|
|
||||||
def void_responder(self, data, result):
|
|
||||||
|
|
||||||
window('jellyfin_%s.json' % data['VoidName'], result)
|
|
||||||
LOG.debug("--->[ nostromo/jellyfin_%s.json ] sent", data['VoidName'])
|
|
||||||
|
|
||||||
def server_instance(self, server_id=None):
|
def server_instance(self, server_id=None):
|
||||||
|
|
||||||
server = Jellyfin(server_id)
|
server = Jellyfin(server_id).get_client()
|
||||||
self.post_capabilities(server)
|
self.post_capabilities(server)
|
||||||
|
|
||||||
if server_id is not None:
|
if server_id is not None:
|
||||||
|
|
|
@ -10,10 +10,10 @@ from datetime import timedelta
|
||||||
from kodi_six import xbmc, xbmcgui, xbmcplugin, xbmcaddon
|
from kodi_six import xbmc, xbmcgui, xbmcplugin, xbmcaddon
|
||||||
|
|
||||||
import database
|
import database
|
||||||
from downloader import TheVoid
|
|
||||||
from helper import translate, playutils, api, window, settings, dialog
|
from helper import translate, playutils, api, window, settings, dialog
|
||||||
from dialogs import resume
|
from dialogs import resume
|
||||||
from helper import LazyLogger
|
from helper import LazyLogger
|
||||||
|
from jellyfin import Jellyfin
|
||||||
|
|
||||||
from .obj import Objects
|
from .obj import Objects
|
||||||
|
|
||||||
|
@ -29,7 +29,9 @@ class Actions(object):
|
||||||
def __init__(self, server_id=None):
|
def __init__(self, server_id=None):
|
||||||
|
|
||||||
self.server_id = server_id or None
|
self.server_id = server_id or None
|
||||||
self.server = TheVoid('GetServerAddress', {'ServerId': self.server_id}).get()
|
client = Jellyfin(self.server_id).get_client()
|
||||||
|
self.api_client = client.jellyfin
|
||||||
|
self.server = client.auth.get_server_address(self.server_id)
|
||||||
self.stack = []
|
self.stack = []
|
||||||
|
|
||||||
def get_playlist(self, item):
|
def get_playlist(self, item):
|
||||||
|
@ -112,7 +114,7 @@ class Actions(object):
|
||||||
|
|
||||||
''' if we have any play them when the movie/show is not being resumed.
|
''' if we have any play them when the movie/show is not being resumed.
|
||||||
'''
|
'''
|
||||||
intros = TheVoid('GetIntros', {'ServerId': self.server_id, 'Id': item['Id']}).get()
|
intros = self.api_client.get_intros(item['Id'])
|
||||||
|
|
||||||
if intros['Items']:
|
if intros['Items']:
|
||||||
enabled = True
|
enabled = True
|
||||||
|
@ -145,8 +147,7 @@ class Actions(object):
|
||||||
|
|
||||||
''' Create listitems and add them to the stack of playlist.
|
''' Create listitems and add them to the stack of playlist.
|
||||||
'''
|
'''
|
||||||
parts = TheVoid('GetAdditionalParts', {'ServerId': self.server_id, 'Id': item_id}).get()
|
parts = self.api_client.get_additional_parts(item_id)
|
||||||
|
|
||||||
for part in parts['Items']:
|
for part in parts['Items']:
|
||||||
|
|
||||||
listitem = xbmcgui.ListItem()
|
listitem = xbmcgui.ListItem()
|
||||||
|
|
Loading…
Reference in a new issue