mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
Fixed transcode via context menu
This commit is contained in:
parent
d0c5cf5864
commit
f6ffd31e2d
3 changed files with 25 additions and 26 deletions
|
@ -36,7 +36,7 @@ class Context(object):
|
||||||
_selected_option = None
|
_selected_option = None
|
||||||
|
|
||||||
def __init__(self, transcode=False, delete=False):
|
def __init__(self, transcode=False, delete=False):
|
||||||
|
|
||||||
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()
|
||||||
|
@ -51,7 +51,7 @@ class Context(object):
|
||||||
self.kodi_id = xbmc.getInfoLabel('ListItem.DBID')
|
self.kodi_id = xbmc.getInfoLabel('ListItem.DBID')
|
||||||
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 or item_id:
|
||||||
self.item = TheVoid('GetItem', {'ServerId': self.server, 'Id': item_id}).get()
|
self.item = TheVoid('GetItem', {'ServerId': self.server, 'Id': item_id}).get()
|
||||||
else:
|
else:
|
||||||
|
@ -171,6 +171,6 @@ class Context(object):
|
||||||
TheVoid('DeleteItem', {'ServerId': self.server, 'Id': self.item['Id']})
|
TheVoid('DeleteItem', {'ServerId': self.server, 'Id': self.item['Id']})
|
||||||
|
|
||||||
def transcode(self):
|
def transcode(self):
|
||||||
|
filename = xbmc.getInfoLabel("ListItem.Filenameandpath")
|
||||||
item = TheVoid('GetItem', {'Id': self.item['Id'], 'ServerId': self.server}).get()
|
filename += "&transcode=True"
|
||||||
Actions(self.server).play(item, self.kodi_id, True)
|
xbmc.executebuiltin("PlayMedia(%s)" % filename)
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Events(object):
|
||||||
elif mode =='play':
|
elif mode =='play':
|
||||||
|
|
||||||
item = TheVoid('GetItem', {'Id': params['id'], 'ServerId': server}).get()
|
item = TheVoid('GetItem', {'Id': params['id'], 'ServerId': server}).get()
|
||||||
Actions(server).play(item, params.get('dbid'), playlist=params.get('playlist') == 'true')
|
Actions(server).play(item, params.get('dbid'), True if params.get('transcode') == 'True' else False, playlist=params.get('playlist') == 'true')
|
||||||
|
|
||||||
elif mode == 'playlist':
|
elif mode == 'playlist':
|
||||||
event('PlayPlaylist', {'Id': params['id'], 'ServerId': server})
|
event('PlayPlaylist', {'Id': params['id'], 'ServerId': server})
|
||||||
|
@ -163,7 +163,7 @@ def listing():
|
||||||
context.append((_(33133), "RunPlugin(plugin://plugin.video.emby/?mode=removelib&id=%s)" % view_id))
|
context.append((_(33133), "RunPlugin(plugin://plugin.video.emby/?mode=removelib&id=%s)" % view_id))
|
||||||
|
|
||||||
LOG.debug("--[ listing/%s/%s ] %s", node, label, path)
|
LOG.debug("--[ listing/%s/%s ] %s", node, label, path)
|
||||||
|
|
||||||
if path:
|
if path:
|
||||||
if xbmc.getCondVisibility('Window.IsActive(Pictures)') and node in ('photos', 'homevideos'):
|
if xbmc.getCondVisibility('Window.IsActive(Pictures)') and node in ('photos', 'homevideos'):
|
||||||
directory(label, path, artwork=artwork)
|
directory(label, path, artwork=artwork)
|
||||||
|
@ -259,7 +259,7 @@ def browse(media, view_id=None, folder=None, server_id=None):
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
if folder and folder == 'firstletter':
|
if folder and folder == 'firstletter':
|
||||||
return browse_letters(media, view_id, server_id)
|
return browse_letters(media, view_id, server_id)
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ def get_media_type(media):
|
||||||
return "MusicArtist,MusicAlbum,Audio"
|
return "MusicArtist,MusicAlbum,Audio"
|
||||||
|
|
||||||
def get_fanart(item_id, path, server_id=None):
|
def get_fanart(item_id, path, server_id=None):
|
||||||
|
|
||||||
''' Get extra fanart for listitems. This is called by skinhelper.
|
''' Get extra fanart for listitems. This is called by skinhelper.
|
||||||
Images are stored locally, due to the Kodi caching system.
|
Images are stored locally, due to the Kodi caching system.
|
||||||
'''
|
'''
|
||||||
|
@ -571,7 +571,7 @@ def get_video_extras(item_id, path, server_id=None):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_next_episodes(item_id, limit):
|
def get_next_episodes(item_id, limit):
|
||||||
|
|
||||||
''' Only for synced content.
|
''' Only for synced content.
|
||||||
'''
|
'''
|
||||||
with Database('emby') as embydb:
|
with Database('emby') as embydb:
|
||||||
|
@ -658,7 +658,7 @@ def create_listitem(item):
|
||||||
label2 = ""
|
label2 = ""
|
||||||
li = xbmcgui.ListItem(title)
|
li = xbmcgui.ListItem(title)
|
||||||
li.setProperty('IsPlayable', "true")
|
li.setProperty('IsPlayable', "true")
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
'Title': title,
|
'Title': title,
|
||||||
'duration': str(item['runtime']/60),
|
'duration': str(item['runtime']/60),
|
||||||
|
@ -712,7 +712,7 @@ def create_listitem(item):
|
||||||
metadata['CastAndRole'] = castandrole
|
metadata['CastAndRole'] = castandrole
|
||||||
|
|
||||||
li.setLabel2(label2)
|
li.setLabel2(label2)
|
||||||
li.setInfo(type="Video", infoLabels=metadata)
|
li.setInfo(type="Video", infoLabels=metadata)
|
||||||
li.setProperty('resumetime', str(item['resume']['position']))
|
li.setProperty('resumetime', str(item['resume']['position']))
|
||||||
li.setProperty('totaltime', str(item['resume']['total']))
|
li.setProperty('totaltime', str(item['resume']['total']))
|
||||||
li.setArt(item['art'])
|
li.setArt(item['art'])
|
||||||
|
@ -794,7 +794,7 @@ def get_themes():
|
||||||
|
|
||||||
items = {}
|
items = {}
|
||||||
server = TheVoid('GetServerAddress', {'ServerId': None}).get()
|
server = TheVoid('GetServerAddress', {'ServerId': None}).get()
|
||||||
token = TheVoid('GetToken', {'ServerId': None}).get()
|
token = TheVoid('GetToken', {'ServerId': None}).get()
|
||||||
|
|
||||||
for view in views:
|
for view in views:
|
||||||
result = TheVoid('GetThemes', {'Type': "Video", 'Id': view}).get()
|
result = TheVoid('GetThemes', {'Type': "Video", 'Id': view}).get()
|
||||||
|
|
|
@ -84,11 +84,11 @@ class Request(object):
|
||||||
|
|
||||||
|
|
||||||
class StoppableHttpServer(BaseHTTPServer.HTTPServer):
|
class StoppableHttpServer(BaseHTTPServer.HTTPServer):
|
||||||
|
|
||||||
''' Http server that reacts to self.stop flag.
|
''' Http server that reacts to self.stop flag.
|
||||||
'''
|
'''
|
||||||
def serve_forever(self):
|
def serve_forever(self):
|
||||||
|
|
||||||
''' Handle one request at a time until stopped.
|
''' Handle one request at a time until stopped.
|
||||||
'''
|
'''
|
||||||
self.stop = False
|
self.stop = False
|
||||||
|
@ -100,7 +100,7 @@ class StoppableHttpServer(BaseHTTPServer.HTTPServer):
|
||||||
|
|
||||||
|
|
||||||
class StoppableHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
class StoppableHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
|
|
||||||
''' http request handler with QUIT stopping the server
|
''' http request handler with QUIT stopping the server
|
||||||
'''
|
'''
|
||||||
raw_requestline = ""
|
raw_requestline = ""
|
||||||
|
@ -120,16 +120,16 @@ class StoppableHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
self.server.stop = True
|
self.server.stop = True
|
||||||
|
|
||||||
def parse_request(self):
|
def parse_request(self):
|
||||||
|
|
||||||
''' Modify here to workaround unencoded requests.
|
''' Modify here to workaround unencoded requests.
|
||||||
'''
|
'''
|
||||||
retval = SimpleHTTPServer.SimpleHTTPRequestHandler.parse_request(self)
|
retval = SimpleHTTPServer.SimpleHTTPRequestHandler.parse_request(self)
|
||||||
self.request = Request(self.path, self.headers, self.rfile)
|
self.request = Request(self.path, self.headers, self.rfile)
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
def do_HEAD(self):
|
def do_HEAD(self):
|
||||||
|
|
||||||
''' Called on HEAD requests
|
''' Called on HEAD requests
|
||||||
'''
|
'''
|
||||||
self.handle_request(True)
|
self.handle_request(True)
|
||||||
|
@ -137,7 +137,7 @@ class StoppableHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_params(self):
|
def get_params(self):
|
||||||
|
|
||||||
''' Get the params
|
''' Get the params
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
|
@ -153,15 +153,14 @@ class StoppableHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def handle_request(self, headers_only=False):
|
def handle_request(self, headers_only=False):
|
||||||
|
|
||||||
''' Send headers and reponse
|
''' Send headers and reponse
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
params = self.get_params()
|
params = self.get_params()
|
||||||
LOG.info("Webservice called with params: %s", params)
|
LOG.info("Webservice called with params: %s", params)
|
||||||
|
path = ("plugin://plugin.video.emby?mode=play&id=%s&dbid=%s&filename=%s&transcode=%s"
|
||||||
path = ("plugin://plugin.video.emby?mode=play&id=%s&dbid=%s&filename=%s"
|
% (params.get('Id'), params.get('KodiId'), params.get('Name'), params.get('transcode') or False))
|
||||||
% (params.get('Id'), params.get('KodiId'), params.get('Name')))
|
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', 'text/html')
|
self.send_header('Content-type', 'text/html')
|
||||||
self.send_header('Content-Length', len(path))
|
self.send_header('Content-Length', len(path))
|
||||||
|
@ -176,7 +175,7 @@ class StoppableHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
return
|
return
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
|
|
||||||
''' Called on GET requests
|
''' Called on GET requests
|
||||||
'''
|
'''
|
||||||
self.handle_request()
|
self.handle_request()
|
||||||
|
|
Loading…
Reference in a new issue