Skip to content

Commit

Permalink
Merge branch 'master' into remove_commented_code
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueTechy authored Dec 9, 2019
2 parents 109c107 + 19e7209 commit f7fdcd0
Show file tree
Hide file tree
Showing 28 changed files with 904 additions and 739 deletions.
4 changes: 2 additions & 2 deletions jellyfin_kodi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import xbmcaddon
import xbmcvfs

from helper import _, window, settings, addon_id, dialog
from helper import translate, window, settings, addon_id, dialog
from helper.utils import create_id

##################################################################################################
Expand Down Expand Up @@ -114,7 +114,7 @@ def reset_device_id():

window('jellyfin_deviceId', clear=True)
get_device_id(True)
dialog("ok", heading="{jellyfin}", line1=_(33033))
dialog("ok", heading="{jellyfin}", line1=translate(33033))
xbmc.executebuiltin('RestartApp')


Expand Down
14 changes: 7 additions & 7 deletions jellyfin_kodi/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import xbmcvfs

import jellyfin_db
from helper import _, settings, window, dialog
from helper import translate, settings, window, dialog
from objects import obj

#################################################################################################
Expand Down Expand Up @@ -215,7 +215,7 @@ def reset():
from views import Views
views = Views()

if not dialog("yesno", heading="{jellyfin}", line1=_(33074)):
if not dialog("yesno", heading="{jellyfin}", line1=translate(33074)):
return

window('jellyfin_should_stop.bool', True)
Expand All @@ -227,7 +227,7 @@ def reset():
count -= 1

if not count:
dialog("ok", heading="{jellyfin}", line1=_(33085))
dialog("ok", heading="{jellyfin}", line1=translate(33085))

return

Expand All @@ -239,12 +239,12 @@ def reset():
views.delete_playlists()
views.delete_nodes()

if dialog("yesno", heading="{jellyfin}", line1=_(33086)):
if dialog("yesno", heading="{jellyfin}", line1=translate(33086)):
reset_artwork()

addon_data = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')

if dialog("yesno", heading="{jellyfin}", line1=_(33087)):
if dialog("yesno", heading="{jellyfin}", line1=translate(33087)):

xbmcvfs.delete(os.path.join(addon_data, "settings.xml"))
xbmcvfs.delete(os.path.join(addon_data, "data.json"))
Expand All @@ -257,7 +257,7 @@ def reset():
settings('MinimumSetup', "")
settings('MusicRescan.bool', False)
settings('SyncInstallRunDone.bool', False)
dialog("ok", heading="{jellyfin}", line1=_(33088))
dialog("ok", heading="{jellyfin}", line1=translate(33088))
xbmc.executebuiltin('RestartApp')


Expand All @@ -272,7 +272,7 @@ def reset_kodi():
if name != 'version':
videodb.cursor.execute("DELETE FROM " + name)

if settings('enableMusic.bool') or dialog("yesno", heading="{jellyfin}", line1=_(33162)):
if settings('enableMusic.bool') or dialog("yesno", heading="{jellyfin}", line1=translate(33162)):

with Database('music') as musicdb:
musicdb.cursor.execute("SELECT tbl_name FROM sqlite_master WHERE type='table'")
Expand Down
6 changes: 3 additions & 3 deletions jellyfin_kodi/dialogs/loginmanual.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import xbmcgui
import xbmcaddon

from helper import _, addon_id
from helper import translate, addon_id

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

Expand Down Expand Up @@ -78,7 +78,7 @@ def onClick(self, control):

if not user:
# Display error
self._error(ERROR['Empty'], _('empty_user'))
self._error(ERROR['Empty'], translate('empty_user'))
LOG.error("Username cannot be null")

elif self._login(user, password):
Expand Down Expand Up @@ -121,7 +121,7 @@ def _login(self, username, password):
result = self.connect_manager.login(server, username, password)

if not result:
self._error(ERROR['Invalid'], _('invalid_auth'))
self._error(ERROR['Invalid'], translate('invalid_auth'))
return False
else:
self._user = result
Expand Down
6 changes: 3 additions & 3 deletions jellyfin_kodi/dialogs/serverconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xbmc
import xbmcgui

from helper import _
from helper import translate
from jellyfin.connection_manager import CONNECTION_STATE

##################################################################################################
Expand Down Expand Up @@ -110,7 +110,7 @@ def onClick(self, control):
def _connect_server(self, server_id):

server = self.connect_manager.get_server_info(server_id)
self.message.setLabel("%s %s..." % (_(30610), server['Name']))
self.message.setLabel("%s %s..." % (translate(30610), server['Name']))

