Most flake8 warnings corrected

This commit is contained in:
Odd Stråbø 2019-10-03 04:14:54 +02:00
commit 00765c0a12
58 changed files with 1144 additions and 1262 deletions

View file

@ -17,7 +17,7 @@ import requests
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
@ -37,7 +37,6 @@ class Artwork(object):
'port': settings('webServerPort')
}
def update(self, image_url, kodi_id, media, image):
''' Update artwork in the video database.
@ -210,7 +209,7 @@ class GetArtworkWorker(threading.Thread):
prep = req.prepare()
prep.url = "http://%s:%s/image/image://%s" % (self.kodi['host'], self.kodi['port'], url)
s.send(prep, timeout=(0.01, 0.01))
s.content # release the connection
s.content # release the connection
except Exception as error:
LOG.exception(error)
@ -220,8 +219,6 @@ class GetArtworkWorker(threading.Thread):
break
"""
# -*- coding: utf-8 -*-
@ -381,4 +378,3 @@ class Artwork(object):
count += 1
"""

View file

@ -12,14 +12,13 @@ from helper import values
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
class Kodi(object):
def __init__(self):
self.artwork = artwork.Artwork(self.cursor)
@ -215,7 +214,7 @@ class Kodi(object):
return self.add_studio(*args)
def add_streams(self, file_id, streams, runtime):
''' First remove any existing entries
Then re-add video, audio and subtitles.
'''

View file

@ -9,14 +9,13 @@ import queries as QU
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
class Movies(Kodi):
def __init__(self, cursor):
self.cursor = cursor
@ -29,7 +28,7 @@ class Movies(Kodi):
def create_entry_rating(self):
self.cursor.execute(QU.create_rating)
return self.cursor.fetchone()[0] + 1
def create_entry(self):

View file

@ -9,7 +9,7 @@ from kodi import Kodi
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
@ -34,17 +34,17 @@ class Music(Kodi):
def create_entry_album(self):
self.cursor.execute(QU.create_album)
return self.cursor.fetchone()[0] + 1
def create_entry_song(self):
self.cursor.execute(QU.create_song)
return self.cursor.fetchone()[0] + 1
def create_entry_genre(self):
self.cursor.execute(QU.create_genre)
return self.cursor.fetchone()[0] + 1
def update_path(self, *args):
@ -212,7 +212,7 @@ class Music(Kodi):
''' Add genres, but delete current genres first.
Album_genres was removed in kodi 18
'''
if media == 'album' and self.version_id < 72 :
if media == 'album' and self.version_id < 72:
self.cursor.execute(QU.delete_genres_album, (kodi_id,))
for genre in genres:
@ -258,11 +258,11 @@ class Music(Kodi):
return self.cursor.fetchone()[0]
#current bug in Kodi 18 that will ask for a scan of music tags unless this is set without a lastscanned
# current bug in Kodi 18 that will ask for a scan of music tags unless this is set without a lastscanned
def update_versiontagscan(self):
if self.version_id < 72:
return
else:
self.cursor.execute(QU.get_versiontagcount)
if self.cursor.fetchone()[0] == 0:
self.cursor.execute(QU.update_versiontag, (self.version_id,))
self.cursor.execute(QU.update_versiontag, (self.version_id,))

View file

@ -9,14 +9,13 @@ from kodi import Kodi
##################################################################################################
log = logging.getLogger("JELLYFIN."+__name__)
log = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
class MusicVideos(Kodi):
def __init__(self, cursor):
self.cursor = cursor
@ -31,7 +30,7 @@ class MusicVideos(Kodi):
try:
self.cursor.execute(QU.get_musicvideo, args)
return self.cursor.fetchone()[0]
except TypeError:
return

File diff suppressed because it is too large Load diff

View file

@ -1,238 +1,212 @@
create_artist = """ SELECT coalesce(max(idArtist), 1)
FROM artist
"""
create_album = """ SELECT coalesce(max(idAlbum), 0)
FROM album
"""
create_song = """ SELECT coalesce(max(idSong), 0)
FROM song
"""
create_genre = """ SELECT coalesce(max(idGenre), 0)
FROM genre
"""
get_artist = """ SELECT idArtist, strArtist
FROM artist
WHERE strMusicBrainzArtistID = ?
"""
get_artist_obj = [ "{ArtistId}","{Name}","{UniqueId}"
]
get_artist_by_name = """ SELECT idArtist
FROM artist
WHERE strArtist = ?
COLLATE NOCASE
"""
get_artist_by_id = """ SELECT *
FROM artist
WHERE idArtist = ?
"""
get_artist_by_id_obj = [ "{ArtistId}"
]
get_album_by_id = """ SELECT *
FROM album
WHERE idAlbum = ?
"""
get_album_by_id_obj = [ "{AlbumId}"
]
get_song_by_id = """ SELECT *
FROM song
WHERE idSong = ?
"""
get_song_by_id_obj = [ "{SongId}"
]
get_album = """ SELECT idAlbum
FROM album
WHERE strMusicBrainzAlbumID = ?
"""
get_album_obj = [ "{AlbumId}","{Title}","{UniqueId}","{Artists}","album"
]
get_album_by_name = """ SELECT idAlbum, strArtists
FROM album
WHERE strAlbum = ?
"""
get_album_by_name72 = """ SELECT idAlbum, strArtistDisp
FROM album
WHERE strAlbum = ?
"""
get_album_artist = """ SELECT strArtists
FROM album
WHERE idAlbum = ?
"""
get_album_artist72 = """ SELECT strArtistDisp
FROM album
WHERE idAlbum = ?
"""
get_album_artist_obj = [ "{AlbumId}","{strAlbumArtists}"
]
get_genre = """ SELECT idGenre
FROM genre
WHERE strGenre = ?
COLLATE NOCASE
"""
get_total_episodes = """ SELECT totalCount
FROM tvshowcounts
WHERE idShow = ?
"""
add_artist = """ INSERT INTO artist(idArtist, strArtist, strMusicBrainzArtistID)
VALUES (?, ?, ?)
"""
add_album = """ INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType)
VALUES (?, ?, ?, ?)
"""
add_album72 = """ INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType, bScrapedMBID)
VALUES (?, ?, ?, ?, 1)
"""
add_single = """ INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType)
VALUES (?, ?, ?, ?)
"""
add_single_obj = [ "{AlbumId}","{Genre}","{Year}","single"
]
add_song = """ INSERT INTO song(idSong, idAlbum, idPath, strArtists, strGenres, strTitle, iTrack,
iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed,
rating, comment, dateAdded)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
"""
add_song72 = """ INSERT INTO song(idSong, idAlbum, idPath, strArtistDisp, strGenres, strTitle, iTrack,
iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed,
rating, comment, dateAdded)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
"""
add_song_obj = [ "{SongId}","{AlbumId}","{PathId}","{Artists}","{Genre}","{Title}","{Index}",
"{Runtime}","{Year}","{Filename}","{UniqueId}","{PlayCount}","{DatePlayed}","{Rating}",
"{Comment}","{DateAdded}"
]
add_genre = """ INSERT INTO genre(idGenre, strGenre)
VALUES (?, ?)
"""
add_genres_obj = [ "{AlbumId}","{Genres}","album"
]
update_path = """ UPDATE path
SET strPath = ?
WHERE idPath = ?
"""
update_path_obj = [ "{Path}","{PathId}"
]
update_role = """ INSERT OR REPLACE INTO role(idRole, strRole)
VALUES (?, ?)
"""
update_role_obj = [ 1,"Composer"
]
update_artist_name = """ UPDATE artist
SET strArtist = ?
WHERE idArtist = ?
"""
update_artist_name_obj = [ "{Name}","{ArtistId}"
]
update_artist = """ UPDATE artist
SET strGenres = ?, strBiography = ?, strImage = ?, strFanart = ?, lastScraped = ?
WHERE idArtist = ?
"""
update_link = """ INSERT OR REPLACE INTO album_artist(idArtist, idAlbum, strArtist)
VALUES (?, ?, ?)
"""
update_link_obj = [ "{ArtistId}","{AlbumId}","{Name}"
]
update_discography = """ INSERT OR REPLACE INTO discography(idArtist, strAlbum, strYear)
VALUES (?, ?, ?)
"""
update_discography_obj = [ "{ArtistId}","{Title}","{Year}"
]
update_album = """ UPDATE album
SET strArtists = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?,
iUserrating = ?, lastScraped = ?, strReleaseType = ?
WHERE idAlbum = ?
"""
update_album72 = """ UPDATE album
SET strArtistDisp = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?,
iUserrating = ?, lastScraped = ?, bScrapedMBID = 1, strReleaseType = ?
WHERE idAlbum = ?
"""
update_album_obj = [ "{Artists}","{Year}","{Genre}","{Bio}","{Thumb}","{Rating}","{LastScraped}",
"album","{AlbumId}"
]
update_album_artist = """ UPDATE album
SET strArtists = ?
WHERE idAlbum = ?
"""
update_album_artist72 = """ UPDATE album
SET strArtistDisp = ?
WHERE idAlbum = ?
"""
update_song = """ UPDATE song
SET idAlbum = ?, strArtists = ?, strGenres = ?, strTitle = ?, iTrack = ?,
iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?,
rating = ?, comment = ?, dateAdded = ?
WHERE idSong = ?
"""
update_song72 = """ UPDATE song
SET idAlbum = ?, strArtistDisp = ?, strGenres = ?, strTitle = ?, iTrack = ?,
iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?,
rating = ?, comment = ?, dateAdded = ?
WHERE idSong = ?
"""
update_song_obj = [ "{AlbumId}","{Artists}","{Genre}","{Title}","{Index}","{Runtime}","{Year}",
"{Filename}","{PlayCount}","{DatePlayed}","{Rating}","{Comment}",
"{DateAdded}","{SongId}"
]
update_song_artist = """ INSERT OR REPLACE INTO song_artist(idArtist, idSong, idRole, iOrder, strArtist)
VALUES (?, ?, ?, ?, ?)
"""
update_song_artist_obj = [ "{ArtistId}","{SongId}",1,"{Index}","{Name}"
]
update_song_album = """ INSERT OR REPLACE INTO albuminfosong(idAlbumInfoSong, idAlbumInfo, iTrack,
strTitle, iDuration)
VALUES (?, ?, ?, ?, ?)
"""
update_song_album_obj = [ "{SongId}","{AlbumId}","{Index}","{Title}","{Runtime}"
]
update_song_rating = """ UPDATE song
SET iTimesPlayed = ?, lastplayed = ?, rating = ?
WHERE idSong = ?
"""
update_song_rating_obj = [ "{PlayCount}","{DatePlayed}","{Rating}","{KodiId}"
]
update_genre_album = """ INSERT OR REPLACE INTO album_genre(idGenre, idAlbum)
VALUES (?, ?)
"""
update_genre_song = """ INSERT OR REPLACE INTO song_genre(idGenre, idSong)
VALUES (?, ?)
"""
update_genre_song_obj = [ "{SongId}","{Genres}","song"
]
delete_genres_album = """ DELETE FROM album_genre
WHERE idAlbum = ?
"""
delete_genres_song = """ DELETE FROM song_genre
WHERE idSong = ?
"""
delete_artist = """ DELETE FROM artist
WHERE idArtist = ?
"""
delete_album = """ DELETE FROM album
WHERE idAlbum = ?
"""
delete_song = """ DELETE FROM song
WHERE idSong = ?
"""
get_version = """ SELECT idVersion
FROM version
"""
update_versiontag = """ INSERT OR REPLACE INTO versiontagscan(idVersion, iNeedsScan)
VALUES (?, 0)
create_artist = """ SELECT coalesce(max(idArtist), 1)
FROM artist
"""
create_album = """ SELECT coalesce(max(idAlbum), 0)
FROM album
"""
create_song = """ SELECT coalesce(max(idSong), 0)
FROM song
"""
create_genre = """ SELECT coalesce(max(idGenre), 0)
FROM genre
"""
get_artist = """ SELECT idArtist, strArtist
FROM artist
WHERE strMusicBrainzArtistID = ?
"""
get_artist_obj = ["{ArtistId}", "{Name}", "{UniqueId}"]
get_artist_by_name = """ SELECT idArtist
FROM artist
WHERE strArtist = ?
COLLATE NOCASE
"""
get_artist_by_id = """ SELECT *
FROM artist
WHERE idArtist = ?
"""
get_artist_by_id_obj = ["{ArtistId}"]
get_album_by_id = """ SELECT *
FROM album
WHERE idAlbum = ?
"""
get_album_by_id_obj = ["{AlbumId}"]
get_song_by_id = """ SELECT *
FROM song
WHERE idSong = ?
"""
get_song_by_id_obj = ["{SongId}"]
get_album = """ SELECT idAlbum
FROM album
WHERE strMusicBrainzAlbumID = ?
"""
get_album_obj = ["{AlbumId}", "{Title}", "{UniqueId}", "{Artists}", "album"]
get_album_by_name = """ SELECT idAlbum, strArtists
FROM album
WHERE strAlbum = ?
"""
get_album_by_name72 = """ SELECT idAlbum, strArtistDisp
FROM album
WHERE strAlbum = ?
"""
get_album_artist = """ SELECT strArtists
FROM album
WHERE idAlbum = ?
"""
get_album_artist72 = """ SELECT strArtistDisp
FROM album
WHERE idAlbum = ?
"""
get_album_artist_obj = ["{AlbumId}", "{strAlbumArtists}"]
get_genre = """ SELECT idGenre
FROM genre
WHERE strGenre = ?
COLLATE NOCASE
"""
get_total_episodes = """ SELECT totalCount
FROM tvshowcounts
WHERE idShow = ?
"""
add_artist = """ INSERT INTO artist(idArtist, strArtist, strMusicBrainzArtistID)
VALUES (?, ?, ?)
"""
add_album = """ INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType)
VALUES (?, ?, ?, ?)
"""
add_album72 = """ INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType, bScrapedMBID)
VALUES (?, ?, ?, ?, 1)
"""
add_single = """ INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType)
VALUES (?, ?, ?, ?)
"""
add_single_obj = ["{AlbumId}", "{Genre}", "{Year}", "single"]
add_song = """ INSERT INTO song(idSong, idAlbum, idPath, strArtists, strGenres, strTitle, iTrack,
iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed,
rating, comment, dateAdded)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
"""
add_song72 = """ INSERT INTO song(idSong, idAlbum, idPath, strArtistDisp, strGenres, strTitle, iTrack,
iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed,
rating, comment, dateAdded)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
"""
add_song_obj = ["{SongId}", "{AlbumId}", "{PathId}", "{Artists}", "{Genre}", "{Title}", "{Index}",
"{Runtime}", "{Year}", "{Filename}", "{UniqueId}", "{PlayCount}", "{DatePlayed}", "{Rating}",
"{Comment}", "{DateAdded}"]
add_genre = """ INSERT INTO genre(idGenre, strGenre)
VALUES (?, ?)
"""
add_genres_obj = ["{AlbumId}", "{Genres}", "album"]
update_path = """ UPDATE path
SET strPath = ?
WHERE idPath = ?
"""
update_path_obj = ["{Path}", "{PathId}"]
update_role = """ INSERT OR REPLACE INTO role(idRole, strRole)
VALUES (?, ?)
"""
update_role_obj = [1, "Composer"]
update_artist_name = """ UPDATE artist
SET strArtist = ?
WHERE idArtist = ?
"""
update_artist_name_obj = ["{Name}", "{ArtistId}"]
update_artist = """ UPDATE artist
SET strGenres = ?, strBiography = ?, strImage = ?, strFanart = ?, lastScraped = ?
WHERE idArtist = ?
"""
update_link = """ INSERT OR REPLACE INTO album_artist(idArtist, idAlbum, strArtist)
VALUES (?, ?, ?)
"""
update_link_obj = ["{ArtistId}", "{AlbumId}", "{Name}"]
update_discography = """ INSERT OR REPLACE INTO discography(idArtist, strAlbum, strYear)
VALUES (?, ?, ?)
"""
update_discography_obj = ["{ArtistId}", "{Title}", "{Year}"]
update_album = """ UPDATE album
SET strArtists = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?,
iUserrating = ?, lastScraped = ?, strReleaseType = ?
WHERE idAlbum = ?
"""
update_album72 = """ UPDATE album
SET strArtistDisp = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?,
iUserrating = ?, lastScraped = ?, bScrapedMBID = 1, strReleaseType = ?
WHERE idAlbum = ?
"""
update_album_obj = ["{Artists}", "{Year}", "{Genre}", "{Bio}", "{Thumb}", "{Rating}", "{LastScraped}", "album", "{AlbumId}"]
update_album_artist = """ UPDATE album
SET strArtists = ?
WHERE idAlbum = ?
"""
update_album_artist72 = """ UPDATE album
SET strArtistDisp = ?
WHERE idAlbum = ?
"""
update_song = """ UPDATE song
SET idAlbum = ?, strArtists = ?, strGenres = ?, strTitle = ?, iTrack = ?,
iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?,
rating = ?, comment = ?, dateAdded = ?
WHERE idSong = ?
"""
update_song72 = """ UPDATE song
SET idAlbum = ?, strArtistDisp = ?, strGenres = ?, strTitle = ?, iTrack = ?,
iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?,
rating = ?, comment = ?, dateAdded = ?
WHERE idSong = ?
"""
update_song_obj = ["{AlbumId}", "{Artists}", "{Genre}", "{Title}", "{Index}", "{Runtime}", "{Year}",
"{Filename}", "{PlayCount}", "{DatePlayed}", "{Rating}", "{Comment}",
"{DateAdded}", "{SongId}"]
update_song_artist = """ INSERT OR REPLACE INTO song_artist(idArtist, idSong, idRole, iOrder, strArtist)
VALUES (?, ?, ?, ?, ?)
"""
update_song_artist_obj = ["{ArtistId}", "{SongId}", 1, "{Index}", "{Name}"]
update_song_album = """ INSERT OR REPLACE INTO albuminfosong(idAlbumInfoSong, idAlbumInfo, iTrack,
strTitle, iDuration)
VALUES (?, ?, ?, ?, ?)
"""
update_song_album_obj = ["{SongId}", "{AlbumId}", "{Index}", "{Title}", "{Runtime}"]
update_song_rating = """ UPDATE song
SET iTimesPlayed = ?, lastplayed = ?, rating = ?
WHERE idSong = ?
"""
update_song_rating_obj = ["{PlayCount}", "{DatePlayed}", "{Rating}", "{KodiId}"]
update_genre_album = """ INSERT OR REPLACE INTO album_genre(idGenre, idAlbum)
VALUES (?, ?)
"""
update_genre_song = """ INSERT OR REPLACE INTO song_genre(idGenre, idSong)
VALUES (?, ?)
"""
update_genre_song_obj = ["{SongId}", "{Genres}", "song"]
delete_genres_album = """ DELETE FROM album_genre
WHERE idAlbum = ?
"""
delete_genres_song = """ DELETE FROM song_genre
WHERE idSong = ?
"""
delete_artist = """ DELETE FROM artist
WHERE idArtist = ?
"""
delete_album = """ DELETE FROM album
WHERE idAlbum = ?
"""
delete_song = """ DELETE FROM song
WHERE idSong = ?
"""
get_version = """ SELECT idVersion
FROM version
"""
update_versiontag = """ INSERT OR REPLACE INTO versiontagscan(idVersion, iNeedsScan)
VALUES (?, 0)
"""
get_versiontagcount = """ SELECT COUNT(*)
FROM versiontagscan
"""
get_versiontagcount = """ SELECT COUNT(*)
FROM versiontagscan
"""

View file

@ -1,11 +1,10 @@
get_cache = """ SELECT cachedurl
FROM texture
WHERE url = ?
"""
get_cache = """ SELECT cachedurl
FROM texture
WHERE url = ?
"""
delete_cache = """ DELETE FROM texture
WHERE url = ?
"""
delete_cache = """ DELETE FROM texture
WHERE url = ?
"""

View file

@ -9,14 +9,13 @@ from kodi import Kodi
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
class TVShows(Kodi):
def __init__(self, cursor):
self.cursor = cursor
@ -24,7 +23,7 @@ class TVShows(Kodi):
def create_entry_unique_id(self):
self.cursor.execute(QU.create_unique_id)
return self.cursor.fetchone()[0] + 1
def create_entry_rating(self):
@ -39,12 +38,12 @@ class TVShows(Kodi):
def create_entry_season(self):
self.cursor.execute(QU.create_season)
return self.cursor.fetchone()[0] + 1
def create_entry_episode(self):
self.cursor.execute(QU.create_episode)
return self.cursor.fetchone()[0] + 1
def get(self, *args):
@ -69,7 +68,7 @@ class TVShows(Kodi):
try:
self.cursor.execute(QU.get_rating, args)
return self.cursor.fetchone()[0]
except TypeError:
return
@ -93,7 +92,7 @@ class TVShows(Kodi):
try:
self.cursor.execute(QU.get_unique_id, args)
return self.cursor.fetchone()[0]
except TypeError:
return