Get kodiversion only once
This commit is contained in:
parent
9d60b9bbbe
commit
013c15378a
2 changed files with 18 additions and 23 deletions
|
@ -7,12 +7,11 @@ from urllib import urlencode
|
||||||
from ntpath import dirname
|
from ntpath import dirname
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import xbmc
|
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
|
||||||
import artwork
|
import artwork
|
||||||
from utils import tryEncode, tryDecode, settings, window, kodiSQL, \
|
from utils import tryEncode, tryDecode, settings, window, kodiSQL, \
|
||||||
CatchExceptions
|
CatchExceptions, KODIVERSION
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
import kodidb_functions as kodidb
|
import kodidb_functions as kodidb
|
||||||
|
|
||||||
|
@ -36,7 +35,6 @@ class Items(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
|
||||||
self.directpath = window('useDirectPaths') == 'true'
|
self.directpath = window('useDirectPaths') == 'true'
|
||||||
|
|
||||||
self.artwork = artwork.Artwork()
|
self.artwork = artwork.Artwork()
|
||||||
|
@ -435,7 +433,7 @@ class Movies(Items):
|
||||||
% (itemid, title))
|
% (itemid, title))
|
||||||
|
|
||||||
# Update the movie entry
|
# Update the movie entry
|
||||||
if self.kodiversion > 16:
|
if KODIVERSION > 16:
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
"UPDATE movie",
|
"UPDATE movie",
|
||||||
"SET c00 = ?, c01 = ?, c02 = ?, c03 = ?, c04 = ?, c05 = ?,"
|
"SET c00 = ?, c01 = ?, c02 = ?, c03 = ?, c04 = ?, c05 = ?,"
|
||||||
|
@ -466,7 +464,7 @@ class Movies(Items):
|
||||||
##### OR ADD THE MOVIE #####
|
##### OR ADD THE MOVIE #####
|
||||||
else:
|
else:
|
||||||
log.info("ADD movie itemid: %s - Title: %s" % (itemid, title))
|
log.info("ADD movie itemid: %s - Title: %s" % (itemid, title))
|
||||||
if self.kodiversion > 16:
|
if KODIVERSION > 16:
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
INSERT INTO movie( idMovie, idFile, c00, c01, c02, c03,
|
INSERT INTO movie( idMovie, idFile, c00, c01, c02, c03,
|
||||||
|
@ -985,7 +983,7 @@ class TVShows(Items):
|
||||||
log.info("UPDATE episode itemid: %s" % (itemid))
|
log.info("UPDATE episode itemid: %s" % (itemid))
|
||||||
|
|
||||||
# Update the movie entry
|
# Update the movie entry
|
||||||
if self.kodiversion in (16, 17):
|
if KODIVERSION in (16, 17):
|
||||||
# Kodi Jarvis, Krypton
|
# Kodi Jarvis, Krypton
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
"UPDATE episode",
|
"UPDATE episode",
|
||||||
|
@ -1018,7 +1016,7 @@ class TVShows(Items):
|
||||||
else:
|
else:
|
||||||
log.info("ADD episode itemid: %s - Title: %s" % (itemid, title))
|
log.info("ADD episode itemid: %s - Title: %s" % (itemid, title))
|
||||||
# Create the episode entry
|
# Create the episode entry
|
||||||
if self.kodiversion in (16, 17):
|
if KODIVERSION in (16, 17):
|
||||||
# Kodi Jarvis, Krypton
|
# Kodi Jarvis, Krypton
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
|
@ -1318,7 +1316,7 @@ class Music(Items):
|
||||||
itemid, artistid, artisttype, "artist", checksum=checksum)
|
itemid, artistid, artisttype, "artist", checksum=checksum)
|
||||||
|
|
||||||
# Process the artist
|
# Process the artist
|
||||||
if self.kodiversion in (16, 17):
|
if KODIVERSION in (16, 17):
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
"UPDATE artist",
|
"UPDATE artist",
|
||||||
|
@ -1411,7 +1409,7 @@ class Music(Items):
|
||||||
itemid, albumid, "MusicAlbum", "album", checksum=checksum)
|
itemid, albumid, "MusicAlbum", "album", checksum=checksum)
|
||||||
|
|
||||||
# Process the album info
|
# Process the album info
|
||||||
if self.kodiversion == 17:
|
if KODIVERSION == 17:
|
||||||
# Kodi Krypton
|
# Kodi Krypton
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
|
@ -1424,7 +1422,7 @@ class Music(Items):
|
||||||
kodicursor.execute(query, (artistname, year, genre, bio, thumb,
|
kodicursor.execute(query, (artistname, year, genre, bio, thumb,
|
||||||
rating, lastScraped, "album", studio,
|
rating, lastScraped, "album", studio,
|
||||||
albumid))
|
albumid))
|
||||||
elif self.kodiversion == 16:
|
elif KODIVERSION == 16:
|
||||||
# Kodi Jarvis
|
# Kodi Jarvis
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
|
@ -1437,7 +1435,7 @@ class Music(Items):
|
||||||
kodicursor.execute(query, (artistname, year, genre, bio, thumb,
|
kodicursor.execute(query, (artistname, year, genre, bio, thumb,
|
||||||
rating, lastScraped, "album", studio,
|
rating, lastScraped, "album", studio,
|
||||||
albumid))
|
albumid))
|
||||||
elif self.kodiversion == 15:
|
elif KODIVERSION == 15:
|
||||||
# Kodi Isengard
|
# Kodi Isengard
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
|
@ -1679,7 +1677,7 @@ class Music(Items):
|
||||||
log.info("Failed to add album. Creating singles.")
|
log.info("Failed to add album. Creating singles.")
|
||||||
kodicursor.execute("select coalesce(max(idAlbum),0) from album")
|
kodicursor.execute("select coalesce(max(idAlbum),0) from album")
|
||||||
albumid = kodicursor.fetchone()[0] + 1
|
albumid = kodicursor.fetchone()[0] + 1
|
||||||
if self.kodiversion == 16:
|
if KODIVERSION == 16:
|
||||||
# Kodi Jarvis
|
# Kodi Jarvis
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
|
@ -1689,7 +1687,7 @@ class Music(Items):
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
kodicursor.execute(query, (albumid, genre, year, "single"))
|
kodicursor.execute(query, (albumid, genre, year, "single"))
|
||||||
elif self.kodiversion == 15:
|
elif KODIVERSION == 15:
|
||||||
# Kodi Isengard
|
# Kodi Isengard
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
|
@ -1767,7 +1765,7 @@ class Music(Items):
|
||||||
artist_edb = emby_db.getItem_byId(artist_eid)
|
artist_edb = emby_db.getItem_byId(artist_eid)
|
||||||
artistid = artist_edb[0]
|
artistid = artist_edb[0]
|
||||||
finally:
|
finally:
|
||||||
if self.kodiversion >= 17:
|
if KODIVERSION >= 17:
|
||||||
# Kodi Krypton
|
# Kodi Krypton
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
|
@ -1842,11 +1840,11 @@ class Music(Items):
|
||||||
result = kodicursor.fetchone()
|
result = kodicursor.fetchone()
|
||||||
if result and result[0] != album_artists:
|
if result and result[0] != album_artists:
|
||||||
# Field is empty
|
# Field is empty
|
||||||
if self.kodiversion in (16, 17):
|
if KODIVERSION in (16, 17):
|
||||||
# Kodi Jarvis, Krypton
|
# Kodi Jarvis, Krypton
|
||||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||||
kodicursor.execute(query, (album_artists, albumid))
|
kodicursor.execute(query, (album_artists, albumid))
|
||||||
elif self.kodiversion == 15:
|
elif KODIVERSION == 15:
|
||||||
# Kodi Isengard
|
# Kodi Isengard
|
||||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||||
kodicursor.execute(query, (album_artists, albumid))
|
kodicursor.execute(query, (album_artists, albumid))
|
||||||
|
|
|
@ -10,7 +10,7 @@ import xbmc
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
from utils import window, settings, language as lang, IfExists, tryDecode, \
|
from utils import window, settings, language as lang, IfExists, tryDecode, \
|
||||||
tryEncode, indent, normalize_nodes
|
tryEncode, indent, normalize_nodes, KODIVERSION
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -21,9 +21,6 @@ log = logging.getLogger("PLEX."+__name__)
|
||||||
|
|
||||||
class VideoNodes(object):
|
class VideoNodes(object):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.kodiversion = int(xbmc.getInfoLabel('System.BuildVersion')[:2])
|
|
||||||
|
|
||||||
def commonRoot(self, order, label, tagname, roottype=1):
|
def commonRoot(self, order, label, tagname, roottype=1):
|
||||||
|
|
||||||
if roottype == 0:
|
if roottype == 0:
|
||||||
|
@ -235,7 +232,7 @@ class VideoNodes(object):
|
||||||
# Custom query
|
# Custom query
|
||||||
path = ("plugin://plugin.video.plexkodiconnect/?id=%s&mode=recentepisodes&type=%s&tagname=%s&limit=%s"
|
path = ("plugin://plugin.video.plexkodiconnect/?id=%s&mode=recentepisodes&type=%s&tagname=%s&limit=%s"
|
||||||
% (viewid, mediatype, tagname, limit))
|
% (viewid, mediatype, tagname, limit))
|
||||||
elif self.kodiversion == 14 and nodetype == "inprogressepisodes":
|
elif KODIVERSION == 14 and nodetype == "inprogressepisodes":
|
||||||
# Custom query
|
# Custom query
|
||||||
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=inprogressepisodes&limit=%s" % (tagname, limit)
|
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=inprogressepisodes&limit=%s" % (tagname, limit)
|
||||||
elif nodetype == 'ondeck':
|
elif nodetype == 'ondeck':
|
||||||
|
@ -252,7 +249,7 @@ class VideoNodes(object):
|
||||||
if mediatype == "photos":
|
if mediatype == "photos":
|
||||||
windowpath = "ActivateWindow(Pictures,%s,return)" % path
|
windowpath = "ActivateWindow(Pictures,%s,return)" % path
|
||||||
else:
|
else:
|
||||||
if self.kodiversion >= 17:
|
if KODIVERSION >= 17:
|
||||||
# Krypton
|
# Krypton
|
||||||
windowpath = "ActivateWindow(Videos,%s,return)" % path
|
windowpath = "ActivateWindow(Videos,%s,return)" % path
|
||||||
else:
|
else:
|
||||||
|
@ -374,7 +371,7 @@ class VideoNodes(object):
|
||||||
"special://profile/library/video/"))
|
"special://profile/library/video/"))
|
||||||
nodeXML = "%splex_%s.xml" % (nodepath, cleantagname)
|
nodeXML = "%splex_%s.xml" % (nodepath, cleantagname)
|
||||||
path = "library://video/plex_%s.xml" % cleantagname
|
path = "library://video/plex_%s.xml" % cleantagname
|
||||||
if self.kodiversion >= 17:
|
if KODIVERSION >= 17:
|
||||||
# Krypton
|
# Krypton
|
||||||
windowpath = "ActivateWindow(Videos,%s,return)" % path
|
windowpath = "ActivateWindow(Videos,%s,return)" % path
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue