Remove Kodi Helix support

This commit is contained in:
croneter 2018-02-25 13:35:09 +01:00
parent eb0d1d21bb
commit ae6fb9ecfa

View file

@ -234,8 +234,6 @@ class Kodidb_Functions():
self.cursor.execute(query, (pathid, filename,))
def addCountries(self, kodiid, countries, mediatype):
if v.KODIVERSION > 14:
# Kodi Isengard, Jarvis, Krypton
for country in countries:
query = ' '.join((
@ -268,42 +266,6 @@ class Kodidb_Functions():
'''
)
self.cursor.execute(query, (country_id, kodiid, mediatype))
else:
# Kodi Helix
for country in countries:
query = ' '.join((
"SELECT idCountry",
"FROM country",
"WHERE strCountry = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (country,))
try:
idCountry = self.cursor.fetchone()[0]
except TypeError:
# Country entry does not exists
self.cursor.execute("select coalesce(max(idCountry),0) from country")
idCountry = self.cursor.fetchone()[0] + 1
query = "INSERT INTO country(idCountry, strCountry) values(?, ?)"
self.cursor.execute(query, (idCountry, country))
log.debug("Add country to media, processing: %s" % country)
finally:
# Only movies have a country field
if "movie" in mediatype:
query = (
'''
INSERT OR REPLACE INTO countrylinkmovie(
idCountry, idMovie)
VALUES (?, ?)
'''
)
self.cursor.execute(query, (idCountry, kodiid))
def _getactorid(self, name):
"""
@ -420,10 +382,6 @@ class Kodidb_Functions():
return result
def addGenres(self, kodiid, genres, mediatype):
# Kodi Isengard, Jarvis, Krypton
if v.KODIVERSION > 14:
# Delete current genres for clean slate
query = ' '.join((
@ -468,77 +426,9 @@ class Kodidb_Functions():
'''
)
self.cursor.execute(query, (genre_id, kodiid, mediatype))
else:
# Kodi Helix
# Delete current genres for clean slate
if "movie" in mediatype:
self.cursor.execute("DELETE FROM genrelinkmovie WHERE idMovie = ?", (kodiid,))
elif "tvshow" in mediatype:
self.cursor.execute("DELETE FROM genrelinktvshow WHERE idShow = ?", (kodiid,))
elif "musicvideo" in mediatype:
self.cursor.execute("DELETE FROM genrelinkmusicvideo WHERE idMVideo = ?", (kodiid,))
# Add genres
for genre in genres:
query = ' '.join((
"SELECT idGenre",
"FROM genre",
"WHERE strGenre = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (genre,))
try:
idGenre = self.cursor.fetchone()[0]
except TypeError:
# Create genre in database
self.cursor.execute("select coalesce(max(idGenre),0) from genre")
idGenre = self.cursor.fetchone()[0] + 1
query = "INSERT INTO genre(idGenre, strGenre) values(?, ?)"
self.cursor.execute(query, (idGenre, genre))
log.debug("Add Genres to media, processing: %s" % genre)
finally:
# Assign genre to item
if "movie" in mediatype:
query = (
'''
INSERT OR REPLACE into genrelinkmovie(
idGenre, idMovie)
VALUES (?, ?)
'''
)
elif "tvshow" in mediatype:
query = (
'''
INSERT OR REPLACE into genrelinktvshow(
idGenre, idShow)
VALUES (?, ?)
'''
)
elif "musicvideo" in mediatype:
query = (
'''
INSERT OR REPLACE into genrelinkmusicvideo(
idGenre, idMVideo)
VALUES (?, ?)
'''
)
else: return # Item is invalid
self.cursor.execute(query, (idGenre, kodiid))
def addStudios(self, kodiid, studios, mediatype):
for studio in studios:
if v.KODIVERSION > 14:
# Kodi Isengard, Jarvis, Krypton
query = ' '.join((
"SELECT studio_id",
@ -568,54 +458,6 @@ class Kodidb_Functions():
VALUES (?, ?, ?)
''')
self.cursor.execute(query, (studioid, kodiid, mediatype))
else:
# Kodi Helix
query = ' '.join((
"SELECT idstudio",
"FROM studio",
"WHERE strstudio = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (studio,))
try:
studioid = self.cursor.fetchone()[0]
except TypeError:
# Studio does not exists.
self.cursor.execute("select coalesce(max(idstudio),0) from studio")
studioid = self.cursor.fetchone()[0] + 1
query = "INSERT INTO studio(idstudio, strstudio) values(?, ?)"
self.cursor.execute(query, (studioid, studio))
log.debug("Add Studios to media, processing: %s" % studio)
finally: # Assign studio to item
if "movie" in mediatype:
query = (
'''
INSERT OR REPLACE INTO studiolinkmovie(idstudio, idMovie)
VALUES (?, ?)
''')
elif "musicvideo" in mediatype:
query = (
'''
INSERT OR REPLACE INTO studiolinkmusicvideo(idstudio, idMVideo)
VALUES (?, ?)
''')
elif "tvshow" in mediatype:
query = (
'''
INSERT OR REPLACE INTO studiolinktvshow(idstudio, idShow)
VALUES (?, ?)
''')
elif "episode" in mediatype:
query = (
'''
INSERT OR REPLACE INTO studiolinkepisode(idstudio, idEpisode)
VALUES (?, ?)
''')
self.cursor.execute(query, (studioid, kodiid))
def addStreams(self, fileid, streamdetails, runtime):
@ -904,8 +746,6 @@ class Kodidb_Functions():
def addTags(self, kodiid, tags, mediatype):
# First, delete any existing tags associated to the id
if v.KODIVERSION > 14:
# Kodi Isengard, Jarvis, Krypton
query = ' '.join((
"DELETE FROM tag_link",
@ -913,15 +753,6 @@ class Kodidb_Functions():
"AND media_type = ?"
))
self.cursor.execute(query, (kodiid, mediatype))
else:
# Kodi Helix
query = ' '.join((
"DELETE FROM taglinks",
"WHERE idMedia = ?",
"AND media_type = ?"
))
self.cursor.execute(query, (kodiid, mediatype))
# Add tags
log.debug("Adding Tags: %s" % tags)
@ -929,8 +760,6 @@ class Kodidb_Functions():
self.addTag(kodiid, tag, mediatype)
def addTag(self, kodiid, tag, mediatype):
if v.KODIVERSION > 14:
# Kodi Isengard, Jarvis, Krypton
query = ' '.join((
"SELECT tag_id",
@ -958,40 +787,9 @@ class Kodidb_Functions():
'''
)
self.cursor.execute(query, (tag_id, kodiid, mediatype))
else:
# Kodi Helix
query = ' '.join((
"SELECT idTag",
"FROM tag",
"WHERE strTag = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (tag,))
try:
tag_id = self.cursor.fetchone()[0]
except TypeError:
# Create the tag
tag_id = self.createTag(tag)
log.debug("Adding tag: %s" % tag)
finally:
# Assign tag to item
query = (
'''
INSERT OR REPLACE INTO taglinks(
idTag, idMedia, media_type)
VALUES (?, ?, ?)
'''
)
self.cursor.execute(query, (tag_id, kodiid, mediatype))
def createTag(self, name):
# This will create and return the tag_id
if v.KODIVERSION > 14:
# Kodi Isengard, Jarvis, Krypton
query = ' '.join((
"SELECT tag_id",
@ -1010,32 +808,9 @@ class Kodidb_Functions():
query = "INSERT INTO tag(tag_id, name) values(?, ?)"
self.cursor.execute(query, (tag_id, name))
log.debug("Create tag_id: %s name: %s" % (tag_id, name))
else:
# Kodi Helix
query = ' '.join((
"SELECT idTag",
"FROM tag",
"WHERE strTag = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (name,))
try:
tag_id = self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute("select coalesce(max(idTag),0) from tag")
tag_id = self.cursor.fetchone()[0] + 1
query = "INSERT INTO tag(idTag, strTag) values(?, ?)"
self.cursor.execute(query, (tag_id, name))
log.debug("Create idTag: %s name: %s" % (tag_id, name))
return tag_id
def updateTag(self, oldtag, newtag, kodiid, mediatype):
if v.KODIVERSION > 14:
# Kodi Isengard, Jarvis, Krypton
try:
query = ' '.join((
@ -1057,33 +832,8 @@ class Kodidb_Functions():
"AND tag_id = ?"
))
self.cursor.execute(query, (kodiid, mediatype, oldtag,))
else:
# Kodi Helix
try:
query = ' '.join((
"UPDATE taglinks",
"SET idTag = ?",
"WHERE idMedia = ?",
"AND media_type = ?",
"AND idTag = ?"
))
self.cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
except Exception as e:
# The new tag we are going to apply already exists for this item
# delete current tag instead
query = ' '.join((
"DELETE FROM taglinks",
"WHERE idMedia = ?",
"AND media_type = ?",
"AND idTag = ?"
))
self.cursor.execute(query, (kodiid, mediatype, oldtag,))
def removeTag(self, kodiid, tagname, mediatype):
if v.KODIVERSION > 14:
# Kodi Isengard, Jarvis, Krypton
query = ' '.join((
"SELECT tag_id",
@ -1105,29 +855,6 @@ class Kodidb_Functions():
"AND tag_id = ?"
))
self.cursor.execute(query, (kodiid, mediatype, tag_id,))
else:
# Kodi Helix
query = ' '.join((
"SELECT idTag",
"FROM tag",
"WHERE strTag = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (tagname,))
try:
tag_id = self.cursor.fetchone()[0]
except TypeError:
return
else:
query = ' '.join((
"DELETE FROM taglinks",
"WHERE idMedia = ?",
"AND media_type = ?",
"AND idTag = ?"
))
self.cursor.execute(query, (kodiid, mediatype, tag_id,))
def addSets(self, movieid, collections, kodicursor):
for setname in collections:
@ -1263,7 +990,6 @@ class Kodidb_Functions():
# Create the album
self.cursor.execute("select coalesce(max(idAlbum),0) from album")
albumid = self.cursor.fetchone()[0] + 1
if v.KODIVERSION > 14:
query = (
'''
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType)
@ -1272,16 +998,6 @@ class Kodidb_Functions():
'''
)
self.cursor.execute(query, (albumid, name, musicbrainz, "album"))
else: # Helix
query = (
'''
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID)
VALUES (?, ?, ?)
'''
)
self.cursor.execute(query, (albumid, name, musicbrainz))
return albumid
def addMusicGenres(self, kodiid, genres, mediatype):