Code refactoring: put variables in one place
This commit is contained in:
parent
11be04ddac
commit
8aba0d998d
18 changed files with 403 additions and 409 deletions
|
@ -32,7 +32,7 @@ sys_path.append(_base_resource)
|
|||
###############################################################################
|
||||
|
||||
import entrypoint
|
||||
from utils import window, pickl_window, reset, passwordsXML
|
||||
from utils import window, pickl_window, reset, passwordsXML, language as lang
|
||||
from pickler import unpickle_me
|
||||
from PKC_listitem import convert_PKC_to_listitem
|
||||
|
||||
|
@ -172,7 +172,7 @@ class Main():
|
|||
if window('plex_online') != "true":
|
||||
# Server is not online, do not run the sync
|
||||
Dialog().ok(
|
||||
"PlexKodiConnect",
|
||||
lang(29999),
|
||||
"Unable to run the sync, the add-on is not connected "
|
||||
"to a Plex server.")
|
||||
log.error("Not connected to a PMS.")
|
||||
|
|
|
@ -48,17 +48,15 @@ import xbmcvfs
|
|||
import clientinfo
|
||||
import downloadutils
|
||||
from utils import window, settings, language as lang, tryDecode, tryEncode, \
|
||||
DateToKodi, KODILANGUAGE
|
||||
from PlexFunctions import PLEX_TO_KODI_TIMEFACTOR, PMSHttpsEnabled, \
|
||||
REMAP_TYPE_FROM_PLEXTYPE, PLEX_TYPE_MOVIE, PLEX_TYPE_SHOW, \
|
||||
PLEX_TYPE_EPISODE, KODI_SUPPORTED_IMAGES
|
||||
DateToKodi
|
||||
from PlexFunctions import PMSHttpsEnabled
|
||||
import plexdb_functions as plexdb
|
||||
import variables as v
|
||||
|
||||
###############################################################################
|
||||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
||||
addonName = 'PlexKodiConnect'
|
||||
REGEX_IMDB = re.compile(r'''/(tt\d+)''')
|
||||
REGEX_TVDB = re.compile(r'''tvdb://(\d+)''')
|
||||
###############################################################################
|
||||
|
@ -122,7 +120,7 @@ class PlexAPI():
|
|||
dialog = xbmcgui.Dialog()
|
||||
while retrievedPlexLogin == '' and plexLogin != '':
|
||||
# Enter plex.tv username. Or nothing to cancel.
|
||||
plexLogin = dialog.input(addonName + lang(39300),
|
||||
plexLogin = dialog.input(v.addonName + lang(39300),
|
||||
type=xbmcgui.INPUT_ALPHANUM)
|
||||
if plexLogin != "":
|
||||
# Enter password for plex.tv user
|
||||
|
@ -138,7 +136,7 @@ class PlexAPI():
|
|||
% (plexLogin, authtoken))
|
||||
if plexLogin == '':
|
||||
# Could not sign in user
|
||||
dialog.ok(addonName,
|
||||
dialog.ok(v.addonName,
|
||||
lang(39302) + plexLogin)
|
||||
# Write to Kodi settings file
|
||||
settings('plexLogin', value=retrievedPlexLogin)
|
||||
|
@ -164,11 +162,11 @@ class PlexAPI():
|
|||
dialog = xbmcgui.Dialog()
|
||||
if not code:
|
||||
# Problems trying to contact plex.tv. Try again later
|
||||
dialog.ok(addonName, lang(39303))
|
||||
dialog.ok(v.addonName, lang(39303))
|
||||
return False
|
||||
# Go to https://plex.tv/pin and enter the code:
|
||||
# Or press No to cancel the sign in.
|
||||
answer = dialog.yesno(addonName,
|
||||
answer = dialog.yesno(v.addonName,
|
||||
lang(39304) + "\n\n",
|
||||
code + "\n\n",
|
||||
lang(39311))
|
||||
|
@ -185,7 +183,7 @@ class PlexAPI():
|
|||
count += 1
|
||||
if xml is False:
|
||||
# Could not sign in to plex.tv Try again later
|
||||
dialog.ok(addonName, lang(39305))
|
||||
dialog.ok(v.addonName, lang(39305))
|
||||
return False
|
||||
# Parse xml
|
||||
userid = xml.attrib.get('id')
|
||||
|
@ -830,7 +828,7 @@ class PlexAPI():
|
|||
if usernumber > 1:
|
||||
# Select user
|
||||
user_select = dialog.select(
|
||||
addonName + lang(39306),
|
||||
v.addonName + lang(39306),
|
||||
userlistCoded)
|
||||
if user_select == -1:
|
||||
log.info("No user selected.")
|
||||
|
@ -873,7 +871,7 @@ class PlexAPI():
|
|||
else:
|
||||
trials += 1
|
||||
# Could not login user, please try again
|
||||
if not dialog.yesno(addonName,
|
||||
if not dialog.yesno(v.addonName,
|
||||
lang(39308) + selected_user,
|
||||
lang(39309)):
|
||||
# User chose to cancel
|
||||
|
@ -1530,8 +1528,8 @@ class API():
|
|||
except (KeyError, ValueError):
|
||||
resume = 0.0
|
||||
|
||||
runtime = int(runtime * PLEX_TO_KODI_TIMEFACTOR)
|
||||
resume = int(resume * PLEX_TO_KODI_TIMEFACTOR)
|
||||
runtime = int(runtime * v.PLEX_TO_KODI_TIMEFACTOR)
|
||||
resume = int(resume * v.PLEX_TO_KODI_TIMEFACTOR)
|
||||
return resume, runtime
|
||||
|
||||
def getMpaa(self):
|
||||
|
@ -1751,7 +1749,7 @@ class API():
|
|||
'key': key,
|
||||
'title': title,
|
||||
'thumb': thumb,
|
||||
'duration': int(duration * PLEX_TO_KODI_TIMEFACTOR),
|
||||
'duration': int(duration * v.PLEX_TO_KODI_TIMEFACTOR),
|
||||
'extraType': extraType,
|
||||
'originallyAvailableAt': originallyAvailableAt,
|
||||
'year': year
|
||||
|
@ -1923,9 +1921,9 @@ class API():
|
|||
# Return the saved Plex id's, if applicable
|
||||
# Always seek collection's ids since not provided by PMS
|
||||
if collection is False:
|
||||
if media_type == PLEX_TYPE_MOVIE:
|
||||
if media_type == v.PLEX_TYPE_MOVIE:
|
||||
mediaId = self.getProvider('imdb')
|
||||
elif media_type == PLEX_TYPE_SHOW:
|
||||
elif media_type == v.PLEX_TYPE_SHOW:
|
||||
mediaId = self.getProvider('tvdb')
|
||||
if mediaId is not None:
|
||||
return mediaId
|
||||
|
@ -1935,7 +1933,7 @@ class API():
|
|||
log.info('Start movie set/collection lookup on themoviedb')
|
||||
|
||||
apiKey = settings('themoviedbAPIKey')
|
||||
if media_type == PLEX_TYPE_SHOW:
|
||||
if media_type == v.PLEX_TYPE_SHOW:
|
||||
media_type = 'tv'
|
||||
title = item.get('title', '')
|
||||
# if the title has the year in remove it as tmdb cannot deal with it...
|
||||
|
@ -1944,7 +1942,7 @@ class API():
|
|||
url = 'http://api.themoviedb.org/3/search/%s' % media_type
|
||||
parameters = {
|
||||
'api_key': apiKey,
|
||||
'language': KODILANGUAGE,
|
||||
'language': v.KODILANGUAGE,
|
||||
'query': tryEncode(title)
|
||||
}
|
||||
data = downloadutils.DownloadUtils().downloadUrl(
|
||||
|
@ -2030,7 +2028,7 @@ class API():
|
|||
parameters = {
|
||||
'api_key': apiKey
|
||||
}
|
||||
for language in [KODILANGUAGE, "en"]:
|
||||
for language in [v.KODILANGUAGE, "en"]:
|
||||
parameters['language'] = language
|
||||
if media_type == "movie":
|
||||
url = 'http://api.themoviedb.org/3/movie/%s' % tmdbId
|
||||
|
@ -2130,7 +2128,7 @@ class API():
|
|||
continue
|
||||
# select image in preferred language
|
||||
for entry in data[fanarttvimage]:
|
||||
if entry.get("lang") == KODILANGUAGE:
|
||||
if entry.get("lang") == v.KODILANGUAGE:
|
||||
allartworks[fanarttype[1]] = entry.get("url", "").replace(' ', '%20')
|
||||
break
|
||||
# just grab the first english OR undefinded one as fallback
|
||||
|
@ -2368,7 +2366,7 @@ class API():
|
|||
listItem.setProperty('IsPlayable', 'true')
|
||||
extension = self.item[0][0].attrib['key'][self.item[0][0].attrib['key'].rfind('.'):].lower()
|
||||
if (window('plex_force_transcode_pix') == 'true' or
|
||||
extension not in KODI_SUPPORTED_IMAGES):
|
||||
extension not in v.KODI_SUPPORTED_IMAGES):
|
||||
# Let Plex transcode
|
||||
# max width/height supported by plex image transcoder is 1920x1080
|
||||
path = self.server + PlexAPI().getTranscodeImagePath(
|
||||
|
@ -2531,7 +2529,7 @@ class API():
|
|||
"""
|
||||
if path is None:
|
||||
return None
|
||||
typus = REMAP_TYPE_FROM_PLEXTYPE[typus]
|
||||
typus = v.REMAP_TYPE_FROM_PLEXTYPE[typus]
|
||||
if window('remapSMB') == 'true':
|
||||
path = path.replace(window('remapSMB%sOrg' % typus),
|
||||
window('remapSMB%sNew' % typus),
|
||||
|
@ -2581,7 +2579,7 @@ class API():
|
|||
"""
|
||||
log.warn('Cannot access file: %s' % url)
|
||||
resp = xbmcgui.Dialog().yesno(
|
||||
heading=addonName,
|
||||
heading=v.addonName,
|
||||
line1=lang(39031) + url,
|
||||
line2=lang(39032))
|
||||
return resp
|
||||
|
@ -2640,7 +2638,7 @@ class API():
|
|||
window('%s.itemid' % plexitem, value=self.getRatingKey())
|
||||
window('%s.playcount' % plexitem, value=str(userdata['PlayCount']))
|
||||
|
||||
if itemtype == PLEX_TYPE_EPISODE:
|
||||
if itemtype == v.PLEX_TYPE_EPISODE:
|
||||
window('%s.refreshid' % plexitem, value=self.getParentRatingKey())
|
||||
else:
|
||||
window('%s.refreshid' % plexitem, value=self.getRatingKey())
|
||||
|
|
|
@ -8,161 +8,14 @@ from copy import deepcopy
|
|||
|
||||
import downloadutils
|
||||
from utils import settings
|
||||
from variables import PLEX_TO_KODI_TIMEFACTOR
|
||||
|
||||
###############################################################################
|
||||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
||||
addonName = 'PlexKodiConnect'
|
||||
|
||||
###############################################################################
|
||||
|
||||
# Multiply Plex time by this factor to receive Kodi time
|
||||
PLEX_TO_KODI_TIMEFACTOR = 1.0 / 1000.0
|
||||
|
||||
|
||||
# All the Plex types as communicated in the PMS xml replies
|
||||
PLEX_TYPE_VIDEO = 'video'
|
||||
PLEX_TYPE_MOVIE = 'movie'
|
||||
PLEX_TYPE_CLIP = 'clip' # e.g. trailers
|
||||
|
||||
PLEX_TYPE_EPISODE = 'episode'
|
||||
PLEX_TYPE_SEASON = 'season'
|
||||
PLEX_TYPE_SHOW = 'show'
|
||||
|
||||
PLEX_TYPE_AUDIO = 'music'
|
||||
PLEX_TYPE_SONG = 'track'
|
||||
PLEX_TYPE_ALBUM = 'album'
|
||||
PLEX_TYPE_ARTIST = 'artist'
|
||||
|
||||
PLEX_TYPE_PHOTO = 'photo'
|
||||
|
||||
|
||||
# All the Kodi types as e.g. used in the JSON API
|
||||
KODI_TYPE_VIDEO = 'video'
|
||||
KODI_TYPE_MOVIE = 'movie'
|
||||
KODI_TYPE_SET = 'set' # for movie sets of several movies
|
||||
KODI_TYPE_CLIP = 'clip' # e.g. trailers
|
||||
|
||||
KODI_TYPE_EPISODE = 'episode'
|
||||
KODI_TYPE_SEASON = 'season'
|
||||
KODI_TYPE_SHOW = 'tvshow'
|
||||
|
||||
KODI_TYPE_AUDIO = 'audio'
|
||||
KODI_TYPE_SONG = 'song'
|
||||
KODI_TYPE_ALBUM = 'album'
|
||||
KODI_TYPE_ARTIST = 'artist'
|
||||
|
||||
KODI_TYPE_PHOTO = 'photo'
|
||||
|
||||
|
||||
# Translation tables
|
||||
|
||||
KODI_VIDEOTYPES = (
|
||||
KODI_TYPE_VIDEO,
|
||||
KODI_TYPE_MOVIE,
|
||||
KODI_TYPE_SHOW,
|
||||
KODI_TYPE_SEASON,
|
||||
KODI_TYPE_EPISODE,
|
||||
KODI_TYPE_SET
|
||||
)
|
||||
|
||||
KODI_AUDIOTYPES = (
|
||||
KODI_TYPE_SONG,
|
||||
KODI_TYPE_ALBUM,
|
||||
KODI_TYPE_ARTIST,
|
||||
)
|
||||
|
||||
ITEMTYPE_FROM_PLEXTYPE = {
|
||||
PLEX_TYPE_MOVIE: 'Movies',
|
||||
PLEX_TYPE_SEASON: 'TVShows',
|
||||
KODI_TYPE_EPISODE: 'TVShows',
|
||||
PLEX_TYPE_SHOW: 'TVShows',
|
||||
PLEX_TYPE_ARTIST: 'Music',
|
||||
PLEX_TYPE_ALBUM: 'Music',
|
||||
PLEX_TYPE_SONG: 'Music',
|
||||
}
|
||||
|
||||
ITEMTYPE_FROM_KODITYPE = {
|
||||
KODI_TYPE_MOVIE: 'Movies',
|
||||
KODI_TYPE_SEASON: 'TVShows',
|
||||
KODI_TYPE_EPISODE: 'TVShows',
|
||||
KODI_TYPE_SHOW: 'TVShows',
|
||||
KODI_TYPE_ARTIST: 'Music',
|
||||
KODI_TYPE_ALBUM: 'Music',
|
||||
KODI_TYPE_SONG: 'Music',
|
||||
}
|
||||
|
||||
KODITYPE_FROM_PLEXTYPE = {
|
||||
PLEX_TYPE_MOVIE: KODI_TYPE_MOVIE,
|
||||
PLEX_TYPE_EPISODE: KODI_TYPE_EPISODE,
|
||||
PLEX_TYPE_SEASON: KODI_TYPE_SEASON,
|
||||
PLEX_TYPE_SHOW: KODI_TYPE_SHOW,
|
||||
PLEX_TYPE_SONG: KODI_TYPE_SONG,
|
||||
PLEX_TYPE_ARTIST: KODI_TYPE_ARTIST,
|
||||
PLEX_TYPE_ALBUM: KODI_TYPE_ALBUM,
|
||||
PLEX_TYPE_PHOTO: KODI_TYPE_PHOTO,
|
||||
'XXXXXX': 'musicvideo',
|
||||
'XXXXXXX': 'genre'
|
||||
}
|
||||
|
||||
KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE = {
|
||||
PLEX_TYPE_VIDEO: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_MOVIE: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_EPISODE: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_SEASON: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_SHOW: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_CLIP: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_ARTIST: KODI_TYPE_AUDIO,
|
||||
PLEX_TYPE_ALBUM: KODI_TYPE_AUDIO,
|
||||
PLEX_TYPE_SONG: KODI_TYPE_AUDIO,
|
||||
PLEX_TYPE_AUDIO: KODI_TYPE_AUDIO
|
||||
}
|
||||
|
||||
|
||||
REMAP_TYPE_FROM_PLEXTYPE = {
|
||||
PLEX_TYPE_MOVIE: 'movie',
|
||||
PLEX_TYPE_CLIP: 'clip',
|
||||
PLEX_TYPE_SHOW: 'tv',
|
||||
PLEX_TYPE_SEASON: 'tv',
|
||||
PLEX_TYPE_EPISODE: 'tv',
|
||||
PLEX_TYPE_ARTIST: 'music',
|
||||
PLEX_TYPE_ALBUM: 'music',
|
||||
PLEX_TYPE_SONG: 'music',
|
||||
PLEX_TYPE_PHOTO: 'photo'
|
||||
}
|
||||
|
||||
|
||||
REMAP_TYPE_FROM_PLEXTYPE = {
|
||||
'movie': 'movie',
|
||||
'show': 'tv',
|
||||
'season': 'tv',
|
||||
'episode': 'tv',
|
||||
'artist': 'music',
|
||||
'album': 'music',
|
||||
'song': 'music',
|
||||
'track': 'music',
|
||||
'clip': 'clip',
|
||||
'photo': 'photo'
|
||||
}
|
||||
|
||||
|
||||
# extensions from:
|
||||
# http://kodi.wiki/view/Features_and_supported_codecs#Format_support (RAW image
|
||||
# formats, BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX and Targa/TGA)
|
||||
KODI_SUPPORTED_IMAGES = (
|
||||
'.bmp',
|
||||
'.jpg',
|
||||
'.jpeg',
|
||||
'.gif',
|
||||
'.png',
|
||||
'.tiff',
|
||||
'.mng',
|
||||
'.ico',
|
||||
'.pcx',
|
||||
'.tga'
|
||||
)
|
||||
|
||||
|
||||
def ConvertPlexToKodiTime(plexTime):
|
||||
"""
|
||||
|
|
|
@ -7,15 +7,15 @@ import logging
|
|||
import xbmc
|
||||
import xbmcaddon
|
||||
|
||||
import PlexFunctions as PF
|
||||
import plexdb_functions as plexdb
|
||||
from utils import window, settings, dialog, language as lang, kodiSQL
|
||||
from dialogs import context
|
||||
from PlexFunctions import delete_item_from_pms
|
||||
import variables as v
|
||||
|
||||
###############################################################################
|
||||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
addonName = 'PlexKodiConnect'
|
||||
|
||||
OPTIONS = {
|
||||
'Refresh': lang(30410),
|
||||
|
@ -89,10 +89,10 @@ class ContextMenu(object):
|
|||
|
||||
# if user uses direct paths, give option to initiate playback via PMS
|
||||
if (window('useDirectPaths') == 'true' and
|
||||
self.item_type in PF.KODI_VIDEOTYPES):
|
||||
self.item_type in v.KODI_VIDEOTYPES):
|
||||
options.append(OPTIONS['PMS_Play'])
|
||||
|
||||
if self.item_type in PF.KODI_VIDEOTYPES:
|
||||
if self.item_type in v.KODI_VIDEOTYPES:
|
||||
options.append(OPTIONS['Transcode'])
|
||||
|
||||
# userdata = self.api.getUserData()
|
||||
|
@ -191,14 +191,14 @@ class ContextMenu(object):
|
|||
delete = True
|
||||
if settings('skipContextMenu') != "true":
|
||||
|
||||
if not dialog(type_="yesno", heading=addonName, line1=lang(33041)):
|
||||
if not dialog("yesno", heading=v.addonName, line1=lang(33041)):
|
||||
log.info("User skipped deletion for: %s", self.item_id)
|
||||
delete = False
|
||||
|
||||
if delete:
|
||||
log.info("Deleting Plex item with id %s", self.item_id)
|
||||
if PF.delete_item_from_pms(self.item_id) is False:
|
||||
dialog(type_="ok", heading="{plex}", line1=lang(30414))
|
||||
if delete_item_from_pms(self.item_id) is False:
|
||||
dialog("ok", heading="{plex}", line1=lang(30414))
|
||||
|
||||
def _PMS_play(self):
|
||||
"""
|
||||
|
|
|
@ -8,7 +8,7 @@ import xml.etree.ElementTree as etree
|
|||
|
||||
import xbmcgui
|
||||
|
||||
from utils import settings, window
|
||||
from utils import settings, window, language as lang
|
||||
import clientinfo
|
||||
|
||||
###############################################################################
|
||||
|
@ -18,7 +18,6 @@ import requests.packages.urllib3
|
|||
requests.packages.urllib3.disable_warnings()
|
||||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
addonName = 'PlexKodiConnect'
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -283,7 +282,7 @@ class DownloadUtils():
|
|||
'unauthorized')
|
||||
window('plex_serverStatus', value="401")
|
||||
xbmcgui.Dialog().notification(
|
||||
addonName,
|
||||
lang(29999),
|
||||
"Unauthorized for PMS",
|
||||
xbmcgui.NOTIFICATION_ERROR)
|
||||
else:
|
||||
|
|
|
@ -24,13 +24,12 @@ import PlexFunctions
|
|||
import PlexAPI
|
||||
from PKC_listitem import convert_PKC_to_listitem
|
||||
from playqueue import Playqueue
|
||||
import variables as v
|
||||
|
||||
###############################################################################
|
||||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
||||
addonName = "PlexKodiConnect"
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
@ -66,7 +65,7 @@ def chooseServer():
|
|||
log.info("Choosing new PMS complete")
|
||||
# '<PMS> connected'
|
||||
xbmcgui.Dialog().notification(
|
||||
heading=addonName,
|
||||
heading=lang(29999),
|
||||
message='%s %s' % (server['name'], lang(39220)),
|
||||
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
||||
time=3000,
|
||||
|
@ -90,7 +89,7 @@ def togglePlexTV():
|
|||
import initialsetup
|
||||
initialsetup.InitialSetup().PlexTVSignIn()
|
||||
xbmcgui.Dialog().notification(
|
||||
heading=addonName,
|
||||
heading=lang(29999),
|
||||
message=lang(39221),
|
||||
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
||||
time=3000,
|
||||
|
@ -114,14 +113,14 @@ def Plex_Node(url, viewOffset, plex_type, playdirectly=False):
|
|||
return
|
||||
if viewOffset != '0':
|
||||
try:
|
||||
viewOffset = int(PlexFunctions.PLEX_TO_KODI_TIMEFACTOR *
|
||||
viewOffset = int(v.PLEX_TO_KODI_TIMEFACTOR *
|
||||
float(viewOffset))
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
window('plex_customplaylist.seektime', value=str(viewOffset))
|
||||
log.info('Set resume point to %s' % str(viewOffset))
|
||||
typus = PlexFunctions.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[plex_type]
|
||||
typus = v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[plex_type]
|
||||
playqueue = Playqueue().get_playqueue_from_type(typus)
|
||||
result = pbutils.PlaybackUtils(xml, playqueue).play(
|
||||
None,
|
||||
|
@ -209,12 +208,12 @@ def resetDeviceId():
|
|||
deviceId = clientinfo.ClientInfo().getDeviceId(reset=True)
|
||||
except Exception as e:
|
||||
log.error("Failed to generate a new device Id: %s" % e)
|
||||
dialog.ok(heading=addonName, line1=lang(33032))
|
||||
dialog.ok(heading=lang(29999), line1=lang(33032))
|
||||
else:
|
||||
log.info("Successfully removed old deviceId: %s New deviceId: %s"
|
||||
% (deviceId_old, deviceId))
|
||||
# "Kodi will now restart to apply the changes"
|
||||
dialog.ok(heading=addonName, line1=lang(33033))
|
||||
dialog.ok(heading=lang(29999), line1=lang(33033))
|
||||
xbmc.executebuiltin('RestartApp')
|
||||
|
||||
|
||||
|
@ -864,7 +863,7 @@ def getExtraFanArt(plexid, plexPath):
|
|||
def RunLibScan(mode):
|
||||
if window('plex_online') != "true":
|
||||
# Server is not online, do not run the sync
|
||||
xbmcgui.Dialog().ok(heading=addonName,
|
||||
xbmcgui.Dialog().ok(heading=lang(29999),
|
||||
line1=lang(39205))
|
||||
else:
|
||||
window('plex_runLibScan', value='full')
|
||||
|
@ -1157,7 +1156,7 @@ def enterPMS():
|
|||
"""
|
||||
dialog = xbmcgui.Dialog()
|
||||
# "Enter your Plex Media Server's IP or URL. Examples are:"
|
||||
dialog.ok(addonName,
|
||||
dialog.ok(lang(29999),
|
||||
lang(39215),
|
||||
'192.168.1.2',
|
||||
'plex.myServer.org')
|
||||
|
@ -1170,7 +1169,7 @@ def enterPMS():
|
|||
url = '%s:%s' % (ip, port)
|
||||
# "Does your Plex Media Server support SSL connections?
|
||||
# (https instead of http)"
|
||||
https = dialog.yesno(addonName, lang(39217))
|
||||
https = dialog.yesno(lang(29999), lang(39217))
|
||||
if https:
|
||||
url = 'https://%s' % url
|
||||
else:
|
||||
|
@ -1181,7 +1180,7 @@ def enterPMS():
|
|||
if machineIdentifier is None:
|
||||
# "Error contacting url
|
||||
# Abort (Yes) or save address anyway (No)"
|
||||
if dialog.yesno(addonName, '%s %s. %s'
|
||||
if dialog.yesno(lang(29999), '%s %s. %s'
|
||||
% (lang(39218), url, lang(39219))):
|
||||
return
|
||||
else:
|
||||
|
@ -1226,7 +1225,7 @@ def __LogOut():
|
|||
dialog = xbmcgui.Dialog()
|
||||
# Resetting, please wait
|
||||
dialog.notification(
|
||||
heading=addonName,
|
||||
heading=lang(29999),
|
||||
message=lang(39207),
|
||||
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
||||
time=3000,
|
||||
|
@ -1238,7 +1237,7 @@ def __LogOut():
|
|||
while window('plex_dbScan') == 'true':
|
||||
if counter > 200:
|
||||
# Failed to reset PMS and plex.tv connects. Try to restart Kodi.
|
||||
dialog.ok(addonName, lang(39208))
|
||||
dialog.ok(lang(29999), lang(39208))
|
||||
# Resuming threads, just in case
|
||||
window('suspend_LibraryThread', clear=True)
|
||||
log.error("Could not stop library sync, aborting")
|
||||
|
@ -1254,7 +1253,7 @@ def __LogOut():
|
|||
while window('plex_serverStatus') == "401":
|
||||
if counter > 100:
|
||||
# 'Failed to reset PKC. Try to restart Kodi.'
|
||||
dialog.ok(addonName, lang(39208))
|
||||
dialog.ok(lang(29999), lang(39208))
|
||||
log.error("Could not sign out user, aborting")
|
||||
return False
|
||||
counter += 1
|
||||
|
|
|
@ -18,8 +18,6 @@ from PlexFunctions import GetMachineIdentifier, get_PMS_settings
|
|||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
||||
addonName = 'PlexKodiConnect'
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
@ -75,13 +73,13 @@ class InitialSetup():
|
|||
settings('plexToken', value='')
|
||||
settings('plexLogin', value='')
|
||||
# Could not login, please try again
|
||||
self.dialog.ok(addonName, lang(39009))
|
||||
self.dialog.ok(lang(29999), lang(39009))
|
||||
answer = self.PlexTVSignIn()
|
||||
elif chk is False or chk >= 400:
|
||||
# Problems connecting to plex.tv. Network or internet issue?
|
||||
log.info('Problems connecting to plex.tv; connection returned '
|
||||
'HTTP %s' % str(chk))
|
||||
self.dialog.ok(addonName, lang(39010))
|
||||
self.dialog.ok(lang(29999), lang(39010))
|
||||
answer = False
|
||||
else:
|
||||
log.info('plex.tv connection with token successful')
|
||||
|
@ -260,7 +258,7 @@ class InitialSetup():
|
|||
else:
|
||||
log.warn('Not authorized even though we are signed '
|
||||
' in to plex.tv correctly')
|
||||
self.dialog.ok(addonName, '%s %s'
|
||||
self.dialog.ok(lang(29999), '%s %s'
|
||||
% lang(39214) + server['name'])
|
||||
return
|
||||
else:
|
||||
|
@ -287,7 +285,7 @@ class InitialSetup():
|
|||
# Exit if no servers found
|
||||
if len(serverlist) == 0:
|
||||
log.warn('No plex media servers found!')
|
||||
self.dialog.ok(addonName, lang(39011))
|
||||
self.dialog.ok(lang(29999), lang(39011))
|
||||
return
|
||||
# Get a nicer list
|
||||
dialoglist = []
|
||||
|
@ -323,7 +321,7 @@ class InitialSetup():
|
|||
log.warn('Not yet authorized for Plex server %s'
|
||||
% server['name'])
|
||||
# Please sign in to plex.tv
|
||||
self.dialog.ok(addonName,
|
||||
self.dialog.ok(lang(29999),
|
||||
lang(39013) + server['name'],
|
||||
lang(39014))
|
||||
if self.PlexTVSignIn() is False:
|
||||
|
@ -332,7 +330,7 @@ class InitialSetup():
|
|||
# Problems connecting
|
||||
elif chk >= 400 or chk is False:
|
||||
# Problems connecting to server. Pick another server?
|
||||
answ = self.dialog.yesno(addonName,
|
||||
answ = self.dialog.yesno(lang(29999),
|
||||
lang(39015))
|
||||
# Exit while loop if user chooses No
|
||||
if not answ:
|
||||
|
@ -435,7 +433,7 @@ class InitialSetup():
|
|||
# Additional settings where the user needs to choose
|
||||
# Direct paths (\\NAS\mymovie.mkv) or addon (http)?
|
||||
goToSettings = False
|
||||
if dialog.yesno(addonName,
|
||||
if dialog.yesno(lang(29999),
|
||||
lang(39027),
|
||||
lang(39028),
|
||||
nolabel="Addon (Default)",
|
||||
|
@ -444,29 +442,29 @@ class InitialSetup():
|
|||
settings('useDirectPaths', value="1")
|
||||
# Are you on a system where you would like to replace paths
|
||||
# \\NAS\mymovie.mkv with smb://NAS/mymovie.mkv? (e.g. Windows)
|
||||
if dialog.yesno(heading=addonName, line1=lang(39033)):
|
||||
if dialog.yesno(heading=lang(29999), line1=lang(39033)):
|
||||
log.debug("User chose to replace paths with smb")
|
||||
else:
|
||||
settings('replaceSMB', value="false")
|
||||
|
||||
# complete replace all original Plex library paths with custom SMB
|
||||
if dialog.yesno(heading=addonName, line1=lang(39043)):
|
||||
if dialog.yesno(heading=lang(29999), line1=lang(39043)):
|
||||
log.debug("User chose custom smb paths")
|
||||
settings('remapSMB', value="true")
|
||||
# Please enter your custom smb paths in the settings under
|
||||
# "Sync Options" and then restart Kodi
|
||||
dialog.ok(heading=addonName, line1=lang(39044))
|
||||
dialog.ok(heading=lang(29999), line1=lang(39044))
|
||||
goToSettings = True
|
||||
|
||||
# Go to network credentials?
|
||||
if dialog.yesno(heading=addonName,
|
||||
if dialog.yesno(heading=lang(29999),
|
||||
line1=lang(39029),
|
||||
line2=lang(39030)):
|
||||
log.debug("Presenting network credentials dialog.")
|
||||
from utils import passwordsXML
|
||||
passwordsXML()
|
||||
# Disable Plex music?
|
||||
if dialog.yesno(heading=addonName, line1=lang(39016)):
|
||||
if dialog.yesno(heading=lang(29999), line1=lang(39016)):
|
||||
log.debug("User opted to disable Plex music library.")
|
||||
settings('enableMusic', value="false")
|
||||
else:
|
||||
|
@ -474,26 +472,26 @@ class InitialSetup():
|
|||
advancedSettingsXML()
|
||||
|
||||
# Download additional art from FanArtTV
|
||||
if dialog.yesno(heading=addonName, line1=lang(39061)):
|
||||
if dialog.yesno(heading=lang(29999), line1=lang(39061)):
|
||||
log.debug("User opted to use FanArtTV")
|
||||
settings('FanartTV', value="true")
|
||||
|
||||
# If you use several Plex libraries of one kind, e.g. "Kids Movies" and
|
||||
# "Parents Movies", be sure to check https://goo.gl/JFtQV9
|
||||
dialog.ok(heading=addonName, line1=lang(39076))
|
||||
dialog.ok(heading=lang(29999), line1=lang(39076))
|
||||
# Make sure that we only ask these questions upon first installation
|
||||
settings('InstallQuestionsAnswered', value='true')
|
||||
|
||||
if goToSettings is False:
|
||||
# Open Settings page now? You will need to restart!
|
||||
goToSettings = dialog.yesno(heading=addonName, line1=lang(39017))
|
||||
goToSettings = dialog.yesno(heading=lang(29999), line1=lang(39017))
|
||||
if goToSettings:
|
||||
window('plex_serverStatus', value="Stop")
|
||||
xbmc.executebuiltin(
|
||||
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||
else:
|
||||
# "Kodi will now restart to apply the changes"
|
||||
dialog.ok(heading=addonName, line1=lang(33033))
|
||||
dialog.ok(heading=lang(29999), line1=lang(33033))
|
||||
xbmc.executebuiltin('RestartApp')
|
||||
# We should always restart to ensure e.g. Kodi settings for Music
|
||||
# are in use!
|
||||
|
|
|
@ -14,7 +14,8 @@ import plexdb_functions as plexdb
|
|||
import kodidb_functions as kodidb
|
||||
|
||||
import PlexAPI
|
||||
import PlexFunctions as PF
|
||||
from PlexFunctions import GetPlexMetadata
|
||||
import variables as v
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -73,13 +74,13 @@ class Items(object):
|
|||
mediaType,
|
||||
self.kodicursor)
|
||||
# Also get artwork for collections/movie sets
|
||||
if mediaType == PF.KODI_TYPE_MOVIE:
|
||||
if mediaType == v.KODI_TYPE_MOVIE:
|
||||
for setname in API.getCollections():
|
||||
log.debug('Getting artwork for movie set %s' % setname)
|
||||
setid = self.kodi_db.createBoxset(setname)
|
||||
self.artwork.addArtwork(API.getSetArtwork(),
|
||||
setid,
|
||||
PF.KODI_TYPE_SET,
|
||||
v.KODI_TYPE_SET,
|
||||
self.kodicursor)
|
||||
self.kodi_db.assignBoxset(setid, kodiId)
|
||||
|
||||
|
@ -271,7 +272,7 @@ class Movies(Items):
|
|||
# update new ratings Kodi 17
|
||||
ratingid = self.kodi_db.get_ratingid(movieid)
|
||||
self.kodi_db.update_ratings(movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
v.KODI_TYPE_MOVIE,
|
||||
"default",
|
||||
rating,
|
||||
votecount,
|
||||
|
@ -279,7 +280,7 @@ class Movies(Items):
|
|||
# update new uniqueid Kodi 17
|
||||
uniqueid = self.kodi_db.get_uniqueid(movieid)
|
||||
self.kodi_db.update_uniqueid(movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
v.KODI_TYPE_MOVIE,
|
||||
imdb,
|
||||
"imdb",
|
||||
uniqueid)
|
||||
|
@ -319,7 +320,7 @@ class Movies(Items):
|
|||
ratingid = self.kodi_db.create_entry_rating()
|
||||
self.kodi_db.add_ratings(ratingid,
|
||||
movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
v.KODI_TYPE_MOVIE,
|
||||
"default",
|
||||
rating,
|
||||
votecount)
|
||||
|
@ -327,7 +328,7 @@ class Movies(Items):
|
|||
uniqueid = self.kodi_db.create_entry_uniqueid()
|
||||
self.kodi_db.add_uniqueid(uniqueid,
|
||||
movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
v.KODI_TYPE_MOVIE,
|
||||
imdb,
|
||||
"imdb")
|
||||
|
||||
|
@ -365,9 +366,9 @@ class Movies(Items):
|
|||
# idempotent; the call here updates also fileid and pathid when item is
|
||||
# moved or renamed
|
||||
plex_db.addReference(itemid,
|
||||
PF.PLEX_TYPE_MOVIE,
|
||||
v.PLEX_TYPE_MOVIE,
|
||||
movieid,
|
||||
PF.KODI_TYPE_MOVIE,
|
||||
v.KODI_TYPE_MOVIE,
|
||||
kodi_fileid=fileid,
|
||||
kodi_pathid=pathid,
|
||||
parent_id=None,
|
||||
|
@ -559,7 +560,7 @@ class TVShows(Items):
|
|||
# update new ratings Kodi 17
|
||||
ratingid = self.kodi_db.get_ratingid(showid)
|
||||
self.kodi_db.update_ratings(showid,
|
||||
PF.KODI_TYPE_SHOW,
|
||||
v.KODI_TYPE_SHOW,
|
||||
"default",
|
||||
rating,
|
||||
None, # votecount
|
||||
|
@ -567,7 +568,7 @@ class TVShows(Items):
|
|||
# update new uniqueid Kodi 17
|
||||
uniqueid = self.kodi_db.get_uniqueid(showid)
|
||||
self.kodi_db.update_uniqueid(showid,
|
||||
PF.KODI_TYPE_SHOW,
|
||||
v.KODI_TYPE_SHOW,
|
||||
tvdb,
|
||||
"tvdb",
|
||||
uniqueid)
|
||||
|
@ -585,9 +586,9 @@ class TVShows(Items):
|
|||
# Add reference is idempotent; the call here updates also fileid
|
||||
# and pathid when item is moved or renamed
|
||||
plex_db.addReference(itemid,
|
||||
PF.PLEX_TYPE_SHOW,
|
||||
v.PLEX_TYPE_SHOW,
|
||||
showid,
|
||||
PF.KODI_TYPE_SHOW,
|
||||
v.KODI_TYPE_SHOW,
|
||||
kodi_pathid=pathid,
|
||||
checksum=checksum,
|
||||
view_id=viewid)
|
||||
|
@ -600,7 +601,7 @@ class TVShows(Items):
|
|||
ratingid = self.kodi_db.create_entry_rating()
|
||||
self.kodi_db.add_ratings(ratingid,
|
||||
showid,
|
||||
PF.KODI_TYPE_SHOW,
|
||||
v.KODI_TYPE_SHOW,
|
||||
"default",
|
||||
rating,
|
||||
None) # votecount
|
||||
|
@ -608,7 +609,7 @@ class TVShows(Items):
|
|||
uniqueid = self.kodi_db.create_entry_uniqueid()
|
||||
self.kodi_db.add_uniqueid(uniqueid,
|
||||
showid,
|
||||
PF.KODI_TYPE_SHOW,
|
||||
v.KODI_TYPE_SHOW,
|
||||
tvdb,
|
||||
"tvdb")
|
||||
query = ' '.join((
|
||||
|
@ -637,9 +638,9 @@ class TVShows(Items):
|
|||
|
||||
# Create the reference in plex table
|
||||
plex_db.addReference(itemid,
|
||||
PF.PLEX_TYPE_SHOW,
|
||||
v.PLEX_TYPE_SHOW,
|
||||
showid,
|
||||
PF.KODI_TYPE_SHOW,
|
||||
v.KODI_TYPE_SHOW,
|
||||
kodi_pathid=pathid,
|
||||
checksum=checksum,
|
||||
view_id=viewid)
|
||||
|
@ -716,9 +717,9 @@ class TVShows(Items):
|
|||
else:
|
||||
# Create the reference in plex table
|
||||
plex_db.addReference(plex_id,
|
||||
PF.PLEX_TYPE_SEASON,
|
||||
v.PLEX_TYPE_SEASON,
|
||||
seasonid,
|
||||
PF.KODI_TYPE_SEASON,
|
||||
v.KODI_TYPE_SEASON,
|
||||
parent_id=showid,
|
||||
view_id=viewid,
|
||||
checksum=checksum)
|
||||
|
@ -943,9 +944,9 @@ class TVShows(Items):
|
|||
# idempotent; the call here updates also fileid and pathid when item is
|
||||
# moved or renamed
|
||||
plex_db.addReference(itemid,
|
||||
PF.PLEX_TYPE_EPISODE,
|
||||
v.PLEX_TYPE_EPISODE,
|
||||
episodeid,
|
||||
PF.KODI_TYPE_EPISODE,
|
||||
v.KODI_TYPE_EPISODE,
|
||||
kodi_fileid=fileid,
|
||||
kodi_pathid=pathid,
|
||||
parent_id=seasonid,
|
||||
|
@ -1036,25 +1037,25 @@ class TVShows(Items):
|
|||
|
||||
##### IF EPISODE #####
|
||||
|
||||
if mediatype == PF.KODI_TYPE_EPISODE:
|
||||
if mediatype == v.KODI_TYPE_EPISODE:
|
||||
# Delete kodi episode and file, verify season and tvshow
|
||||
self.removeEpisode(kodiid, fileid)
|
||||
|
||||
# Season verification
|
||||
season = plex_db.getItem_byKodiId(parentid, PF.KODI_TYPE_SEASON)
|
||||
season = plex_db.getItem_byKodiId(parentid, v.KODI_TYPE_SEASON)
|
||||
try:
|
||||
showid = season[1]
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
season_episodes = plex_db.getItem_byParentId(parentid,
|
||||
PF.KODI_TYPE_EPISODE)
|
||||
v.KODI_TYPE_EPISODE)
|
||||
if not season_episodes:
|
||||
self.removeSeason(parentid)
|
||||
plex_db.removeItem(season[0])
|
||||
|
||||
# Show verification
|
||||
show = plex_db.getItem_byKodiId(showid, PF.KODI_TYPE_SHOW)
|
||||
show = plex_db.getItem_byKodiId(showid, v.KODI_TYPE_SHOW)
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT totalCount",
|
||||
|
@ -1066,13 +1067,13 @@ class TVShows(Items):
|
|||
if result and result[0] is None:
|
||||
# There's no episodes left, delete show and any possible remaining seasons
|
||||
seasons = plex_db.getItem_byParentId(showid,
|
||||
PF.KODI_TYPE_SEASON)
|
||||
v.KODI_TYPE_SEASON)
|
||||
for season in seasons:
|
||||
self.removeSeason(season[1])
|
||||
else:
|
||||
# Delete plex season entries
|
||||
plex_db.removeItems_byParentId(showid,
|
||||
PF.KODI_TYPE_SEASON)
|
||||
v.KODI_TYPE_SEASON)
|
||||
self.removeShow(showid)
|
||||
plex_db.removeItem(show[0])
|
||||
|
||||
|
@ -1081,46 +1082,46 @@ class TVShows(Items):
|
|||
elif mediatype == "tvshow":
|
||||
# Remove episodes, seasons, tvshow
|
||||
seasons = plex_db.getItem_byParentId(kodiid,
|
||||
PF.KODI_TYPE_SEASON)
|
||||
v.KODI_TYPE_SEASON)
|
||||
for season in seasons:
|
||||
seasonid = season[1]
|
||||
season_episodes = plex_db.getItem_byParentId(seasonid,
|
||||
PF.KODI_TYPE_EPISODE)
|
||||
v.KODI_TYPE_EPISODE)
|
||||
for episode in season_episodes:
|
||||
self.removeEpisode(episode[1], episode[2])
|
||||
else:
|
||||
# Remove plex episodes
|
||||
plex_db.removeItems_byParentId(seasonid,
|
||||
PF.KODI_TYPE_EPISODE)
|
||||
v.KODI_TYPE_EPISODE)
|
||||
else:
|
||||
# Remove plex seasons
|
||||
plex_db.removeItems_byParentId(kodiid,
|
||||
PF.KODI_TYPE_SEASON)
|
||||
v.KODI_TYPE_SEASON)
|
||||
|
||||
# Remove tvshow
|
||||
self.removeShow(kodiid)
|
||||
|
||||
##### IF SEASON #####
|
||||
|
||||
elif mediatype == PF.KODI_TYPE_SEASON:
|
||||
elif mediatype == v.KODI_TYPE_SEASON:
|
||||
# Remove episodes, season, verify tvshow
|
||||
season_episodes = plex_db.getItem_byParentId(kodiid,
|
||||
PF.KODI_TYPE_EPISODE)
|
||||
v.KODI_TYPE_EPISODE)
|
||||
for episode in season_episodes:
|
||||
self.removeEpisode(episode[1], episode[2])
|
||||
else:
|
||||
# Remove plex episodes
|
||||
plex_db.removeItems_byParentId(kodiid, PF.KODI_TYPE_EPISODE)
|
||||
plex_db.removeItems_byParentId(kodiid, v.KODI_TYPE_EPISODE)
|
||||
|
||||
# Remove season
|
||||
self.removeSeason(kodiid)
|
||||
|
||||
# Show verification
|
||||
seasons = plex_db.getItem_byParentId(parentid, PF.KODI_TYPE_SEASON)
|
||||
seasons = plex_db.getItem_byParentId(parentid, v.KODI_TYPE_SEASON)
|
||||
if not seasons:
|
||||
# There's no seasons, delete the show
|
||||
self.removeShow(parentid)
|
||||
plex_db.removeItem_byKodiId(parentid, PF.KODI_TYPE_SHOW)
|
||||
plex_db.removeItem_byKodiId(parentid, v.KODI_TYPE_SHOW)
|
||||
|
||||
log.debug("Deleted %s: %s from kodi database" % (mediatype, itemid))
|
||||
|
||||
|
@ -1223,9 +1224,9 @@ class Music(Items):
|
|||
artistid = self.kodi_db.addArtist(name, musicBrainzId)
|
||||
# Create the reference in plex table
|
||||
plex_db.addReference(itemid,
|
||||
PF.PLEX_TYPE_ARTIST,
|
||||
v.PLEX_TYPE_ARTIST,
|
||||
artistid,
|
||||
PF.KODI_TYPE_ARTIST,
|
||||
v.KODI_TYPE_ARTIST,
|
||||
checksum=checksum)
|
||||
|
||||
# Process the artist
|
||||
|
@ -1319,9 +1320,9 @@ class Music(Items):
|
|||
albumid = self.kodi_db.addAlbum(name, musicBrainzId)
|
||||
# Create the reference in plex table
|
||||
plex_db.addReference(itemid,
|
||||
PF.PLEX_TYPE_ALBUM,
|
||||
v.PLEX_TYPE_ALBUM,
|
||||
albumid,
|
||||
PF.KODI_TYPE_ALBUM,
|
||||
v.KODI_TYPE_ALBUM,
|
||||
checksum=checksum)
|
||||
|
||||
# Process the album info
|
||||
|
@ -1387,15 +1388,15 @@ class Music(Items):
|
|||
except TypeError:
|
||||
log.info('Artist %s does not exist in plex database'
|
||||
% parentId)
|
||||
artist = PF.GetPlexMetadata(parentId)
|
||||
artist = GetPlexMetadata(parentId)
|
||||
# Item may not be an artist, verification necessary.
|
||||
if artist is not None and artist != 401:
|
||||
if artist[0].attrib.get('type') == "artist":
|
||||
# Update with the parentId, for remove reference
|
||||
plex_db.addReference(parentId,
|
||||
PF.PLEX_TYPE_ARTIST,
|
||||
v.PLEX_TYPE_ARTIST,
|
||||
parentId,
|
||||
PF.KODI_TYPE_ARTIST)
|
||||
v.KODI_TYPE_ARTIST)
|
||||
plex_db.updateParentId(itemid, parentId)
|
||||
else:
|
||||
# Update plex reference with the artistid
|
||||
|
@ -1410,7 +1411,7 @@ class Music(Items):
|
|||
except TypeError:
|
||||
# Artist does not exist in plex database, create the reference
|
||||
log.info('Artist %s does not exist in Plex database' % artistId)
|
||||
artist = PF.GetPlexMetadata(artistId)
|
||||
artist = GetPlexMetadata(artistId)
|
||||
if artist is not None and artist != 401:
|
||||
self.add_updateArtist(artist[0], artisttype="AlbumArtist")
|
||||
plex_dbartist = plex_db.getItem_byId(artistId)
|
||||
|
@ -1571,9 +1572,9 @@ class Music(Items):
|
|||
% itemid)
|
||||
albumid = self.kodi_db.addAlbum(album_name, API.getProvider('MusicBrainzAlbum'))
|
||||
plex_db.addReference("%salbum%s" % (itemid, albumid),
|
||||
PF.PLEX_TYPE_ALBUM,
|
||||
v.PLEX_TYPE_ALBUM,
|
||||
albumid,
|
||||
PF.KODI_TYPE_ALBUM)
|
||||
v.KODI_TYPE_ALBUM)
|
||||
else:
|
||||
# No album Id associated to the song.
|
||||
log.error("Song itemid: %s has no albumId associated."
|
||||
|
@ -1584,7 +1585,7 @@ class Music(Items):
|
|||
# No album found. Let's create it
|
||||
log.info("Album database entry missing.")
|
||||
plex_albumId = item.attrib.get('parentRatingKey')
|
||||
album = PF.GetPlexMetadata(plex_albumId)
|
||||
album = GetPlexMetadata(plex_albumId)
|
||||
if album is None or album == 401:
|
||||
log.error('Could not download album, abort')
|
||||
return
|
||||
|
@ -1647,9 +1648,9 @@ class Music(Items):
|
|||
|
||||
# Create the reference in plex table
|
||||
plex_db.addReference(itemid,
|
||||
PF.PLEX_TYPE_SONG,
|
||||
v.PLEX_TYPE_SONG,
|
||||
songid,
|
||||
PF.KODI_TYPE_SONG,
|
||||
v.KODI_TYPE_SONG,
|
||||
kodi_pathid=pathid,
|
||||
parent_id=albumid,
|
||||
checksum=checksum)
|
||||
|
@ -1680,7 +1681,7 @@ class Music(Items):
|
|||
artistid = artist_edb[0]
|
||||
except TypeError:
|
||||
# Artist is missing from plex database, add it.
|
||||
artistXml = PF.GetPlexMetadata(artist_eid)
|
||||
artistXml = GetPlexMetadata(artist_eid)
|
||||
if artistXml is None or artistXml == 401:
|
||||
log.error('Error getting artist, abort')
|
||||
return
|
||||
|
@ -1726,7 +1727,7 @@ class Music(Items):
|
|||
artistid = artist_edb[0]
|
||||
except TypeError:
|
||||
# Artist is missing from plex database, add it.
|
||||
artistXml = PF.GetPlexMetadata(artist_eid)
|
||||
artistXml = GetPlexMetadata(artist_eid)
|
||||
if artistXml is None or artistXml == 401:
|
||||
log.error('Error getting artist, abort')
|
||||
return
|
||||
|
@ -1809,7 +1810,7 @@ class Music(Items):
|
|||
|
||||
##### IF SONG #####
|
||||
|
||||
if mediatype == PF.KODI_TYPE_SONG:
|
||||
if mediatype == v.KODI_TYPE_SONG:
|
||||
# Delete song
|
||||
self.removeSong(kodiid)
|
||||
# This should only address single song scenario, where server doesn't actually
|
||||
|
@ -1821,54 +1822,54 @@ class Music(Items):
|
|||
item_kid = item[0]
|
||||
item_mediatype = item[1]
|
||||
|
||||
if item_mediatype == PF.KODI_TYPE_ALBUM:
|
||||
if item_mediatype == v.KODI_TYPE_ALBUM:
|
||||
childs = plex_db.getItem_byParentId(item_kid,
|
||||
PF.KODI_TYPE_SONG)
|
||||
v.KODI_TYPE_SONG)
|
||||
if not childs:
|
||||
# Delete album
|
||||
self.removeAlbum(item_kid)
|
||||
|
||||
##### IF ALBUM #####
|
||||
|
||||
elif mediatype == PF.KODI_TYPE_ALBUM:
|
||||
elif mediatype == v.KODI_TYPE_ALBUM:
|
||||
# Delete songs, album
|
||||
album_songs = plex_db.getItem_byParentId(kodiid,
|
||||
PF.KODI_TYPE_SONG)
|
||||
v.KODI_TYPE_SONG)
|
||||
for song in album_songs:
|
||||
self.removeSong(song[1])
|
||||
else:
|
||||
# Remove plex songs
|
||||
plex_db.removeItems_byParentId(kodiid,
|
||||
PF.KODI_TYPE_SONG)
|
||||
v.KODI_TYPE_SONG)
|
||||
|
||||
# Remove the album
|
||||
self.removeAlbum(kodiid)
|
||||
|
||||
##### IF ARTIST #####
|
||||
|
||||
elif mediatype == PF.KODI_TYPE_ARTIST:
|
||||
elif mediatype == v.KODI_TYPE_ARTIST:
|
||||
# Delete songs, album, artist
|
||||
albums = plex_db.getItem_byParentId(kodiid,
|
||||
PF.KODI_TYPE_ALBUM)
|
||||
v.KODI_TYPE_ALBUM)
|
||||
for album in albums:
|
||||
albumid = album[1]
|
||||
album_songs = plex_db.getItem_byParentId(albumid,
|
||||
PF.KODI_TYPE_SONG)
|
||||
v.KODI_TYPE_SONG)
|
||||
for song in album_songs:
|
||||
self.removeSong(song[1])
|
||||
else:
|
||||
# Remove plex song
|
||||
plex_db.removeItems_byParentId(albumid,
|
||||
PF.KODI_TYPE_SONG)
|
||||
v.KODI_TYPE_SONG)
|
||||
# Remove plex artist
|
||||
plex_db.removeItems_byParentId(albumid,
|
||||
PF.KODI_TYPE_ARTIST)
|
||||
v.KODI_TYPE_ARTIST)
|
||||
# Remove kodi album
|
||||
self.removeAlbum(albumid)
|
||||
else:
|
||||
# Remove plex albums
|
||||
plex_db.removeItems_byParentId(kodiid,
|
||||
PF.KODI_TYPE_ALBUM)
|
||||
v.KODI_TYPE_ALBUM)
|
||||
|
||||
# Remove artist
|
||||
self.removeArtist(kodiid)
|
||||
|
@ -1876,18 +1877,18 @@ class Music(Items):
|
|||
log.info("Deleted %s: %s from kodi database" % (mediatype, itemid))
|
||||
|
||||
def removeSong(self, kodiid):
|
||||
self.artwork.deleteArtwork(kodiid, PF.KODI_TYPE_SONG, self.kodicursor)
|
||||
self.artwork.deleteArtwork(kodiid, v.KODI_TYPE_SONG, self.kodicursor)
|
||||
self.kodicursor.execute("DELETE FROM song WHERE idSong = ?",
|
||||
(kodiid,))
|
||||
|
||||
def removeAlbum(self, kodiid):
|
||||
self.artwork.deleteArtwork(kodiid, PF.KODI_TYPE_ALBUM, self.kodicursor)
|
||||
self.artwork.deleteArtwork(kodiid, v.KODI_TYPE_ALBUM, self.kodicursor)
|
||||
self.kodicursor.execute("DELETE FROM album WHERE idAlbum = ?",
|
||||
(kodiid,))
|
||||
|
||||
def removeArtist(self, kodiid):
|
||||
self.artwork.deleteArtwork(kodiid,
|
||||
PF.KODI_TYPE_ARTIST,
|
||||
v.KODI_TYPE_ARTIST,
|
||||
self.kodicursor)
|
||||
self.kodicursor.execute("DELETE FROM artist WHERE idArtist = ?",
|
||||
(kodiid,))
|
||||
|
|
|
@ -6,8 +6,8 @@ import logging
|
|||
from ntpath import dirname
|
||||
|
||||
import artwork
|
||||
from utils import kodiSQL, KODIVERSION
|
||||
from PlexFunctions import KODI_TYPE_MOVIE, KODI_TYPE_EPISODE
|
||||
from utils import kodiSQL
|
||||
import variables as v
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -205,7 +205,7 @@ class Kodidb_Functions():
|
|||
self.cursor.execute(query, (pathid, filename,))
|
||||
|
||||
def addCountries(self, kodiid, countries, mediatype):
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
for country in countries:
|
||||
query = ' '.join((
|
||||
|
@ -335,7 +335,7 @@ class Kodidb_Functions():
|
|||
castorder = 1
|
||||
for person in people:
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
actorid = self._getactorid(person['Name'])
|
||||
# Link person to content
|
||||
castorder = self._addPerson(person.get('Role'),
|
||||
|
@ -528,7 +528,7 @@ class Kodidb_Functions():
|
|||
|
||||
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
# Delete current genres for clean slate
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -642,7 +642,7 @@ class Kodidb_Functions():
|
|||
|
||||
def addStudios(self, kodiid, studios, mediatype):
|
||||
for studio in studios:
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -870,7 +870,7 @@ class Kodidb_Functions():
|
|||
self.cursor.execute(query, (idFile,))
|
||||
try:
|
||||
itemId = self.cursor.fetchone()[0]
|
||||
typus = KODI_TYPE_MOVIE
|
||||
typus = v.KODI_TYPE_MOVIE
|
||||
except TypeError:
|
||||
# Try tv shows next
|
||||
query = ' '.join((
|
||||
|
@ -881,7 +881,7 @@ class Kodidb_Functions():
|
|||
self.cursor.execute(query, (idFile,))
|
||||
try:
|
||||
itemId = self.cursor.fetchone()[0]
|
||||
typus = KODI_TYPE_EPISODE
|
||||
typus = v.KODI_TYPE_EPISODE
|
||||
except TypeError:
|
||||
log.warn('Unexpectantly did not find a match!')
|
||||
return
|
||||
|
@ -908,13 +908,13 @@ class Kodidb_Functions():
|
|||
return ids
|
||||
|
||||
def getVideoRuntime(self, kodiid, mediatype):
|
||||
if mediatype == KODI_TYPE_MOVIE:
|
||||
if mediatype == v.KODI_TYPE_MOVIE:
|
||||
query = ' '.join((
|
||||
"SELECT c11",
|
||||
"FROM movie",
|
||||
"WHERE idMovie = ?",
|
||||
))
|
||||
elif mediatype == KODI_TYPE_EPISODE:
|
||||
elif mediatype == v.KODI_TYPE_EPISODE:
|
||||
query = ' '.join((
|
||||
"SELECT c09",
|
||||
"FROM episode",
|
||||
|
@ -962,7 +962,7 @@ class Kodidb_Functions():
|
|||
|
||||
def addTags(self, kodiid, tags, mediatype):
|
||||
# First, delete any existing tags associated to the id
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -987,7 +987,7 @@ class Kodidb_Functions():
|
|||
self.addTag(kodiid, tag, mediatype)
|
||||
|
||||
def addTag(self, kodiid, tag, mediatype):
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -1048,7 +1048,7 @@ class Kodidb_Functions():
|
|||
|
||||
def createTag(self, name):
|
||||
# This will create and return the tag_id
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -1092,7 +1092,7 @@ class Kodidb_Functions():
|
|||
return tag_id
|
||||
|
||||
def updateTag(self, oldtag, newtag, kodiid, mediatype):
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
try:
|
||||
query = ' '.join((
|
||||
|
@ -1140,7 +1140,7 @@ class Kodidb_Functions():
|
|||
self.cursor.execute(query, (kodiid, mediatype, oldtag,))
|
||||
|
||||
def removeTag(self, kodiid, tagname, mediatype):
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -1314,7 +1314,7 @@ class Kodidb_Functions():
|
|||
# Create the album
|
||||
self.cursor.execute("select coalesce(max(idAlbum),0) from album")
|
||||
albumid = self.cursor.fetchone()[0] + 1
|
||||
if KODIVERSION > 14:
|
||||
if v.KODIVERSION > 14:
|
||||
query = (
|
||||
'''
|
||||
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType)
|
||||
|
|
|
@ -10,9 +10,10 @@ from xbmc import Monitor, Player, sleep
|
|||
import downloadutils
|
||||
import plexdb_functions as plexdb
|
||||
from utils import window, settings, CatchExceptions, tryDecode, tryEncode
|
||||
from PlexFunctions import scrobble, REMAP_TYPE_FROM_PLEXTYPE
|
||||
from PlexFunctions import scrobble
|
||||
from kodidb_functions import get_kodiid_from_filename
|
||||
from PlexAPI import API
|
||||
from variables import REMAP_TYPE_FROM_PLEXTYPE
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
|
|
@ -25,16 +25,16 @@ import kodidb_functions as kodidb
|
|||
import userclient
|
||||
import videonodes
|
||||
import artwork
|
||||
import variables as v
|
||||
|
||||
import PlexFunctions as PF
|
||||
from PlexFunctions import GetPlexMetadata, GetAllPlexLeaves, scrobble, \
|
||||
GetPlexSectionResults, GetAllPlexChildren, GetPMSStatus
|
||||
import PlexAPI
|
||||
|
||||
###############################################################################
|
||||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
||||
addonName = 'PlexKodiConnect'
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
@ -99,7 +99,7 @@ class ThreadedGetMetadata(Thread):
|
|||
xbmc.sleep(10)
|
||||
continue
|
||||
# Download Metadata
|
||||
plexXML = PF.GetPlexMetadata(updateItem['itemId'])
|
||||
plexXML = GetPlexMetadata(updateItem['itemId'])
|
||||
if plexXML is None:
|
||||
# Did not receive a valid XML - skip that item for now
|
||||
log.warn("Could not get metadata for %s. Skipping that item "
|
||||
|
@ -229,7 +229,7 @@ class ThreadedShowSyncInfo(Thread):
|
|||
downloadLock = self.locks[0]
|
||||
processLock = self.locks[1]
|
||||
dialog.create("%s: Sync %s: %s items"
|
||||
% (addonName, self.itemType, str(total)),
|
||||
% (lang(29999), self.itemType, str(total)),
|
||||
"Starting")
|
||||
global getMetadataCount
|
||||
global processMetadataCount
|
||||
|
@ -330,7 +330,7 @@ class ProcessFanartThread(Thread):
|
|||
log.debug('Getting additional fanart for Plex id %s'
|
||||
% item['itemId'])
|
||||
# Download Metadata
|
||||
xml = PF.GetPlexMetadata(item['itemId'])
|
||||
xml = GetPlexMetadata(item['itemId'])
|
||||
if xml is None:
|
||||
# Did not receive a valid XML - skip that item for now
|
||||
log.warn("Could not get metadata for %s. Skipping that item "
|
||||
|
@ -388,7 +388,7 @@ class LibrarySync(Thread):
|
|||
# Init for replacing paths
|
||||
window('remapSMB', value=settings('remapSMB'))
|
||||
window('replaceSMB', value=settings('replaceSMB'))
|
||||
for typus in PF.REMAP_TYPE_FROM_PLEXTYPE.values():
|
||||
for typus in v.REMAP_TYPE_FROM_PLEXTYPE.values():
|
||||
for arg in ('Org', 'New'):
|
||||
key = 'remapSMB%s%s' % (typus, arg)
|
||||
window(key, value=settings(key))
|
||||
|
@ -412,14 +412,14 @@ class LibrarySync(Thread):
|
|||
return
|
||||
if icon == "plex":
|
||||
self.dialog.notification(
|
||||
addonName,
|
||||
lang(29999),
|
||||
message,
|
||||
"special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
||||
5000,
|
||||
False)
|
||||
elif icon == "error":
|
||||
self.dialog.notification(
|
||||
addonName,
|
||||
lang(29999),
|
||||
message,
|
||||
xbmcgui.NOTIFICATION_ERROR,
|
||||
7000,
|
||||
|
@ -448,9 +448,9 @@ class LibrarySync(Thread):
|
|||
return False
|
||||
|
||||
plexId = None
|
||||
for mediatype in (PF.PLEX_TYPE_MOVIE,
|
||||
PF.PLEX_TYPE_SHOW,
|
||||
PF.PLEX_TYPE_ARTIST):
|
||||
for mediatype in (v.PLEX_TYPE_MOVIE,
|
||||
v.PLEX_TYPE_SHOW,
|
||||
v.PLEX_TYPE_ARTIST):
|
||||
if plexId is not None:
|
||||
break
|
||||
for view in sections:
|
||||
|
@ -459,8 +459,8 @@ class LibrarySync(Thread):
|
|||
if not view.attrib['type'] == mediatype:
|
||||
continue
|
||||
libraryId = view.attrib['key']
|
||||
items = PF.GetAllPlexLeaves(libraryId,
|
||||
containerSize=self.limitindex)
|
||||
items = GetAllPlexLeaves(libraryId,
|
||||
containerSize=self.limitindex)
|
||||
if items in (None, 401):
|
||||
log.error("Could not download section %s"
|
||||
% view.attrib['key'])
|
||||
|
@ -482,7 +482,7 @@ class LibrarySync(Thread):
|
|||
return False
|
||||
|
||||
# Get the Plex item's metadata
|
||||
xml = PF.GetPlexMetadata(plexId)
|
||||
xml = GetPlexMetadata(plexId)
|
||||
if xml in (None, 401):
|
||||
log.error("Could not download metadata, aborting time sync")
|
||||
return False
|
||||
|
@ -501,15 +501,15 @@ class LibrarySync(Thread):
|
|||
# Set the timer
|
||||
koditime = getUnixTimestamp()
|
||||
# Toggle watched state
|
||||
PF.scrobble(plexId, 'watched')
|
||||
scrobble(plexId, 'watched')
|
||||
# Let the PMS process this first!
|
||||
xbmc.sleep(1000)
|
||||
# Get PMS items to find the item we just changed
|
||||
items = PF.GetAllPlexLeaves(libraryId,
|
||||
lastViewedAt=timestamp,
|
||||
containerSize=self.limitindex)
|
||||
items = GetAllPlexLeaves(libraryId,
|
||||
lastViewedAt=timestamp,
|
||||
containerSize=self.limitindex)
|
||||
# Toggle watched state back
|
||||
PF.scrobble(plexId, 'unwatched')
|
||||
scrobble(plexId, 'unwatched')
|
||||
if items in (None, 401):
|
||||
log.error("Could not download metadata, aborting time sync")
|
||||
return False
|
||||
|
@ -630,13 +630,13 @@ class LibrarySync(Thread):
|
|||
setScreensaver(value=screensaver)
|
||||
if window('plex_scancrashed') == 'true':
|
||||
# Show warning if itemtypes.py crashed at some point
|
||||
self.dialog.ok(addonName, lang(39408))
|
||||
self.dialog.ok(lang(29999), lang(39408))
|
||||
window('plex_scancrashed', clear=True)
|
||||
elif window('plex_scancrashed') == '401':
|
||||
window('plex_scancrashed', clear=True)
|
||||
if window('plex_serverStatus') not in ('401', 'Auth'):
|
||||
# Plex server had too much and returned ERROR
|
||||
self.dialog.ok(addonName, lang(39409))
|
||||
self.dialog.ok(lang(29999), lang(39409))
|
||||
|
||||
# Path hack, so Kodis Information screen works
|
||||
with kodidb.GetKodiDB('video') as kodi_db:
|
||||
|
@ -653,8 +653,8 @@ class LibrarySync(Thread):
|
|||
folder = folderItem.attrib
|
||||
mediatype = folder['type']
|
||||
# Only process supported formats
|
||||
if mediatype not in (PF.PLEX_TYPE_MOVIE, PF.PLEX_TYPE_SHOW,
|
||||
PF.PLEX_TYPE_ARTIST, PF.PLEX_TYPE_PHOTO):
|
||||
if mediatype not in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW,
|
||||
v.PLEX_TYPE_ARTIST, v.PLEX_TYPE_PHOTO):
|
||||
return totalnodes
|
||||
|
||||
# Prevent duplicate for nodes of the same type
|
||||
|
@ -678,12 +678,12 @@ class LibrarySync(Thread):
|
|||
tagid = kodi_db.createTag(foldername)
|
||||
# Create playlist for the video library
|
||||
if (foldername not in playlists and
|
||||
mediatype in (PF.PLEX_TYPE_MOVIE, PF.PLEX_TYPE_SHOW)):
|
||||
mediatype in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW)):
|
||||
playlistXSP(mediatype, foldername, folderid, viewtype)
|
||||
playlists.append(foldername)
|
||||
# Create the video node
|
||||
if (foldername not in nodes and
|
||||
mediatype != PF.PLEX_TYPE_ARTIST):
|
||||
mediatype != v.PLEX_TYPE_ARTIST):
|
||||
vnodes.viewNode(sorted_views.index(foldername),
|
||||
foldername,
|
||||
mediatype,
|
||||
|
@ -737,7 +737,7 @@ class LibrarySync(Thread):
|
|||
delete=True)
|
||||
# Added new playlist
|
||||
if (foldername not in playlists and
|
||||
mediatype in (PF.PLEX_TYPE_MOVIE, PF.PLEX_TYPE_SHOW)):
|
||||
mediatype in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW)):
|
||||
playlistXSP(mediatype,
|
||||
foldername,
|
||||
folderid,
|
||||
|
@ -761,9 +761,9 @@ class LibrarySync(Thread):
|
|||
current_tagid, tagid, item[0], current_viewtype[:-1])
|
||||
else:
|
||||
# Validate the playlist exists or recreate it
|
||||
if mediatype != PF.PLEX_TYPE_ARTIST:
|
||||
if mediatype != v.PLEX_TYPE_ARTIST:
|
||||
if (foldername not in playlists and
|
||||
mediatype in (PF.PLEX_TYPE_MOVIE, PF.PLEX_TYPE_SHOW)):
|
||||
mediatype in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW)):
|
||||
playlistXSP(mediatype,
|
||||
foldername,
|
||||
folderid,
|
||||
|
@ -798,22 +798,22 @@ class LibrarySync(Thread):
|
|||
|
||||
# For whatever freaking reason, .copy() or dict() does NOT work?!?!?!
|
||||
self.nodes = {
|
||||
PF.PLEX_TYPE_MOVIE: [],
|
||||
PF.PLEX_TYPE_SHOW: [],
|
||||
PF.PLEX_TYPE_ARTIST: [],
|
||||
PF.PLEX_TYPE_PHOTO: []
|
||||
v.PLEX_TYPE_MOVIE: [],
|
||||
v.PLEX_TYPE_SHOW: [],
|
||||
v.PLEX_TYPE_ARTIST: [],
|
||||
v.PLEX_TYPE_PHOTO: []
|
||||
}
|
||||
self.playlists = {
|
||||
PF.PLEX_TYPE_MOVIE: [],
|
||||
PF.PLEX_TYPE_SHOW: [],
|
||||
PF.PLEX_TYPE_ARTIST: [],
|
||||
PF.PLEX_TYPE_PHOTO: []
|
||||
v.PLEX_TYPE_MOVIE: [],
|
||||
v.PLEX_TYPE_SHOW: [],
|
||||
v.PLEX_TYPE_ARTIST: [],
|
||||
v.PLEX_TYPE_PHOTO: []
|
||||
}
|
||||
self.sorted_views = []
|
||||
|
||||
for view in sections:
|
||||
itemType = view.attrib['type']
|
||||
if itemType in (PF.PLEX_TYPE_MOVIE, PF.PLEX_TYPE_SHOW, PF.PLEX_TYPE_PHOTO): # NOT artist for now
|
||||
if itemType in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW, v.PLEX_TYPE_PHOTO): # NOT artist for now
|
||||
self.sorted_views.append(view.attrib['title'])
|
||||
log.debug('Sorted views: %s' % self.sorted_views)
|
||||
|
||||
|
@ -1042,10 +1042,10 @@ class LibrarySync(Thread):
|
|||
if (settings('FanartTV') == 'true' and
|
||||
itemType in ('Movies', 'TVShows')):
|
||||
# Save to queue for later processing
|
||||
typus = {'Movies': PF.KODI_TYPE_MOVIE,
|
||||
'TVShows': PF.KODI_TYPE_SHOW}[itemType]
|
||||
typus = {'Movies': v.KODI_TYPE_MOVIE,
|
||||
'TVShows': v.KODI_TYPE_SHOW}[itemType]
|
||||
for item in self.updatelist:
|
||||
if item['mediaType'] in (PF.KODI_TYPE_MOVIE, PF.KODI_TYPE_SHOW):
|
||||
if item['mediaType'] in (v.KODI_TYPE_MOVIE, v.KODI_TYPE_SHOW):
|
||||
self.fanartqueue.put({
|
||||
'itemId': item['itemId'],
|
||||
'class': itemType,
|
||||
|
@ -1061,7 +1061,7 @@ class LibrarySync(Thread):
|
|||
|
||||
itemType = 'Movies'
|
||||
|
||||
views = [x for x in self.views if x['itemtype'] == PF.KODI_TYPE_MOVIE]
|
||||
views = [x for x in self.views if x['itemtype'] == v.KODI_TYPE_MOVIE]
|
||||
log.info("Processing Plex %s. Libraries: %s" % (itemType, views))
|
||||
|
||||
self.allKodiElementsId = {}
|
||||
|
@ -1071,7 +1071,7 @@ class LibrarySync(Thread):
|
|||
# Pull the list of movies and boxsets in Kodi
|
||||
try:
|
||||
self.allKodiElementsId = dict(
|
||||
plex_db.getChecksum(PF.PLEX_TYPE_MOVIE))
|
||||
plex_db.getChecksum(v.PLEX_TYPE_MOVIE))
|
||||
except ValueError:
|
||||
self.allKodiElementsId = {}
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ class LibrarySync(Thread):
|
|||
# Get items per view
|
||||
viewId = view['id']
|
||||
viewName = view['name']
|
||||
all_plexmovies = PF.GetPlexSectionResults(
|
||||
all_plexmovies = GetPlexSectionResults(
|
||||
viewId, args=None, containerSize=self.limitindex)
|
||||
if all_plexmovies is None:
|
||||
log.info("Couldnt get section items, aborting for view.")
|
||||
|
@ -1121,10 +1121,10 @@ class LibrarySync(Thread):
|
|||
also updates resume times.
|
||||
This is done by downloading one XML for ALL elements with viewId
|
||||
"""
|
||||
xml = PF.GetAllPlexLeaves(viewId,
|
||||
lastViewedAt=lastViewedAt,
|
||||
updatedAt=updatedAt,
|
||||
containerSize=self.limitindex)
|
||||
xml = GetAllPlexLeaves(viewId,
|
||||
lastViewedAt=lastViewedAt,
|
||||
updatedAt=updatedAt,
|
||||
containerSize=self.limitindex)
|
||||
# Return if there are no items in PMS reply - it's faster
|
||||
try:
|
||||
xml[0].attrib
|
||||
|
@ -1156,9 +1156,9 @@ class LibrarySync(Thread):
|
|||
if self.compare:
|
||||
with plexdb.Get_Plex_DB() as plex:
|
||||
# Pull the list of TV shows already in Kodi
|
||||
for kind in (PF.PLEX_TYPE_SHOW,
|
||||
PF.PLEX_TYPE_SEASON,
|
||||
PF.PLEX_TYPE_EPISODE):
|
||||
for kind in (v.PLEX_TYPE_SHOW,
|
||||
v.PLEX_TYPE_SEASON,
|
||||
v.PLEX_TYPE_EPISODE):
|
||||
try:
|
||||
elements = dict(plex.getChecksum(kind))
|
||||
self.allKodiElementsId.update(elements)
|
||||
|
@ -1174,7 +1174,7 @@ class LibrarySync(Thread):
|
|||
# Get items per view
|
||||
viewId = view['id']
|
||||
viewName = view['name']
|
||||
allPlexTvShows = PF.GetPlexSectionResults(
|
||||
allPlexTvShows = GetPlexSectionResults(
|
||||
viewId, containerSize=self.limitindex)
|
||||
if allPlexTvShows is None:
|
||||
log.error("Error downloading show xml for view %s" % viewId)
|
||||
|
@ -1202,7 +1202,7 @@ class LibrarySync(Thread):
|
|||
if self.threadStopped():
|
||||
return False
|
||||
# Grab all seasons to tvshow from PMS
|
||||
seasons = PF.GetAllPlexChildren(
|
||||
seasons = GetAllPlexChildren(
|
||||
tvShowId, containerSize=self.limitindex)
|
||||
if seasons is None:
|
||||
log.error("Error download season xml for show %s" % tvShowId)
|
||||
|
@ -1228,7 +1228,7 @@ class LibrarySync(Thread):
|
|||
if self.threadStopped():
|
||||
return False
|
||||
# Grab all episodes to tvshow from PMS
|
||||
episodes = PF.GetAllPlexLeaves(
|
||||
episodes = GetAllPlexLeaves(
|
||||
view['id'], containerSize=self.limitindex)
|
||||
if episodes is None:
|
||||
log.error("Error downloading episod xml for view %s"
|
||||
|
@ -1252,7 +1252,7 @@ class LibrarySync(Thread):
|
|||
# Cycle through tv shows
|
||||
with itemtypes.TVShows() as TVshow:
|
||||
for tvShowId in allPlexTvShowsId:
|
||||
XMLtvshow = PF.GetPlexMetadata(tvShowId)
|
||||
XMLtvshow = GetPlexMetadata(tvShowId)
|
||||
if XMLtvshow is None or XMLtvshow == 401:
|
||||
log.error('Could not download XMLtvshow')
|
||||
continue
|
||||
|
@ -1278,24 +1278,24 @@ class LibrarySync(Thread):
|
|||
def PlexMusic(self):
|
||||
itemType = 'Music'
|
||||
|
||||
views = [x for x in self.views if x['itemtype'] == PF.PLEX_TYPE_ARTIST]
|
||||
views = [x for x in self.views if x['itemtype'] == v.PLEX_TYPE_ARTIST]
|
||||
log.info("Media folders for %s: %s" % (itemType, views))
|
||||
|
||||
methods = {
|
||||
PF.PLEX_TYPE_ARTIST: 'add_updateArtist',
|
||||
PF.PLEX_TYPE_ALBUM: 'add_updateAlbum',
|
||||
PF.PLEX_TYPE_SONG: 'add_updateSong'
|
||||
v.PLEX_TYPE_ARTIST: 'add_updateArtist',
|
||||
v.PLEX_TYPE_ALBUM: 'add_updateAlbum',
|
||||
v.PLEX_TYPE_SONG: 'add_updateSong'
|
||||
}
|
||||
urlArgs = {
|
||||
PF.PLEX_TYPE_ARTIST: {'type': 8},
|
||||
PF.PLEX_TYPE_ALBUM: {'type': 9},
|
||||
PF.PLEX_TYPE_SONG: {'type': 10}
|
||||
v.PLEX_TYPE_ARTIST: {'type': 8},
|
||||
v.PLEX_TYPE_ALBUM: {'type': 9},
|
||||
v.PLEX_TYPE_SONG: {'type': 10}
|
||||
}
|
||||
|
||||
# Process artist, then album and tracks last to minimize overhead
|
||||
for kind in (PF.PLEX_TYPE_ARTIST,
|
||||
PF.PLEX_TYPE_ALBUM,
|
||||
PF.PLEX_TYPE_SONG):
|
||||
for kind in (v.PLEX_TYPE_ARTIST,
|
||||
v.PLEX_TYPE_ALBUM,
|
||||
v.PLEX_TYPE_SONG):
|
||||
if self.threadStopped():
|
||||
return False
|
||||
log.debug("Start processing music %s" % kind)
|
||||
|
@ -1343,7 +1343,7 @@ class LibrarySync(Thread):
|
|||
# Get items per view
|
||||
viewId = view['id']
|
||||
viewName = view['name']
|
||||
itemsXML = PF.GetPlexSectionResults(
|
||||
itemsXML = GetPlexSectionResults(
|
||||
viewId, args=urlArgs, containerSize=self.limitindex)
|
||||
if itemsXML is None:
|
||||
log.error("Error downloading xml for view %s" % viewId)
|
||||
|
@ -1490,7 +1490,7 @@ class LibrarySync(Thread):
|
|||
|
||||
def process_newitems(self, item):
|
||||
ratingKey = item['ratingKey']
|
||||
xml = PF.GetPlexMetadata(ratingKey)
|
||||
xml = GetPlexMetadata(ratingKey)
|
||||
try:
|
||||
mediatype = xml[0].attrib['type']
|
||||
except (IndexError, KeyError, TypeError):
|
||||
|
@ -1602,7 +1602,7 @@ class LibrarySync(Thread):
|
|||
}
|
||||
else:
|
||||
# PMS is ours - get all current sessions
|
||||
self.sessionKeys = PF.GetPMSStatus(
|
||||
self.sessionKeys = GetPMSStatus(
|
||||
window('plex_token'))
|
||||
log.debug('Updated current sessions. They are: %s'
|
||||
% self.sessionKeys)
|
||||
|
@ -1639,7 +1639,7 @@ class LibrarySync(Thread):
|
|||
# duration of item
|
||||
# viewCount
|
||||
if currSess.get('duration') is None:
|
||||
xml = PF.GetPlexMetadata(ratingKey)
|
||||
xml = GetPlexMetadata(ratingKey)
|
||||
if xml in (None, 401):
|
||||
log.error('Could not get up-to-date xml for item %s'
|
||||
% ratingKey)
|
||||
|
@ -1673,7 +1673,7 @@ class LibrarySync(Thread):
|
|||
# Now tell Kodi where we are
|
||||
for item in items:
|
||||
itemFkt = getattr(itemtypes,
|
||||
PF.ITEMTYPE_FROM_KODITYPE[item['kodi_type']])
|
||||
v.ITEMTYPE_FROM_KODITYPE[item['kodi_type']])
|
||||
with itemFkt() as Fkt:
|
||||
Fkt.updatePlaystate(item)
|
||||
|
||||
|
@ -1685,8 +1685,8 @@ class LibrarySync(Thread):
|
|||
"""
|
||||
items = []
|
||||
typus = {
|
||||
PF.PLEX_TYPE_MOVIE: 'Movies',
|
||||
PF.PLEX_TYPE_SHOW: 'TVShows'
|
||||
v.PLEX_TYPE_MOVIE: 'Movies',
|
||||
v.PLEX_TYPE_SHOW: 'TVShows'
|
||||
}
|
||||
with plexdb.Get_Plex_DB() as plex_db:
|
||||
for plextype in typus:
|
||||
|
@ -1710,7 +1710,7 @@ class LibrarySync(Thread):
|
|||
import traceback
|
||||
log.error("Traceback:\n%s" % traceback.format_exc())
|
||||
# Library sync thread has crashed
|
||||
self.dialog.ok(addonName, lang(39400))
|
||||
self.dialog.ok(lang(29999), lang(39400))
|
||||
raise
|
||||
|
||||
def run_internal(self):
|
||||
|
@ -1768,13 +1768,13 @@ class LibrarySync(Thread):
|
|||
log.warn("Db version out of date: %s minimum version "
|
||||
"required: %s" % (currentVersion, minVersion))
|
||||
# DB out of date. Proceed to recreate?
|
||||
resp = self.dialog.yesno(heading=addonName,
|
||||
resp = self.dialog.yesno(heading=lang(29999),
|
||||
line1=lang(39401))
|
||||
if not resp:
|
||||
log.warn("Db version out of date! USER IGNORED!")
|
||||
# PKC may not work correctly until reset
|
||||
self.dialog.ok(heading=addonName,
|
||||
line1=(addonName + lang(39402)))
|
||||
self.dialog.ok(heading=lang(29999),
|
||||
line1=(lang(29999) + lang(39402)))
|
||||
else:
|
||||
reset()
|
||||
break
|
||||
|
@ -1792,7 +1792,7 @@ class LibrarySync(Thread):
|
|||
log.error('Current Kodi version: %s' % tryDecode(
|
||||
xbmc.getInfoLabel('System.BuildVersion')))
|
||||
# "Current Kodi version is unsupported, cancel lib sync"
|
||||
self.dialog.ok(heading=addonName, line1=lang(39403))
|
||||
self.dialog.ok(heading=lang(29999), line1=lang(39403))
|
||||
break
|
||||
# Run start up sync
|
||||
window('plex_dbScan', value="true")
|
||||
|
@ -1826,7 +1826,7 @@ class LibrarySync(Thread):
|
|||
log.error("Startup full sync failed. Stopping sync")
|
||||
# "Startup syncing process failed repeatedly"
|
||||
# "Please restart"
|
||||
self.dialog.ok(heading=addonName,
|
||||
self.dialog.ok(heading=lang(29999),
|
||||
line1=lang(39404))
|
||||
break
|
||||
|
||||
|
@ -1873,7 +1873,7 @@ class LibrarySync(Thread):
|
|||
# Only look for missing fanart (No)
|
||||
# or refresh all fanart (Yes)
|
||||
self.fanartSync(refresh=self.dialog.yesno(
|
||||
heading=addonName,
|
||||
heading=lang(29999),
|
||||
line1=lang(39223),
|
||||
nolabel=lang(39224),
|
||||
yeslabel=lang(39225)))
|
||||
|
|
|
@ -8,10 +8,10 @@ from PKC_listitem import PKC_ListItem
|
|||
from pickler import pickle_me, Playback_Successful
|
||||
from playbackutils import PlaybackUtils
|
||||
from utils import window
|
||||
from PlexFunctions import GetPlexMetadata, PLEX_TYPE_PHOTO, \
|
||||
KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE
|
||||
from PlexFunctions import GetPlexMetadata
|
||||
from PlexAPI import API
|
||||
from playqueue import lock
|
||||
import variables as v
|
||||
|
||||
###############################################################################
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
@ -45,7 +45,7 @@ class Playback_Starter(Thread):
|
|||
log.error('Could not get a PMS xml for plex id %s' % plex_id)
|
||||
return
|
||||
api = API(xml[0])
|
||||
if api.getType() == PLEX_TYPE_PHOTO:
|
||||
if api.getType() == v.PLEX_TYPE_PHOTO:
|
||||
# Photo
|
||||
result = Playback_Successful()
|
||||
listitem = PKC_ListItem()
|
||||
|
@ -56,7 +56,7 @@ class Playback_Starter(Thread):
|
|||
else:
|
||||
# Video and Music
|
||||
playqueue = self.playqueue.get_playqueue_from_type(
|
||||
KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[api.getType()])
|
||||
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[api.getType()])
|
||||
with lock:
|
||||
result = PlaybackUtils(xml, playqueue).play(
|
||||
plex_id,
|
||||
|
|
|
@ -10,25 +10,23 @@ from xbmc import getCondVisibility, Player
|
|||
import xbmcgui
|
||||
|
||||
import playutils as putils
|
||||
from utils import window, settings, tryEncode, tryDecode
|
||||
from utils import window, settings, tryEncode, tryDecode, language as lang
|
||||
import downloadutils
|
||||
|
||||
from PlexAPI import API
|
||||
from PlexFunctions import GetPlexPlaylist, KODITYPE_FROM_PLEXTYPE, \
|
||||
PLEX_TYPE_CLIP, PLEX_TYPE_MOVIE
|
||||
from PlexFunctions import GetPlexPlaylist
|
||||
from PKC_listitem import PKC_ListItem as ListItem, convert_PKC_to_listitem
|
||||
from playlist_func import add_item_to_kodi_playlist, \
|
||||
get_playlist_details_from_xml, add_listitem_to_Kodi_playlist, \
|
||||
add_listitem_to_playlist, remove_from_Kodi_playlist
|
||||
from pickler import Playback_Successful
|
||||
from plexdb_functions import Get_Plex_DB
|
||||
import variables as v
|
||||
|
||||
###############################################################################
|
||||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
||||
addonName = "PlexKodiConnect"
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
@ -86,7 +84,7 @@ class PlaybackUtils():
|
|||
result.listitem = listitem
|
||||
return result
|
||||
|
||||
kodi_type = KODITYPE_FROM_PLEXTYPE[api.getType()]
|
||||
kodi_type = v.KODITYPE_FROM_PLEXTYPE[api.getType()]
|
||||
kodi_id = int(kodi_id)
|
||||
|
||||
# ORGANIZE CURRENT PLAYLIST ################
|
||||
|
@ -125,13 +123,13 @@ class PlaybackUtils():
|
|||
# Where will the player need to start?
|
||||
# Do we need to get trailers?
|
||||
trailers = False
|
||||
if (api.getType() == PLEX_TYPE_MOVIE and
|
||||
if (api.getType() == v.PLEX_TYPE_MOVIE and
|
||||
not seektime and
|
||||
sizePlaylist < 2 and
|
||||
settings('enableCinema') == "true"):
|
||||
if settings('askCinema') == "true":
|
||||
trailers = xbmcgui.Dialog().yesno(
|
||||
addonName,
|
||||
lang(29999),
|
||||
"Play trailers?")
|
||||
else:
|
||||
trailers = True
|
||||
|
@ -290,7 +288,7 @@ class PlaybackUtils():
|
|||
self.currentPosition = 0
|
||||
for item in self.xml:
|
||||
api = API(item)
|
||||
if api.getType() == PLEX_TYPE_CLIP:
|
||||
if api.getType() == v.PLEX_TYPE_CLIP:
|
||||
self.add_trailer(item)
|
||||
else:
|
||||
with Get_Plex_DB() as plex_db:
|
||||
|
|
|
@ -13,7 +13,7 @@ import clientinfo
|
|||
import downloadutils
|
||||
import plexdb_functions as plexdb
|
||||
import kodidb_functions as kodidb
|
||||
from PlexFunctions import KODI_TYPE_MOVIE, KODI_TYPE_EPISODE
|
||||
import variables as v
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -354,7 +354,7 @@ class Player(xbmc.Player):
|
|||
if percentComplete >= markPlayed:
|
||||
# Tell Kodi that we've finished watching (Plex knows)
|
||||
if (data['fileid'] is not None and
|
||||
data['itemType'] in (KODI_TYPE_MOVIE, KODI_TYPE_EPISODE)):
|
||||
data['itemType'] in (v.KODI_TYPE_MOVIE, v.KODI_TYPE_EPISODE)):
|
||||
with kodidb.GetKodiDB('video') as kodi_db:
|
||||
kodi_db.addPlaystate(
|
||||
data['fileid'],
|
||||
|
|
|
@ -20,8 +20,6 @@ from PlexFunctions import GetMachineIdentifier
|
|||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
||||
addonName = 'PlexKodiConnect'
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
@ -136,7 +134,7 @@ class UserClient(threading.Thread):
|
|||
log.info("Access is granted.")
|
||||
self.HasAccess = True
|
||||
window('plex_serverStatus', clear=True)
|
||||
xbmcgui.Dialog().notification(addonName,
|
||||
xbmcgui.Dialog().notification(lang(29999),
|
||||
lang(33007))
|
||||
|
||||
def loadCurrUser(self, username, userId, usertoken, authenticated=False):
|
||||
|
|
|
@ -20,17 +20,15 @@ import xbmcaddon
|
|||
import xbmcgui
|
||||
import xbmcvfs
|
||||
|
||||
from variables import addonName
|
||||
|
||||
###############################################################################
|
||||
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
||||
addonName = 'PlexKodiConnect'
|
||||
WINDOW = xbmcgui.Window(10000)
|
||||
ADDON = xbmcaddon.Addon(id='plugin.video.plexkodiconnect')
|
||||
|
||||
KODILANGUAGE = xbmc.getLanguage(xbmc.ISO_639_1)
|
||||
KODIVERSION = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
||||
|
||||
###############################################################################
|
||||
# Main methods
|
||||
|
||||
|
|
151
resources/lib/variables.py
Normal file
151
resources/lib/variables.py
Normal file
|
@ -0,0 +1,151 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import xbmc
|
||||
|
||||
KODILANGUAGE = xbmc.getLanguage(xbmc.ISO_639_1)
|
||||
KODIVERSION = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
||||
|
||||
# Multiply Plex time by this factor to receive Kodi time
|
||||
PLEX_TO_KODI_TIMEFACTOR = 1.0 / 1000.0
|
||||
|
||||
|
||||
# All the Plex types as communicated in the PMS xml replies
|
||||
PLEX_TYPE_VIDEO = 'video'
|
||||
PLEX_TYPE_MOVIE = 'movie'
|
||||
PLEX_TYPE_CLIP = 'clip' # e.g. trailers
|
||||
|
||||
PLEX_TYPE_EPISODE = 'episode'
|
||||
PLEX_TYPE_SEASON = 'season'
|
||||
PLEX_TYPE_SHOW = 'show'
|
||||
|
||||
PLEX_TYPE_AUDIO = 'music'
|
||||
PLEX_TYPE_SONG = 'track'
|
||||
PLEX_TYPE_ALBUM = 'album'
|
||||
PLEX_TYPE_ARTIST = 'artist'
|
||||
|
||||
PLEX_TYPE_PHOTO = 'photo'
|
||||
|
||||
|
||||
# All the Kodi types as e.g. used in the JSON API
|
||||
KODI_TYPE_VIDEO = 'video'
|
||||
KODI_TYPE_MOVIE = 'movie'
|
||||
KODI_TYPE_SET = 'set' # for movie sets of several movies
|
||||
KODI_TYPE_CLIP = 'clip' # e.g. trailers
|
||||
|
||||
KODI_TYPE_EPISODE = 'episode'
|
||||
KODI_TYPE_SEASON = 'season'
|
||||
KODI_TYPE_SHOW = 'tvshow'
|
||||
|
||||
KODI_TYPE_AUDIO = 'audio'
|
||||
KODI_TYPE_SONG = 'song'
|
||||
KODI_TYPE_ALBUM = 'album'
|
||||
KODI_TYPE_ARTIST = 'artist'
|
||||
|
||||
KODI_TYPE_PHOTO = 'photo'
|
||||
|
||||
|
||||
# Translation tables
|
||||
|
||||
KODI_VIDEOTYPES = (
|
||||
KODI_TYPE_VIDEO,
|
||||
KODI_TYPE_MOVIE,
|
||||
KODI_TYPE_SHOW,
|
||||
KODI_TYPE_SEASON,
|
||||
KODI_TYPE_EPISODE,
|
||||
KODI_TYPE_SET
|
||||
)
|
||||
|
||||
KODI_AUDIOTYPES = (
|
||||
KODI_TYPE_SONG,
|
||||
KODI_TYPE_ALBUM,
|
||||
KODI_TYPE_ARTIST,
|
||||
)
|
||||
|
||||
ITEMTYPE_FROM_PLEXTYPE = {
|
||||
PLEX_TYPE_MOVIE: 'Movies',
|
||||
PLEX_TYPE_SEASON: 'TVShows',
|
||||
KODI_TYPE_EPISODE: 'TVShows',
|
||||
PLEX_TYPE_SHOW: 'TVShows',
|
||||
PLEX_TYPE_ARTIST: 'Music',
|
||||
PLEX_TYPE_ALBUM: 'Music',
|
||||
PLEX_TYPE_SONG: 'Music',
|
||||
}
|
||||
|
||||
ITEMTYPE_FROM_KODITYPE = {
|
||||
KODI_TYPE_MOVIE: 'Movies',
|
||||
KODI_TYPE_SEASON: 'TVShows',
|
||||
KODI_TYPE_EPISODE: 'TVShows',
|
||||
KODI_TYPE_SHOW: 'TVShows',
|
||||
KODI_TYPE_ARTIST: 'Music',
|
||||
KODI_TYPE_ALBUM: 'Music',
|
||||
KODI_TYPE_SONG: 'Music',
|
||||
}
|
||||
|
||||
KODITYPE_FROM_PLEXTYPE = {
|
||||
PLEX_TYPE_MOVIE: KODI_TYPE_MOVIE,
|
||||
PLEX_TYPE_EPISODE: KODI_TYPE_EPISODE,
|
||||
PLEX_TYPE_SEASON: KODI_TYPE_SEASON,
|
||||
PLEX_TYPE_SHOW: KODI_TYPE_SHOW,
|
||||
PLEX_TYPE_SONG: KODI_TYPE_SONG,
|
||||
PLEX_TYPE_ARTIST: KODI_TYPE_ARTIST,
|
||||
PLEX_TYPE_ALBUM: KODI_TYPE_ALBUM,
|
||||
PLEX_TYPE_PHOTO: KODI_TYPE_PHOTO,
|
||||
'XXXXXX': 'musicvideo',
|
||||
'XXXXXXX': 'genre'
|
||||
}
|
||||
|
||||
KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE = {
|
||||
PLEX_TYPE_VIDEO: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_MOVIE: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_EPISODE: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_SEASON: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_SHOW: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_CLIP: KODI_TYPE_VIDEO,
|
||||
PLEX_TYPE_ARTIST: KODI_TYPE_AUDIO,
|
||||
PLEX_TYPE_ALBUM: KODI_TYPE_AUDIO,
|
||||
PLEX_TYPE_SONG: KODI_TYPE_AUDIO,
|
||||
PLEX_TYPE_AUDIO: KODI_TYPE_AUDIO
|
||||
}
|
||||
|
||||
|
||||
REMAP_TYPE_FROM_PLEXTYPE = {
|
||||
PLEX_TYPE_MOVIE: 'movie',
|
||||
PLEX_TYPE_CLIP: 'clip',
|
||||
PLEX_TYPE_SHOW: 'tv',
|
||||
PLEX_TYPE_SEASON: 'tv',
|
||||
PLEX_TYPE_EPISODE: 'tv',
|
||||
PLEX_TYPE_ARTIST: 'music',
|
||||
PLEX_TYPE_ALBUM: 'music',
|
||||
PLEX_TYPE_SONG: 'music',
|
||||
PLEX_TYPE_PHOTO: 'photo'
|
||||
}
|
||||
|
||||
|
||||
REMAP_TYPE_FROM_PLEXTYPE = {
|
||||
'movie': 'movie',
|
||||
'show': 'tv',
|
||||
'season': 'tv',
|
||||
'episode': 'tv',
|
||||
'artist': 'music',
|
||||
'album': 'music',
|
||||
'song': 'music',
|
||||
'track': 'music',
|
||||
'clip': 'clip',
|
||||
'photo': 'photo'
|
||||
}
|
||||
|
||||
|
||||
# extensions from:
|
||||
# http://kodi.wiki/view/Features_and_supported_codecs#Format_support (RAW image
|
||||
# formats, BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX and Targa/TGA)
|
||||
KODI_SUPPORTED_IMAGES = (
|
||||
'.bmp',
|
||||
'.jpg',
|
||||
'.jpeg',
|
||||
'.gif',
|
||||
'.png',
|
||||
'.tiff',
|
||||
'.mng',
|
||||
'.ico',
|
||||
'.pcx',
|
||||
'.tga'
|
||||
)
|
14
service.py
14
service.py
|
@ -54,7 +54,6 @@ import loghandler
|
|||
|
||||
loghandler.config()
|
||||
log = logging.getLogger("PLEX.service")
|
||||
addonName = 'PlexKodiConnect'
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -94,10 +93,11 @@ class Service():
|
|||
value=settings('fetch_pms_item_number'))
|
||||
|
||||
# Initial logging
|
||||
log.warn("======== START %s ========" % addonName)
|
||||
log.warn("======== START %s ========" % lang(29999))
|
||||
log.warn("Platform: %s" % (self.clientInfo.getPlatform()))
|
||||
log.warn("KODI Version: %s" % xbmc.getInfoLabel('System.BuildVersion'))
|
||||
log.warn("%s Version: %s" % (addonName, self.clientInfo.getVersion()))
|
||||
log.warn("%s Version: %s"
|
||||
% (lang(29999), self.clientInfo.getVersion()))
|
||||
log.warn("Using plugin paths: %s"
|
||||
% (settings('useDirectPaths') != "true"))
|
||||
log.warn("Number of sync threads: %s"
|
||||
|
@ -187,7 +187,7 @@ class Service():
|
|||
# Reset authentication warnings
|
||||
welcome_msg = False
|
||||
xbmcgui.Dialog().notification(
|
||||
heading=addonName,
|
||||
heading=lang(29999),
|
||||
message="%s %s" % (lang(33000),
|
||||
self.user.currUser),
|
||||
icon="special://home/addons/plugin."
|
||||
|
@ -261,7 +261,7 @@ class Service():
|
|||
xbmcgui.Dialog().notification(
|
||||
heading=lang(33001),
|
||||
message="%s %s"
|
||||
% (addonName, lang(33002)),
|
||||
% (lang(29999), lang(33002)),
|
||||
icon="special://home/addons/plugin.video."
|
||||
"plexkodiconnect/icon.png",
|
||||
sound=False)
|
||||
|
@ -287,7 +287,7 @@ class Service():
|
|||
if (welcome_msg is False and
|
||||
settings('show_pms_offline') == 'true'):
|
||||
xbmcgui.Dialog().notification(
|
||||
heading=addonName,
|
||||
heading=lang(29999),
|
||||
message=lang(33003),
|
||||
icon="special://home/addons/plugin.video."
|
||||
"plexkodiconnect/icon.png",
|
||||
|
@ -340,7 +340,7 @@ class Service():
|
|||
except:
|
||||
pass
|
||||
|
||||
log.warn("======== STOP %s ========" % addonName)
|
||||
log.warn("======== STOP %s ========" % lang(29999))
|
||||
|
||||
# Delay option
|
||||
delay = int(settings('startupDelay'))
|
||||
|
|
Loading…
Reference in a new issue