Code optimization

This commit is contained in:
tomkat83 2016-10-29 15:23:48 +02:00
parent 3b80cd3e91
commit 7e58fae9a2
3 changed files with 7 additions and 12 deletions

View file

@ -49,7 +49,7 @@ import clientinfo
import downloadutils import downloadutils
from utils import window, settings, language as lang, tryDecode, tryEncode, \ from utils import window, settings, language as lang, tryDecode, tryEncode, \
DateToKodi DateToKodi
from PlexFunctions import PlexToKodiTimefactor, PMSHttpsEnabled from PlexFunctions import PLEX_TO_KODI_TIMEFACTOR, PMSHttpsEnabled
import embydb_functions as embydb import embydb_functions as embydb
############################################################################### ###############################################################################
@ -1528,8 +1528,8 @@ class API():
except (KeyError, ValueError): except (KeyError, ValueError):
resume = 0.0 resume = 0.0
runtime = int(runtime * PlexToKodiTimefactor()) runtime = int(runtime * PLEX_TO_KODI_TIMEFACTOR)
resume = int(resume * PlexToKodiTimefactor()) resume = int(resume * PLEX_TO_KODI_TIMEFACTOR)
return resume, runtime return resume, runtime
def getMpaa(self): def getMpaa(self):
@ -1749,7 +1749,7 @@ class API():
'key': key, 'key': key,
'title': title, 'title': title,
'thumb': thumb, 'thumb': thumb,
'duration': int(duration * PlexToKodiTimefactor()), 'duration': int(duration * PLEX_TO_KODI_TIMEFACTOR),
'extraType': extraType, 'extraType': extraType,
'originallyAvailableAt': originallyAvailableAt, 'originallyAvailableAt': originallyAvailableAt,
'year': year 'year': year

View file

@ -17,12 +17,7 @@ addonName = 'PlexKodiConnect'
############################################################################### ###############################################################################
PLEX_TO_KODI_TIMEFACTOR = 1.0 / 1000.0
def PlexToKodiTimefactor():
"""
Kodi measures time in seconds, but Plex in milliseconds
"""
return 1.0 / 1000.0
def ConvertPlexToKodiTime(plexTime): def ConvertPlexToKodiTime(plexTime):
@ -31,7 +26,7 @@ def ConvertPlexToKodiTime(plexTime):
""" """
if plexTime is None: if plexTime is None:
return None return None
return int(float(plexTime) * PlexToKodiTimefactor()) return int(float(plexTime) * PLEX_TO_KODI_TIMEFACTOR)
def GetItemClassFromType(itemType): def GetItemClassFromType(itemType):

View file

@ -171,7 +171,7 @@ def playWatchLater(itemid, viewOffset):
int(sys.argv[1]), False, xbmcgui.ListItem()) int(sys.argv[1]), False, xbmcgui.ListItem())
if viewOffset != '0': if viewOffset != '0':
try: try:
viewOffset = int(PlexFunctions.PlexToKodiTimefactor() * viewOffset = int(PlexFunctions.PLEX_TO_KODI_TIMEFACTOR *
float(viewOffset)) float(viewOffset))
except: except:
pass pass