Skip to content

Commit

Permalink
Merge pull request #362 from quickmic/next-gen
Browse files Browse the repository at this point in the history
first stable release of emby-next-gen
  • Loading branch information
quickmic authored Mar 15, 2021
2 parents 71162fc + 007a652 commit 8ba19ce
Show file tree
Hide file tree
Showing 234 changed files with 12,907 additions and 54,807 deletions.
26 changes: 8 additions & 18 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby" name="Emby" version="4.1.22" provider-name="angelblue05, sualfred">
<addon id="plugin.video.emby-next-gen" name="Emby-next-gen" version="5.1.17" provider-name="quickmic, angelblue05, sualfred">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="plugin.video.emby.movies" version="0.14" />
<import addon="plugin.video.emby.tvshows" version="0.14" />
<import addon="plugin.video.emby.musicvideos" version="0.14" />
<import addon="script.module.requests" version="2.22.0"/>
<import addon="script.module.dateutil" version="2.8.1"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
<extension point="xbmc.python.pluginsource" library="events.py">
<provides>video audio image</provides>
</extension>
<extension point="xbmc.service" library="service.py" />
<extension point="kodi.context.item">
<menu id="kodi.core.main">
<item library="context_play.py">
<label>33201</label>
<visible>[!String.IsEmpty(ListItem.DBID) + !String.IsEqual(ListItem.DBID,-1) | !String.IsEmpty(ListItem.Property(embyid))] + !String.IsEmpty(Window(10000).Property(emby_context))</visible>
</item>
<item library="context_transcode.py">
<label>30402</label>
<visible>[[!String.IsEmpty(ListItem.DBID) + !String.IsEqual(ListItem.DBID,-1) | !String.IsEmpty(ListItem.Property(embyid))] + [String.IsEqual(ListItem.DBTYPE,movie) | String.IsEqual(ListItem.DBTYPE,episode)]] + !String.IsEmpty(Window(10000).Property(emby_context_transcode))</visible>
</item>
<item library="context.py">
<label>30401</label>
<visible>[!String.IsEmpty(ListItem.DBID) + !String.IsEqual(ListItem.DBID,-1) | !String.IsEmpty(ListItem.Property(embyid))] + !String.IsEmpty(Window(10000).Property(emby_context))</visible>
<visible>[!String.IsEmpty(ListItem.DBID) + !String.IsEqual(ListItem.DBID,-1) | !String.IsEmpty(ListItem.Property(embyid))]</visible>
</item>
</menu>
</extension>
Expand All @@ -31,13 +21,13 @@
<language>en</language>
<license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
<forum>http://emby.media/community/index.php?/forum/99-kodi/</forum>
<website>http://emby.media/</website>
<website>https://emby.media/</website>
<source>https://github.com/MediaBrowser/plugin.video.emby</source>
<description lang="en">Welcome to Emby for Kodi A whole new way to manage and view your media library. The Emby addon for Kodi combines the best of Kodi - ultra smooth navigation, beautiful UIs and playback of any file under the sun, and Emby - the most powerful fully open source multi-client media metadata indexer and server.&#10;&#10;Emby for Kodi is the absolute best way to enjoy the incredible Kodi playback engine combined with the power of Emby's centralized database. Features: Direct integration with the Kodi library for native Kodi speed Instant synchronization with the Emby server Full support for Movie, TV and Music collections Emby Server direct stream and transcoding support - use Kodi when you are away from home!</description>
<description lang="es">Bienvenido a Emby para Kodi una forma completamente nueva de gestionar y ver su biblioteca multimedia. El complemento Emby para Kodi combina lo mejor de Kodi - navegación ultra suave, interfaces hermosas de usuario y la reproducción de cualquier archivo bajo el sol, y Emby - el indexador y servidor de metadatos multimedia multicliente de código abierto más potente.&#10;&#10;Emby para Kodi es la mejor manera de disfrutar del increíble motor de reproducción de Kodi combinado con el poder de la base de datos centralizada de Emby. Características: Integración directa con la biblioteca de Kodi para una velocidad nativa de sincronización instantánea con el soporte completo del Servidor Emby para colecciones de películas, programas de TV y música. Emby Server soporta transcodificación y transmisión en directo - ¡Usa Kodi cuando estés fuera de casa!</description>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
</assets>
</extension>
</addon>
178 changes: 149 additions & 29 deletions context.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,165 @@
# -*- coding: utf-8 -*-

#################################################################################################

import json
import logging
import os
import sys

import xbmc
import xbmcaddon

#################################################################################################
import database.database
import dialogs.context
import emby.main
import helper.translate
import helper.utils
import helper.loghandler

class Context():
def __init__(self, play=False, transcode=False, delete=False):
helper.loghandler.reset()
helper.loghandler.config()
self.LOG = logging.getLogger("EMBY.context.Context")
self._selected_option = None
self.Utils = helper.utils.Utils()
self.server_id = None
self.kodi_id = None
self.media = None
self.XML_PATH = (xbmcaddon.Addon('plugin.video.emby-next-gen').getAddonInfo('path'), "default", "1080i")
self.OPTIONS = {
'Refresh': helper.translate._(30410),
'Delete': helper.translate._(30409),
'Addon': helper.translate._(30408),
'AddFav': helper.translate._(30405),
'RemoveFav': helper.translate._(30406),
'Transcode': helper.translate._(30412)
}

