This commit is contained in:
angelblue05 2016-10-12 05:43:19 -05:00 committed by GitHub
parent c124fbff3f
commit 6ad3a548f8
8 changed files with 41 additions and 54 deletions

View file

@ -28,7 +28,6 @@ class API(object):
played = False played = False
last_played = None last_played = None
resume = 0 resume = 0
user_rating = 0
try: try:
userdata = self.item['UserData'] userdata = self.item['UserData']

View file

@ -15,19 +15,17 @@ log = logging.getLogger("EMBY."+__name__)
################################################################################################# #################################################################################################
class Kodidb_Functions(): class Kodidb_Functions(object):
kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2]) kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
def __init__(self, cursor): def __init__(self, cursor):
self.cursor = cursor self.cursor = cursor
self.artwork = artwork.Artwork() self.artwork = artwork.Artwork()
def createTag(self, name): def createTag(self, name):
# This will create and return the tag_id # This will create and return the tag_id
if self.kodiversion in (15, 16, 17): if self.kodiversion in (15, 16, 17):
# Kodi Isengard, Jarvis, Krypton # Kodi Isengard, Jarvis, Krypton
@ -41,14 +39,14 @@ class Kodidb_Functions():
self.cursor.execute(query, (name,)) self.cursor.execute(query, (name,))
try: try:
tag_id = self.cursor.fetchone()[0] tag_id = self.cursor.fetchone()[0]
except TypeError: except TypeError:
self.cursor.execute("select coalesce(max(tag_id),0) from tag") self.cursor.execute("select coalesce(max(tag_id),0) from tag")
tag_id = self.cursor.fetchone()[0] + 1 tag_id = self.cursor.fetchone()[0] + 1
query = "INSERT INTO tag(tag_id, name) values(?, ?)" query = "INSERT INTO tag(tag_id, name) values(?, ?)"
self.cursor.execute(query, (tag_id, name)) self.cursor.execute(query, (tag_id, name))
log.debug("Create tag_id: %s name: %s" % (tag_id, name)) log.debug("Create tag_id: %s name: %s", tag_id, name)
else: else:
# Kodi Helix # Kodi Helix
query = ' '.join(( query = ' '.join((
@ -68,17 +66,17 @@ class Kodidb_Functions():
query = "INSERT INTO tag(idTag, strTag) values(?, ?)" query = "INSERT INTO tag(idTag, strTag) values(?, ?)"
self.cursor.execute(query, (tag_id, name)) self.cursor.execute(query, (tag_id, name))
log.debug("Create idTag: %s name: %s" % (tag_id, name)) log.debug("Create idTag: %s name: %s", tag_id, name)
return tag_id return tag_id
def updateTag(self, oldtag, newtag, kodiid, mediatype): def updateTag(self, oldtag, newtag, kodiid, mediatype):
# TODO: Move to video nodes eventually # TODO: Move to video nodes eventually
log.debug("Updating: %s with %s for %s: %s" % (oldtag, newtag, mediatype, kodiid)) log.debug("Updating: %s with %s for %s: %s", oldtag, newtag, mediatype, kodiid)
if self.kodiversion in (15, 16, 17): if self.kodiversion in (15, 16, 17):
# Kodi Isengard, Jarvis, Krypton # Kodi Isengard, Jarvis, Krypton
try: try:
query = ' '.join(( query = ' '.join((
"UPDATE tag_link", "UPDATE tag_link",
@ -88,7 +86,7 @@ class Kodidb_Functions():
"AND tag_id = ?" "AND tag_id = ?"
)) ))
self.cursor.execute(query, (newtag, kodiid, mediatype, oldtag,)) self.cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
except Exception as e: except Exception:
# The new tag we are going to apply already exists for this item # The new tag we are going to apply already exists for this item
# delete current tag instead # delete current tag instead
query = ' '.join(( query = ' '.join((
@ -111,7 +109,7 @@ class Kodidb_Functions():
"AND idTag = ?" "AND idTag = ?"
)) ))
self.cursor.execute(query, (newtag, kodiid, mediatype, oldtag,)) self.cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
except Exception as e: except Exception:
# The new tag we are going to apply already exists for this item # The new tag we are going to apply already exists for this item
# delete current tag instead # delete current tag instead
query = ' '.join(( query = ' '.join((

View file

@ -6,7 +6,6 @@ import logging
import xbmc import xbmc
import api
import artwork import artwork
################################################################################################## ##################################################################################################
@ -110,7 +109,7 @@ class KodiItems(object):
self.cursor.execute(query, (path, media_type, scraper, 1, path_id)) self.cursor.execute(query, (path, media_type, scraper, 1, path_id))
def remove_path(self, path_id): def remove_path(self, path_id):
kodicursor.execute("DELETE FROM path WHERE idPath = ?", (path_id,)) self.cursor.execute("DELETE FROM path WHERE idPath = ?", (path_id,))
def add_file(self, filename, path_id): def add_file(self, filename, path_id):
@ -180,7 +179,7 @@ class KodiItems(object):
def add_people(self, kodi_id, people, media_type): def add_people(self, kodi_id, people, media_type):
def add_thumbnail(person_id, person, type_): def add_thumbnail(person_id, person, type_):
thumbnail = person['imageurl'] thumbnail = person['imageurl']
if thumbnail: if thumbnail:
@ -221,10 +220,10 @@ class KodiItems(object):
) )
self.cursor.execute(query, (person_id, kodi_id, media_type, role, cast_order)) self.cursor.execute(query, (person_id, kodi_id, media_type, role, cast_order))
cast_order += 1 cast_order += 1
elif type_ == "Director": elif type_ == "Director":
add_link("director_link", person_id, kodi_id, media_type) add_link("director_link", person_id, kodi_id, media_type)
elif type_ in ("Writing", "Writer"): elif type_ in ("Writing", "Writer"):
add_link("writer_link", person_id, kodi_id, media_type) add_link("writer_link", person_id, kodi_id, media_type)
@ -292,7 +291,7 @@ class KodiItems(object):
''' '''
) )
else: return # Item is invalid else: return # Item is invalid
self.cursor.execute(query, (person_id, kodi_id, role, cast_order)) self.cursor.execute(query, (person_id, kodi_id, role, cast_order))
cast_order += 1 cast_order += 1
@ -333,38 +332,32 @@ class KodiItems(object):
if media_type == "movie": if media_type == "movie":
query = ( query = (
''' '''
INSERT OR REPLACE INTO writerlinkmovie( INSERT OR REPLACE INTO writerlinkmovie(idWriter, idMovie)
idWriter, idMovie)
VALUES (?, ?) VALUES (?, ?)
''' '''
) )
elif media_type == "episode": elif media_type == "episode":
query = ( query = (
''' '''
INSERT OR REPLACE INTO writerlinkepisode( INSERT OR REPLACE INTO writerlinkepisode(idWriter, idEpisode)
idWriter, idEpisode)
VALUES (?, ?) VALUES (?, ?)
''' '''
) )
else: return # Item is invalid else: return # Item is invalid
self.cursor.execute(query, (person_id, kodi_id)) self.cursor.execute(query, (person_id, kodi_id))
elif type_ == "Artist": elif type_ == "Artist":
query = ( query = (
''' '''
INSERT OR REPLACE INTO artistlinkmusicvideo( INSERT OR REPLACE INTO artistlinkmusicvideo(idArtist, idMVideo)
idArtist, idMVideo)
VALUES (?, ?) VALUES (?, ?)
''' '''
) )
self.cursor.execute(query, (person_id, kodi_id)) self.cursor.execute(query, (person_id, kodi_id))
add_thumbnail(person_id, person, type_) add_thumbnail(person_id, person, type_)
def _add_person(self, name): def _add_person(self, name):
person_id = self.create_entry_person() person_id = self.create_entry_person()
@ -384,7 +377,7 @@ class KodiItems(object):
"COLLATE NOCASE" "COLLATE NOCASE"
)) ))
self.cursor.execute(query, (name,)) self.cursor.execute(query, (name,))
try: try:
person_id = self.cursor.fetchone()[0] person_id = self.cursor.fetchone()[0]
except TypeError: except TypeError:
@ -406,7 +399,7 @@ class KodiItems(object):
# Add genres # Add genres
for genre in genres: for genre in genres:
genre_id = self._get_genre(genre) genre_id = self._get_genre(genre)
query = ( query = (
''' '''
@ -475,7 +468,7 @@ class KodiItems(object):
''' '''
) )
else: return # Item is invalid else: return # Item is invalid
self.cursor.execute(query, (genre_id, kodi_id)) self.cursor.execute(query, (genre_id, kodi_id))
def _add_genre(self, genre): def _add_genre(self, genre):
@ -514,9 +507,7 @@ class KodiItems(object):
studio_id = self._get_studio(studio) studio_id = self._get_studio(studio)
query = ( query = (
''' '''
INSERT OR REPLACE INTO studio_link( INSERT OR REPLACE INTO studio_link(studio_id, media_id, media_type)
studio_id, media_id, media_type)
VALUES (?, ?, ?) VALUES (?, ?, ?)
''') ''')
self.cursor.execute(query, (studio_id, kodi_id, media_type)) self.cursor.execute(query, (studio_id, kodi_id, media_type))
@ -548,25 +539,25 @@ class KodiItems(object):
if media_type == "movie": if media_type == "movie":
query = ( query = (
''' '''
INSERT OR REPLACE INTO studiolinkmovie(idstudio, idMovie) INSERT OR REPLACE INTO studiolinkmovie(idstudio, idMovie)
VALUES (?, ?) VALUES (?, ?)
''') ''')
elif media_type == "musicvideo": elif media_type == "musicvideo":
query = ( query = (
''' '''
INSERT OR REPLACE INTO studiolinkmusicvideo(idstudio, idMVideo) INSERT OR REPLACE INTO studiolinkmusicvideo(idstudio, idMVideo)
VALUES (?, ?) VALUES (?, ?)
''') ''')
elif media_type == "tvshow": elif media_type == "tvshow":
query = ( query = (
''' '''
INSERT OR REPLACE INTO studiolinktvshow(idstudio, idShow) INSERT OR REPLACE INTO studiolinktvshow(idstudio, idShow)
VALUES (?, ?) VALUES (?, ?)
''') ''')
elif media_type == "episode": elif media_type == "episode":
query = ( query = (
''' '''
INSERT OR REPLACE INTO studiolinkepisode(idstudio, idEpisode) INSERT OR REPLACE INTO studiolinkepisode(idstudio, idEpisode)
VALUES (?, ?) VALUES (?, ?)
''') ''')
self.cursor.execute(query, (studio_id, kodi_id)) self.cursor.execute(query, (studio_id, kodi_id))
@ -606,7 +597,7 @@ class KodiItems(object):
query = ( query = (
''' '''
INSERT INTO streamdetails( INSERT INTO streamdetails(
idFile, iStreamType, strVideoCodec, fVideoAspect, idFile, iStreamType, strVideoCodec, fVideoAspect,
iVideoWidth, iVideoHeight, iVideoDuration ,strStereoMode) iVideoWidth, iVideoHeight, iVideoDuration ,strStereoMode)
VALUES (?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?)

View file

@ -77,7 +77,7 @@ class KodiMovies(KodiItems):
self.cursor.execute(query, (args)) self.cursor.execute(query, (args))
def update_movie(self, *args): def update_movie(self, *args):
query = ' '.join(( query = ' '.join((
"UPDATE movie", "UPDATE movie",
@ -105,9 +105,9 @@ class KodiMovies(KodiItems):
self.cursor.execute("DELETE FROM files WHERE idFile = ?", (file_id,)) self.cursor.execute("DELETE FROM files WHERE idFile = ?", (file_id,))
def add_countries(self, kodi_id, countries): def add_countries(self, kodi_id, countries):
if self.kodi_version > 14: if self.kodi_version > 14:
for country in countries: for country in countries:
country_id = self._get_country(country) country_id = self._get_country(country)
@ -148,7 +148,7 @@ class KodiMovies(KodiItems):
''' '''
) )
self.cursor.execute(query, (country_id, kodi_id)) self.cursor.execute(query, (country_id, kodi_id))
def _add_country(self, country): def _add_country(self, country):
country_id = self.create_entry_country() country_id = self.create_entry_country()
@ -221,5 +221,5 @@ class KodiMovies(KodiItems):
)) ))
self.cursor.execute(query, (movie_id,)) self.cursor.execute(query, (movie_id,))
def remove_boxset(self, set_id): def remove_boxset(self, kodi_id):
self.cursor.execute("DELETE FROM sets WHERE idSet = ?", (kodi_id,)) self.cursor.execute("DELETE FROM sets WHERE idSet = ?", (kodi_id,))

View file

@ -267,7 +267,7 @@ class KodiMusic(KodiItems):
VALUES (?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?)
''' '''
) )
self.cursor.execute(query, (albumid, args)) self.cursor.execute(query, (args))
def add_single_14(self, *args): def add_single_14(self, *args):
# TODO: Remove Helix code when Krypton is RC # TODO: Remove Helix code when Krypton is RC
@ -278,7 +278,7 @@ class KodiMusic(KodiItems):
VALUES (?, ?, ?, ?) VALUES (?, ?, ?, ?)
''' '''
) )
self.cursor.execute(query, (albumid, genre, year, dateadded)) self.cursor.execute(query, (args))
def add_song(self, *args): def add_song(self, *args):
query = ( query = (
@ -313,7 +313,7 @@ class KodiMusic(KodiItems):
VALUES (?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?)
''' '''
) )
kodicursor.execute(query, (kodi_id, song_id, 1, index, artist)) self.cursor.execute(query, (kodi_id, song_id, 1, index, artist))
else: else:
query = ( query = (
''' '''

View file

@ -51,7 +51,7 @@ class KodiMusicVideos(KodiItems):
self.cursor.execute(query, (args)) self.cursor.execute(query, (args))
def update_musicvideo(self, *args): def update_musicvideo(self, *args):
query = ' '.join(( query = ' '.join((
"UPDATE musicvideo", "UPDATE musicvideo",

View file

@ -72,7 +72,7 @@ class KodiTVShows(KodiItems):
self.cursor.execute(query, (args)) self.cursor.execute(query, (args))
def update_tvshow(self, *args): def update_tvshow(self, *args):
query = ' '.join(( query = ' '.join((
"UPDATE tvshow", "UPDATE tvshow",

View file

@ -8,7 +8,6 @@ from ntpath import dirname
import api import api
import embydb_functions as embydb import embydb_functions as embydb
import kodidb_functions as kodidb
import _kodi_tvshows import _kodi_tvshows
from _common import Items from _common import Items
from utils import window, settings, language as lang, catch_except from utils import window, settings, language as lang, catch_except
@ -796,14 +795,14 @@ class TVShows(Items):
log.info("Deleted %s: %s from kodi database", mediatype, itemid) log.info("Deleted %s: %s from kodi database", mediatype, itemid)
def removeShow(self, kodiid): def removeShow(self, kodiid):
kodicursor = self.kodicursor kodicursor = self.kodicursor
self.artwork.delete_artwork(kodiid, "tvshow", kodicursor) self.artwork.delete_artwork(kodiid, "tvshow", kodicursor)
self.kodi_db.remove_tvshow(kodiid) self.kodi_db.remove_tvshow(kodiid)
log.debug("Removed tvshow: %s", kodiid) log.debug("Removed tvshow: %s", kodiid)
def removeSeason(self, kodiid): def removeSeason(self, kodiid):
kodicursor = self.kodicursor kodicursor = self.kodicursor
self.artwork.delete_artwork(kodiid, "season", kodicursor) self.artwork.delete_artwork(kodiid, "season", kodicursor)