mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
Pylint (#69)
This commit is contained in:
parent
c124fbff3f
commit
6ad3a548f8
8 changed files with 41 additions and 54 deletions
|
@ -28,7 +28,6 @@ class API(object):
|
|||
played = False
|
||||
last_played = None
|
||||
resume = 0
|
||||
user_rating = 0
|
||||
|
||||
try:
|
||||
userdata = self.item['UserData']
|
||||
|
|
|
@ -15,19 +15,17 @@ log = logging.getLogger("EMBY."+__name__)
|
|||
|
||||
#################################################################################################
|
||||
|
||||
class Kodidb_Functions():
|
||||
class Kodidb_Functions(object):
|
||||
|
||||
kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
||||
|
||||
|
||||
def __init__(self, cursor):
|
||||
|
||||
|
||||
self.cursor = cursor
|
||||
|
||||
self.artwork = artwork.Artwork()
|
||||
|
||||
def createTag(self, name):
|
||||
|
||||
# This will create and return the tag_id
|
||||
if self.kodiversion in (15, 16, 17):
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
|
@ -41,14 +39,14 @@ class Kodidb_Functions():
|
|||
self.cursor.execute(query, (name,))
|
||||
try:
|
||||
tag_id = self.cursor.fetchone()[0]
|
||||
|
||||
|
||||
except TypeError:
|
||||
self.cursor.execute("select coalesce(max(tag_id),0) from tag")
|
||||
tag_id = self.cursor.fetchone()[0] + 1
|
||||
|
||||
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))
|
||||
log.debug("Create tag_id: %s name: %s", tag_id, name)
|
||||
else:
|
||||
# Kodi Helix
|
||||
query = ' '.join((
|
||||
|
@ -68,17 +66,17 @@ class Kodidb_Functions():
|
|||
|
||||
query = "INSERT INTO tag(idTag, strTag) values(?, ?)"
|
||||
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
|
||||
|
||||
def updateTag(self, oldtag, newtag, kodiid, mediatype):
|
||||
# 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):
|
||||
# Kodi Isengard, Jarvis, Krypton
|
||||
try:
|
||||
try:
|
||||
query = ' '.join((
|
||||
|
||||
"UPDATE tag_link",
|
||||
|
@ -88,7 +86,7 @@ class Kodidb_Functions():
|
|||
"AND tag_id = ?"
|
||||
))
|
||||
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
|
||||
# delete current tag instead
|
||||
query = ' '.join((
|
||||
|
@ -111,7 +109,7 @@ class Kodidb_Functions():
|
|||
"AND idTag = ?"
|
||||
))
|
||||
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
|
||||
# delete current tag instead
|
||||
query = ' '.join((
|
||||
|
|
|
@ -6,7 +6,6 @@ import logging
|
|||
|
||||
import xbmc
|
||||
|
||||
import api
|
||||
import artwork
|
||||
|
||||
##################################################################################################
|
||||
|
@ -110,7 +109,7 @@ class KodiItems(object):
|
|||
self.cursor.execute(query, (path, media_type, scraper, 1, 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):
|
||||
|
||||
|
@ -180,7 +179,7 @@ class KodiItems(object):
|
|||
def add_people(self, kodi_id, people, media_type):
|
||||
|
||||
def add_thumbnail(person_id, person, type_):
|
||||
|
||||
|
||||
thumbnail = person['imageurl']
|
||||
if thumbnail:
|
||||
|
||||
|
@ -221,10 +220,10 @@ class KodiItems(object):
|
|||
)
|
||||
self.cursor.execute(query, (person_id, kodi_id, media_type, role, cast_order))
|
||||
cast_order += 1
|
||||
|
||||
|
||||
elif type_ == "Director":
|
||||
add_link("director_link", person_id, kodi_id, media_type)
|
||||
|
||||
|
||||
elif type_ in ("Writing", "Writer"):
|
||||
add_link("writer_link", person_id, kodi_id, media_type)
|
||||
|
||||
|
@ -292,7 +291,7 @@ class KodiItems(object):
|
|||
'''
|
||||
)
|
||||
else: return # Item is invalid
|
||||
|
||||
|
||||
self.cursor.execute(query, (person_id, kodi_id, role, cast_order))
|
||||
cast_order += 1
|
||||
|
||||
|
@ -333,38 +332,32 @@ class KodiItems(object):
|
|||
if media_type == "movie":
|
||||
query = (
|
||||
'''
|
||||
INSERT OR REPLACE INTO writerlinkmovie(
|
||||
idWriter, idMovie)
|
||||
|
||||
INSERT OR REPLACE INTO writerlinkmovie(idWriter, idMovie)
|
||||
VALUES (?, ?)
|
||||
'''
|
||||
)
|
||||
elif media_type == "episode":
|
||||
query = (
|
||||
'''
|
||||
INSERT OR REPLACE INTO writerlinkepisode(
|
||||
idWriter, idEpisode)
|
||||
|
||||
INSERT OR REPLACE INTO writerlinkepisode(idWriter, idEpisode)
|
||||
VALUES (?, ?)
|
||||
'''
|
||||
)
|
||||
else: return # Item is invalid
|
||||
|
||||
|
||||
self.cursor.execute(query, (person_id, kodi_id))
|
||||
|
||||
elif type_ == "Artist":
|
||||
query = (
|
||||
'''
|
||||
INSERT OR REPLACE INTO artistlinkmusicvideo(
|
||||
idArtist, idMVideo)
|
||||
|
||||
INSERT OR REPLACE INTO artistlinkmusicvideo(idArtist, idMVideo)
|
||||
VALUES (?, ?)
|
||||
'''
|
||||
)
|
||||
self.cursor.execute(query, (person_id, kodi_id))
|
||||
|
||||
add_thumbnail(person_id, person, type_)
|
||||
|
||||
|
||||
def _add_person(self, name):
|
||||
|
||||
person_id = self.create_entry_person()
|
||||
|
@ -384,7 +377,7 @@ class KodiItems(object):
|
|||
"COLLATE NOCASE"
|
||||
))
|
||||
self.cursor.execute(query, (name,))
|
||||
|
||||
|
||||
try:
|
||||
person_id = self.cursor.fetchone()[0]
|
||||
except TypeError:
|
||||
|
@ -406,7 +399,7 @@ class KodiItems(object):
|
|||
|
||||
# Add genres
|
||||
for genre in genres:
|
||||
|
||||
|
||||
genre_id = self._get_genre(genre)
|
||||
query = (
|
||||
'''
|
||||
|
@ -475,7 +468,7 @@ class KodiItems(object):
|
|||
'''
|
||||
)
|
||||
else: return # Item is invalid
|
||||
|
||||
|
||||
self.cursor.execute(query, (genre_id, kodi_id))
|
||||
|
||||
def _add_genre(self, genre):
|
||||
|
@ -514,9 +507,7 @@ class KodiItems(object):
|
|||
studio_id = self._get_studio(studio)
|
||||
query = (
|
||||
'''
|
||||
INSERT OR REPLACE INTO studio_link(
|
||||
studio_id, media_id, media_type)
|
||||
|
||||
INSERT OR REPLACE INTO studio_link(studio_id, media_id, media_type)
|
||||
VALUES (?, ?, ?)
|
||||
''')
|
||||
self.cursor.execute(query, (studio_id, kodi_id, media_type))
|
||||
|
@ -548,25 +539,25 @@ class KodiItems(object):
|
|||
if media_type == "movie":
|
||||
query = (
|
||||
'''
|
||||
INSERT OR REPLACE INTO studiolinkmovie(idstudio, idMovie)
|
||||
INSERT OR REPLACE INTO studiolinkmovie(idstudio, idMovie)
|
||||
VALUES (?, ?)
|
||||
''')
|
||||
elif media_type == "musicvideo":
|
||||
query = (
|
||||
'''
|
||||
INSERT OR REPLACE INTO studiolinkmusicvideo(idstudio, idMVideo)
|
||||
INSERT OR REPLACE INTO studiolinkmusicvideo(idstudio, idMVideo)
|
||||
VALUES (?, ?)
|
||||
''')
|
||||
elif media_type == "tvshow":
|
||||
query = (
|
||||
'''
|
||||
INSERT OR REPLACE INTO studiolinktvshow(idstudio, idShow)
|
||||
INSERT OR REPLACE INTO studiolinktvshow(idstudio, idShow)
|
||||
VALUES (?, ?)
|
||||
''')
|
||||
elif media_type == "episode":
|
||||
query = (
|
||||
'''
|
||||
INSERT OR REPLACE INTO studiolinkepisode(idstudio, idEpisode)
|
||||
INSERT OR REPLACE INTO studiolinkepisode(idstudio, idEpisode)
|
||||
VALUES (?, ?)
|
||||
''')
|
||||
self.cursor.execute(query, (studio_id, kodi_id))
|
||||
|
@ -606,7 +597,7 @@ class KodiItems(object):
|
|||
query = (
|
||||
'''
|
||||
INSERT INTO streamdetails(
|
||||
idFile, iStreamType, strVideoCodec, fVideoAspect,
|
||||
idFile, iStreamType, strVideoCodec, fVideoAspect,
|
||||
iVideoWidth, iVideoHeight, iVideoDuration ,strStereoMode)
|
||||
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
|
|
|
@ -77,7 +77,7 @@ class KodiMovies(KodiItems):
|
|||
self.cursor.execute(query, (args))
|
||||
|
||||
def update_movie(self, *args):
|
||||
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
"UPDATE movie",
|
||||
|
@ -105,9 +105,9 @@ class KodiMovies(KodiItems):
|
|||
self.cursor.execute("DELETE FROM files WHERE idFile = ?", (file_id,))
|
||||
|
||||
def add_countries(self, kodi_id, countries):
|
||||
|
||||
|
||||
if self.kodi_version > 14:
|
||||
|
||||
|
||||
for country in countries:
|
||||
country_id = self._get_country(country)
|
||||
|
||||
|
@ -148,7 +148,7 @@ class KodiMovies(KodiItems):
|
|||
'''
|
||||
)
|
||||
self.cursor.execute(query, (country_id, kodi_id))
|
||||
|
||||
|
||||
def _add_country(self, country):
|
||||
|
||||
country_id = self.create_entry_country()
|
||||
|
@ -221,5 +221,5 @@ class KodiMovies(KodiItems):
|
|||
))
|
||||
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,))
|
||||
|
|
|
@ -267,7 +267,7 @@ class KodiMusic(KodiItems):
|
|||
VALUES (?, ?, ?, ?, ?)
|
||||
'''
|
||||
)
|
||||
self.cursor.execute(query, (albumid, args))
|
||||
self.cursor.execute(query, (args))
|
||||
|
||||
def add_single_14(self, *args):
|
||||
# TODO: Remove Helix code when Krypton is RC
|
||||
|
@ -278,7 +278,7 @@ class KodiMusic(KodiItems):
|
|||
VALUES (?, ?, ?, ?)
|
||||
'''
|
||||
)
|
||||
self.cursor.execute(query, (albumid, genre, year, dateadded))
|
||||
self.cursor.execute(query, (args))
|
||||
|
||||
def add_song(self, *args):
|
||||
query = (
|
||||
|
@ -313,7 +313,7 @@ class KodiMusic(KodiItems):
|
|||
VALUES (?, ?, ?, ?, ?)
|
||||
'''
|
||||
)
|
||||
kodicursor.execute(query, (kodi_id, song_id, 1, index, artist))
|
||||
self.cursor.execute(query, (kodi_id, song_id, 1, index, artist))
|
||||
else:
|
||||
query = (
|
||||
'''
|
||||
|
|
|
@ -51,7 +51,7 @@ class KodiMusicVideos(KodiItems):
|
|||
self.cursor.execute(query, (args))
|
||||
|
||||
def update_musicvideo(self, *args):
|
||||
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
"UPDATE musicvideo",
|
||||
|
|
|
@ -72,7 +72,7 @@ class KodiTVShows(KodiItems):
|
|||
self.cursor.execute(query, (args))
|
||||
|
||||
def update_tvshow(self, *args):
|
||||
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
"UPDATE tvshow",
|
||||
|
|
|
@ -8,7 +8,6 @@ from ntpath import dirname
|
|||
|
||||
import api
|
||||
import embydb_functions as embydb
|
||||
import kodidb_functions as kodidb
|
||||
import _kodi_tvshows
|
||||
from _common import Items
|
||||
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)
|
||||
|
||||
def removeShow(self, kodiid):
|
||||
|
||||
|
||||
kodicursor = self.kodicursor
|
||||
self.artwork.delete_artwork(kodiid, "tvshow", kodicursor)
|
||||
self.kodi_db.remove_tvshow(kodiid)
|
||||
log.debug("Removed tvshow: %s", kodiid)
|
||||
|
||||
def removeSeason(self, kodiid):
|
||||
|
||||
|
||||
kodicursor = self.kodicursor
|
||||
|
||||
self.artwork.delete_artwork(kodiid, "season", kodicursor)
|
||||
|
|
Loading…
Reference in a new issue