# try:
# self.kodi_id = max(sys.listitem.getVideoInfoTag().getDbId(), 0) or max(sys.listitem.getMusicInfoTag().getDbId(), 0) or None
# self.media = self.get_media_type()
# self.server_id = sys.listitem.getProperty('embyserver') or None
# item_id = sys.listitem.getProperty('embyid')
# except AttributeError:
if xbmc.getInfoLabel('ListItem.Property(embyid)'):
item_id = xbmc.getInfoLabel('ListItem.Property(embyid)')
else:
self.kodi_id = xbmc.getInfoLabel('ListItem.DBID')
self.media = xbmc.getInfoLabel('ListItem.DBTYPE')
item_id = None

ServerOnline = False

for i in range(60):
if self.Utils.window('emby_online.bool'):
ServerOnline = True
break

xbmc.sleep(500)

if not ServerOnline:
helper.loghandler.reset()
return

#Load server connection data
self.server = emby.main.Emby(self.server_id).get_client()
emby.main.Emby().set_state(self.Utils.window('emby.server.state.json'))

for server in self.Utils.window('emby.server.states.json') or []:
emby.main.Emby(server).set_state(self.Utils.window('emby.server.%s.state.json' % server))

if item_id:
self.item = self.server['api'].get_item(item_id)
else:
self.item = self.get_item_id()

if self.item:
if delete:
self.delete_item()

elif self.select_menu():
self.action_menu()

#Get media type based on sys.listitem. If unfilled, base on visible window
# def get_media_type(self):
# media = sys.listitem.getVideoInfoTag().getMediaType() or sys.listitem.getMusicInfoTag().getMediaType()

# if not media:
# if xbmc.getCondVisibility('Container.Content(albums)'):
# media = "album"
# elif xbmc.getCondVisibility('Container.Content(artists)'):
# media = "artist"
# elif xbmc.getCondVisibility('Container.Content(songs)'):
# media = "song"
# elif xbmc.getCondVisibility('Container.Content(pictures)'):
# media = "picture"
# else:
# self.LOG.info("media is unknown")

# return media.decode('utf-8')

#Get synced item from embydb
def get_item_id(self):
item = database.database.get_item(self.kodi_id, self.media)

if not item:
return {}

return {
'Id': item[0],
'UserData': json.loads(item[4]) if item[4] else {},
'Type': item[3]
}

#Display the select dialog.
#Favorites, Refresh, Delete (opt), Settings.
def select_menu(self):
options = []

if self.item['Type'] not in 'Season':
if self.item['UserData'].get('IsFavorite'):
options.append(self.OPTIONS['RemoveFav'])
else:
options.append(self.OPTIONS['AddFav'])

options.append(self.OPTIONS['Refresh'])

if self.Utils.settings('enableContextDelete.bool'):
options.append(self.OPTIONS['Delete'])

options.append(self.OPTIONS['Addon'])
context_menu = dialogs.context.ContextMenu("script-emby-context.xml", *self.XML_PATH)
context_menu.set_options(options)
context_menu.doModal()

__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
if context_menu.is_selected():
self._selected_option = context_menu.get_selected()

sys.path.insert(0, __cache__)
sys.path.insert(0, __pcache__)
sys.path.insert(0, __libraries__)
sys.path.append(__base__)
return self._selected_option

#################################################################################################
def action_menu(self):
selected = self.Utils.StringDecode(self._selected_option)

from entrypoint import Context
if selected == self.OPTIONS['Refresh']:
self.server['api'].refresh_item(self.item['Id'])

#################################################################################################
elif selected == self.OPTIONS['AddFav']:
self.server['api'].favorite(self.item['Id'], True)

LOG = logging.getLogger("EMBY.context")
elif selected == self.OPTIONS['RemoveFav']:
self.server['api'].favorite(self.item['Id'], False)

#################################################################################################
elif selected == self.OPTIONS['Addon']:
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby-next-gen)')

elif selected == self.OPTIONS['Delete']:
self.delete_item()

if __name__ == "__main__":
def delete_item(self):
delete = True

LOG.debug("--->[ context ]")
if not self.Utils.settings('skipContextMenu.bool'):
if not self.Utils.dialog("yesno", heading="{emby}", line1=helper.translate._(33015)):
delete = False

try:
Context()
except Exception as error:
LOG.exception(error)
if delete:
self.server['api'].delete_item(self.item['Id'])
self.Utils.event("LibraryChanged", {'ItemsRemoved': [self.item['Id']], 'ItemsVerify': [self.item['Id']], 'ItemsUpdated': [], 'ItemsAdded': []})

LOG.info("---<[ context ]")
if __name__ == "__main__":
Context()
45 changes: 0 additions & 45 deletions context_play.py

This file was deleted.

45 changes: 0 additions & 45 deletions context_transcode.py

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 8ba19ce

Please sign in to comment.