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

View file

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

View file

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