self.message_box.setVisibleCondition('true')
self.busy.setVisibleCondition('true')
Expand All @@ -120,7 +120,7 @@ def _connect_server(self, server_id):
if result['State'] == CONNECTION_STATE['Unavailable']:
self.busy.setVisibleCondition('false')

self.message.setLabel(_(30609))
self.message.setLabel(translate(30609))
return False
else:
xbmc.sleep(1000)
Expand Down
8 changes: 4 additions & 4 deletions jellyfin_kodi/dialogs/servermanual.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import xbmcgui
import xbmcaddon

from helper import _, addon_id
from helper import translate, addon_id
from jellyfin.connection_manager import CONNECTION_STATE

##################################################################################################
Expand Down Expand Up @@ -77,7 +77,7 @@ def onClick(self, control):

if not server:
# Display error
self._error(ERROR['Empty'], _('empty_server'))
self._error(ERROR['Empty'], translate('empty_server'))
LOG.error("Server cannot be null")

elif self._connect_to_server(server):
Expand Down Expand Up @@ -116,11 +116,11 @@ def _connect_to_server(self, server):
if _IPV6_RE.match(server):
server = "[%s]" % (server)

self._message("%s %s..." % (_(30610), server))
self._message("%s %s..." % (translate(30610), server))
result = self.connect_manager.connect_to_address(server)

if result['State'] == CONNECTION_STATE['Unavailable']:
self._message(_(30609))
self._message(translate(30609))
return False
else:
self._server = result['Servers'][0]
Expand Down
16 changes: 8 additions & 8 deletions jellyfin_kodi/entrypoint/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@

import database
from dialogs import context
from helper import _, settings, dialog
from helper import translate, settings, dialog
from downloader import TheVoid

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

LOG = logging.getLogger("JELLYFIN." + __name__)
XML_PATH = (xbmcaddon.Addon('plugin.video.jellyfin').getAddonInfo('path'), "default", "1080i")
OPTIONS = {
'Refresh': _(30410),
'Delete': _(30409),
'Addon': _(30408),
'AddFav': _(30405),
'RemoveFav': _(30406),
'Transcode': _(30412)
'Refresh': translate(30410),
'Delete': translate(30409),
'Addon': translate(30408),
'AddFav': translate(30405),
'RemoveFav': translate(30406),
'Transcode': translate(30412)
}

#################################################################################################
Expand Down Expand Up @@ -163,7 +163,7 @@ def delete_item(self):

if not settings('skipContextMenu.bool'):

if not dialog("yesno", heading="{jellyfin}", line1=_(33015)):
if not dialog("yesno", heading="{jellyfin}", line1=translate(33015)):
delete = False

if delete:
Expand Down
70 changes: 35 additions & 35 deletions jellyfin_kodi/entrypoint/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from database import reset, get_sync, Database, jellyfin_db, get_credentials
from objects import Objects, Actions
from downloader import TheVoid
from helper import _, event, settings, window, dialog, api, JSONRPC
from helper import translate, event, settings, window, dialog, api, JSONRPC

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

Expand Down Expand Up @@ -146,14 +146,14 @@ def listing():
context = []

if view_id and node in ('movies', 'tvshows', 'musicvideos', 'music', 'mixed') and view_id not in whitelist:
label = "%s %s" % (label.decode('utf-8'), _(33166))
context.append((_(33123), "RunPlugin(plugin://plugin.video.jellyfin/?mode=synclib&id=%s)" % view_id))
label = "%s %s" % (label.decode('utf-8'), translate(33166))
context.append((translate(33123), "RunPlugin(plugin://plugin.video.jellyfin/?mode=synclib&id=%s)" % view_id))

if view_id and node in ('movies', 'tvshows', 'musicvideos', 'music') and view_id in whitelist:

context.append((_(33136), "RunPlugin(plugin://plugin.video.jellyfin/?mode=updatelib&id=%s)" % view_id))
context.append((_(33132), "RunPlugin(plugin://plugin.video.jellyfin/?mode=repairlib&id=%s)" % view_id))
context.append((_(33133), "RunPlugin(plugin://plugin.video.jellyfin/?mode=removelib&id=%s)" % view_id))
context.append((translate(33136), "RunPlugin(plugin://plugin.video.jellyfin/?mode=updatelib&id=%s)" % view_id))
context.append((translate(33132), "RunPlugin(plugin://plugin.video.jellyfin/?mode=repairlib&id=%s)" % view_id))
context.append((translate(33133), "RunPlugin(plugin://plugin.video.jellyfin/?mode=removelib&id=%s)" % view_id))

LOG.debug("--[ listing/%s/%s ] %s", node, label, path)

Expand All @@ -171,22 +171,22 @@ def listing():
context = []

if server.get('ManualAddress'):
context.append((_(33141), "RunPlugin(plugin://plugin.video.jellyfin/?mode=removeserver&server=%s)" % server['Id']))
context.append((translate(33141), "RunPlugin(plugin://plugin.video.jellyfin/?mode=removeserver&server=%s)" % server['Id']))

if 'AccessToken' not in server:
directory("%s (%s)" % (server['Name'], _(30539)), "plugin://plugin.video.jellyfin/?mode=login&server=%s" % server['Id'], False, context=context)
directory("%s (%s)" % (server['Name'], translate(30539)), "plugin://plugin.video.jellyfin/?mode=login&server=%s" % server['Id'], False, context=context)
else:
directory(server['Name'], "plugin://plugin.video.jellyfin/?mode=browse&server=%s" % server['Id'], context=context)

directory(_(33194), "plugin://plugin.video.jellyfin/?mode=managelibs", True)
directory(_(33134), "plugin://plugin.video.jellyfin/?mode=addserver", False)
directory(_(33054), "plugin://plugin.video.jellyfin/?mode=adduser", False)
directory(_(5), "plugin://plugin.video.jellyfin/?mode=settings", False)
directory(_(33058), "plugin://plugin.video.jellyfin/?mode=reset", False)
directory(_(33192), "plugin://plugin.video.jellyfin/?mode=restartservice", False)
directory(translate(33194), "plugin://plugin.video.jellyfin/?mode=managelibs", True)
directory(translate(33134), "plugin://plugin.video.jellyfin/?mode=addserver", False)
directory(translate(33054), "plugin://plugin.video.jellyfin/?mode=adduser", False)
directory(translate(5), "plugin://plugin.video.jellyfin/?mode=settings", False)
directory(translate(33058), "plugin://plugin.video.jellyfin/?mode=reset", False)
directory(translate(33192), "plugin://plugin.video.jellyfin/?mode=restartservice", False)

if settings('backupPath'):
directory(_(33092), "plugin://plugin.video.jellyfin/?mode=backup", False)
directory(translate(33092), "plugin://plugin.video.jellyfin/?mode=backup", False)

xbmcplugin.setContent(int(sys.argv[1]), 'files')
xbmcplugin.endOfDirectory(int(sys.argv[1]))
Expand Down Expand Up @@ -220,12 +220,12 @@ def dir_listitem(label, path, artwork=None, fanart=None):

def manage_libraries():

directory(_(33098), "plugin://plugin.video.jellyfin/?mode=refreshboxsets", False)
directory(_(33154), "plugin://plugin.video.jellyfin/?mode=addlibs", False)
directory(_(33139), "plugin://plugin.video.jellyfin/?mode=updatelibs", False)
directory(_(33140), "plugin://plugin.video.jellyfin/?mode=repairlibs", False)
directory(_(33184), "plugin://plugin.video.jellyfin/?mode=removelibs", False)
directory(_(33060), "plugin://plugin.video.jellyfin/?mode=thememedia", False)
directory(translate(33098), "plugin://plugin.video.jellyfin/?mode=refreshboxsets", False)
directory(translate(33154), "plugin://plugin.video.jellyfin/?mode=addlibs", False)
directory(translate(33139), "plugin://plugin.video.jellyfin/?mode=updatelibs", False)
directory(translate(33140), "plugin://plugin.video.jellyfin/?mode=repairlibs", False)
directory(translate(33184), "plugin://plugin.video.jellyfin/?mode=removelibs", False)
directory(translate(33060), "plugin://plugin.video.jellyfin/?mode=thememedia", False)

xbmcplugin.setContent(int(sys.argv[1]), 'files')
xbmcplugin.endOfDirectory(int(sys.argv[1]))
Expand Down Expand Up @@ -345,9 +345,9 @@ def browse(media, view_id=None, folder=None, server_id=None):
context.append(("Play", "RunPlugin(plugin://plugin.video.jellyfin/?mode=playlist&id=%s&server=%s)" % (item['Id'], server_id)))

if item['UserData']['Played']:
context.append((_(16104), "RunPlugin(plugin://plugin.video.jellyfin/?mode=unwatched&id=%s&server=%s)" % (item['Id'], server_id)))
context.append((translate(16104), "RunPlugin(plugin://plugin.video.jellyfin/?mode=unwatched&id=%s&server=%s)" % (item['Id'], server_id)))
else:
context.append((_(16103), "RunPlugin(plugin://plugin.video.jellyfin/?mode=watched&id=%s&server=%s)" % (item['Id'], server_id)))
context.append((translate(16103), "RunPlugin(plugin://plugin.video.jellyfin/?mode=watched&id=%s&server=%s)" % (item['Id'], server_id)))

li.addContextMenuItems(context)
list_li.append((path, li, True))
Expand All @@ -373,12 +373,12 @@ def browse(media, view_id=None, folder=None, server_id=None):
}
path = "%s?%s" % ("plugin://plugin.video.jellyfin/", urllib.urlencode(params))
li.setProperty('path', path)
context = [(_(13412), "RunPlugin(plugin://plugin.video.jellyfin/?mode=playlist&id=%s&server=%s)" % (item['Id'], server_id))]
context = [(translate(13412), "RunPlugin(plugin://plugin.video.jellyfin/?mode=playlist&id=%s&server=%s)" % (item['Id'], server_id))]

if item['UserData']['Played']:
context.append((_(16104), "RunPlugin(plugin://plugin.video.jellyfin/?mode=unwatched&id=%s&server=%s)" % (item['Id'], server_id)))
context.append((translate(16104), "RunPlugin(plugin://plugin.video.jellyfin/?mode=unwatched&id=%s&server=%s)" % (item['Id'], server_id)))
else:
context.append((_(16103), "RunPlugin(plugin://plugin.video.jellyfin/?mode=watched&id=%s&server=%s)" % (item['Id'], server_id)))
context.append((translate(16103), "RunPlugin(plugin://plugin.video.jellyfin/?mode=watched&id=%s&server=%s)" % (item['Id'], server_id)))

li.addContextMenuItems(context)

Expand Down Expand Up @@ -740,22 +740,22 @@ def add_user():
users = TheVoid('GetUsers', {'IsDisabled': False, 'IsHidden': False}).get()
current = session[0]['AdditionalUsers']

result = dialog("select", _(33061), [_(33062), _(33063)] if current else [_(33062)])
result = dialog("select", translate(33061), [translate(33062), translate(33063)] if current else [translate(33062)])

if result < 0:
return

if not result: # Add user
eligible = [x for x in users if x['Id'] not in [current_user['UserId'] for current_user in current]]
resp = dialog("select", _(33064), [x['Name'] for x in eligible])
resp = dialog("select", translate(33064), [x['Name'] for x in eligible])

if resp < 0:
return

user = eligible[resp]
event('AddUser', {'Id': user['Id'], 'Add': True})
else: # Remove user
resp = dialog("select", _(33064), [x['UserName'] for x in current])
resp = dialog("select", translate(33064), [x['UserName'] for x in current])

if resp < 0:
return
Expand Down Expand Up @@ -786,7 +786,7 @@ def get_themes():
tvtunes.setSetting('custom_path', library)
LOG.info("TV Tunes custom path is enabled and set.")
else:
dialog("ok", heading="{jellyfin}", line1=_(33152))
dialog("ok", heading="{jellyfin}", line1=translate(33152))

return

Expand Down Expand Up @@ -834,7 +834,7 @@ def get_themes():

tvtunes_nfo(nfo_file, paths)

dialog("notification", heading="{jellyfin}", message=_(33153), icon="{jellyfin}", time=1000, sound=False)
dialog("notification", heading="{jellyfin}", message=translate(33153), icon="{jellyfin}", time=1000, sound=False)


def delete_item():
Expand All @@ -854,15 +854,15 @@ def backup():

path = settings('backupPath')
folder_name = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2], xbmc.getInfoLabel('System.Date(dd-mm-yy)'))
folder_name = dialog("input", heading=_(33089), defaultt=folder_name)
folder_name = dialog("input", heading=translate(33089), defaultt=folder_name)

if not folder_name:
return

backup = os.path.join(path, folder_name)

if xbmcvfs.exists(backup + '/'):
if not dialog("yesno", heading="{jellyfin}", line1=_(33090)):
if not dialog("yesno", heading="{jellyfin}", line1=translate(33090)):

return backup()

Expand All @@ -875,7 +875,7 @@ def backup():
if not xbmcvfs.mkdirs(path) or not xbmcvfs.mkdirs(destination_databases):

LOG.info("Unable to create all directories")
dialog("notification", heading="{jellyfin}", icon="{jellyfin}", message=_(33165), sound=False)
dialog("notification", heading="{jellyfin}", icon="{jellyfin}", message=translate(33165), sound=False)

return

Expand All @@ -900,4 +900,4 @@ def backup():
LOG.info("copied %s", filename)

LOG.info("backup completed")
dialog("ok", heading="{jellyfin}", line1="%s %s" % (_(33091), backup))
dialog("ok", heading="{jellyfin}", line1="%s %s" % (translate(33091), backup))
Loading

0 comments on commit f7fdcd0

Please sign in to comment.