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

@ -22,7 +22,7 @@ from utils import get_play_action
#################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
#################################################################################################
@ -58,7 +58,7 @@ class Actions(object):
play.set_external_subs(source, listitem)
self.set_playlist(item, listitem, db_id, transcode)
index = max(kodi_playlist.getposition(), 0) + 1 # Can return -1
index = max(kodi_playlist.getposition(), 0) + 1 # Can return -1
force_play = False
self.stack[0][1].setPath(self.stack[0][0])
@ -79,7 +79,8 @@ class Actions(object):
index += 1
if force_play:
if len(sys.argv) > 1: xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, self.stack[0][1])
if len(sys.argv) > 1:
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, self.stack[0][1])
xbmc.Player().play(kodi_playlist, windowed=False)
def set_playlist(self, item, listitem, db_id=None, transcode=False):
@ -177,7 +178,7 @@ class Actions(object):
playlist = self.get_playlist(item)
player = xbmc.Player()
#xbmc.executebuiltin("Playlist.Clear") # Clear playlist to remove the previous item from playlist position no.2
# xbmc.executebuiltin("Playlist.Clear") # Clear playlist to remove the previous item from playlist position no.2
if clear:
if player.isPlaying():
@ -186,7 +187,7 @@ class Actions(object):
xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
index = 0
else:
index = max(playlist.getposition(), 0) + 1 # Can return -1
index = max(playlist.getposition(), 0) + 1 # Can return -1
listitem = xbmcgui.ListItem()
LOG.info("[ playlist/%s ] %s", item['Id'], item['Name'])
@ -282,7 +283,7 @@ class Actions(object):
''' Set listitem for video content. That also include streams.
'''
API = api.API(item, self.server)
is_video = obj['MediaType'] in ('Video', 'Audio') # audiobook
is_video = obj['MediaType'] in ('Video', 'Audio') # audiobook
obj['Genres'] = " / ".join(obj['Genres'] or [])
obj['Studios'] = [API.validate_studio(studio) for studio in (obj['Studios'] or [])]
@ -312,21 +313,21 @@ class Actions(object):
if not intro and not obj['Type'] == 'Trailer':
obj['Artwork']['Primary'] = obj['Artwork']['Primary'] \
or "special://home/addons/plugin.video.jellyfin/resources/icon.png"
or "special://home/addons/plugin.video.jellyfin/resources/icon.png"
else:
obj['Artwork']['Primary'] = obj['Artwork']['Primary'] \
or obj['Artwork']['Thumb'] \
or (obj['Artwork']['Backdrop'][0] \
if len(obj['Artwork']['Backdrop']) \
or obj['Artwork']['Thumb'] \
or (obj['Artwork']['Backdrop'][0]
if len(obj['Artwork']['Backdrop'])
else "special://home/addons/plugin.video.jellyfin/resources/fanart.png")
obj['Artwork']['Primary'] += "&KodiTrailer=true" \
if obj['Type'] == 'Trailer' else "&KodiCinemaMode=true"
if obj['Type'] == 'Trailer' else "&KodiCinemaMode=true"
obj['Artwork']['Backdrop'] = [obj['Artwork']['Primary']]
self.set_artwork(obj['Artwork'], listitem, obj['Type'])
if intro or obj['Type'] == 'Trailer':
listitem.setArt({'poster': ""}) # Clear the poster value for intros / trailers to prevent issues in skins
listitem.setArt({'poster': ""}) # Clear the poster value for intros / trailers to prevent issues in skins
listitem.setIconImage('DefaultVideo.png')
listitem.setThumbnailImage(obj['Artwork']['Primary'])
@ -442,9 +443,9 @@ class Actions(object):
listitem.setProperty('IsPlayable', 'true')
listitem.setProperty('IsFolder', 'false')
if obj['Resume'] and seektime != False:
if obj['Resume'] and seektime:
listitem.setProperty('resumetime', str(obj['Resume']))
listitem.setProperty('StartPercent', str(((obj['Resume']/obj['Runtime']) * 100) - 0.40))
listitem.setProperty('StartPercent', str(((obj['Resume'] / obj['Runtime']) * 100) - 0.40))
else:
listitem.setProperty('resumetime', '0')
@ -478,11 +479,11 @@ class Actions(object):
obj['PlayCount'] = API.get_playcount(obj['Played'], obj['PlayCount']) or 0
obj['Overlay'] = 7 if obj['Played'] else 6
obj['Artwork']['Primary'] = obj['Artwork']['Primary'] \
or "special://home/addons/plugin.video.jellyfin/resources/icon.png"
or "special://home/addons/plugin.video.jellyfin/resources/icon.png"
obj['Artwork']['Thumb'] = obj['Artwork']['Thumb'] \
or "special://home/addons/plugin.video.jellyfin/resources/fanart.png"
or "special://home/addons/plugin.video.jellyfin/resources/fanart.png"
obj['Artwork']['Backdrop'] = obj['Artwork']['Backdrop'] \
or ["special://home/addons/plugin.video.jellyfin/resources/fanart.png"]
or ["special://home/addons/plugin.video.jellyfin/resources/fanart.png"]
metadata = {
'title': obj['Title'],
@ -625,7 +626,7 @@ class Actions(object):
'clearlogo': "Logo",
'discart': "Disc",
'fanart': "Backdrop",
'fanart_image': "Backdrop", # in case
'fanart_image': "Backdrop", # in case
'thumb': "Primary"
}
else:
@ -671,9 +672,9 @@ class Actions(object):
dialog.doModal()
if dialog.is_selected():
if not dialog.get_selected(): # Start from beginning selected.
if not dialog.get_selected(): # Start from beginning selected.
return False
else: # User backed out
else: # User backed out
LOG.info("User exited without a selection.")
return
@ -688,9 +689,7 @@ class Actions(object):
return False
if (not xbmc.getCondVisibility('Window.IsMedia') and
((item['Type'] == 'Audio' and not xbmc.getCondVisibility('Integer.IsGreater(Playlist.Length(music),1)')) or
not xbmc.getCondVisibility('Integer.IsGreater(Playlist.Length(video),1)'))):
if (not xbmc.getCondVisibility('Window.IsMedia') and ((item['Type'] == 'Audio' and not xbmc.getCondVisibility('Integer.IsGreater(Playlist.Length(music),1)')) or not xbmc.getCondVisibility('Integer.IsGreater(Playlist.Length(video),1)'))):
return True
@ -733,6 +732,7 @@ def on_update(data, server):
window('jellyfin.skip.%s' % item[0], clear=True)
def on_play(data, server):
''' Setup progress for jellyfin playback.
@ -781,6 +781,7 @@ def on_play(data, server):
item['PlaybackInfo'] = {'Path': file}
playutils.set_properties(item, 'DirectStream' if settings('useDirectPaths') == '0' else 'DirectPlay')
def special_listener():
''' Corner cases that needs to be listened to.
@ -790,12 +791,11 @@ def special_listener():
isPlaying = player.isPlaying()
count = int(window('jellyfin.external_count') or 0)
if (not isPlaying and xbmc.getCondVisibility('Window.IsVisible(DialogContextMenu.xml)') and
xbmc.getInfoLabel('Control.GetLabel(1002)') == xbmc.getLocalizedString(12021)):
if (not isPlaying and xbmc.getCondVisibility('Window.IsVisible(DialogContextMenu.xml)') and xbmc.getInfoLabel('Control.GetLabel(1002)') == xbmc.getLocalizedString(12021)):
control = int(xbmcgui.Window(10106).getFocusId())
if control == 1002: # Start from beginning
if control == 1002: # Start from beginning
LOG.info("Resume dialog: Start from beginning selected.")
window('jellyfin.resume.bool', False)
@ -806,7 +806,7 @@ def special_listener():
elif isPlaying and not window('jellyfin.external_check'):
time = player.getTime()
if time > 1: # Not external player.
if time > 1: # Not external player.
window('jellyfin.external_check', value="true")
window('jellyfin.external_count', value="0")

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

View file

@ -14,7 +14,7 @@ from helper import api, catch, stop, validate, jellyfin_item, library_check, val
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
@ -103,13 +103,11 @@ class Movies(KodiDb):
obj['Tags'] = tags
if update:
self.movie_update(obj)
else:
self.movie_add(obj)
self.update_path(*values(obj, QU.update_path_movie_obj))
self.update_file(*values(obj, QU.update_file_obj))
self.add_tags(*values(obj, QU.add_tags_movie_obj))
@ -192,7 +190,6 @@ class Movies(KodiDb):
}
obj['Filename'] = "%s?%s" % (obj['Path'], urllib.urlencode(params))
@stop()
@jellyfin_item()
def boxset(self, item, e_item):

View file

@ -14,7 +14,7 @@ from helper import api, catch, stop, validate, jellyfin_item, values, library_ch
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
@ -77,13 +77,11 @@ class Music(KodiDb):
if obj['Backdrops']:
obj['Backdrops'] = "<fanart>%s</fanart>" % obj['Backdrops'][0]
if update:
self.artist_update(obj)
else:
self.artist_add(obj)
self.update(obj['Genre'], obj['Bio'], obj['Thumb'], obj['Backdrops'], obj['LastScraped'], obj['ArtistId'])
self.artwork.add(obj['Artwork'], obj['ArtistId'], "artist")
self.item_ids.append(obj['Id'])
@ -106,7 +104,6 @@ class Music(KodiDb):
self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj))
LOG.info("UPDATE artist [%s] %s: %s", obj['ArtistId'], obj['Name'], obj['Id'])
@stop()
@jellyfin_item()
def album(self, item, e_item):
@ -144,13 +141,11 @@ class Music(KodiDb):
if obj['Thumb']:
obj['Thumb'] = "<thumb>%s</thumb>" % obj['Thumb']
if update:
self.album_update(obj)
else:
self.album_add(obj)
self.artist_link(obj)
self.artist_discography(obj)
self.update_album(*values(obj, QU.update_album_obj))
@ -217,7 +212,6 @@ class Music(KodiDb):
self.link(*values(temp_obj, QU.update_link_obj))
self.item_ids.append(temp_obj['Id'])
@stop()
@jellyfin_item()
def song(self, item, e_item):
@ -269,15 +263,13 @@ class Music(KodiDb):
if obj['Disc'] != 1:
obj['Index'] = obj['Disc'] * 2 ** 16 + obj['Index']
if update:
self.song_update(obj)
else:
self.song_add(obj)
self.link_song_album(*values(obj, QU.update_song_album_obj))
self.add_role(*values(obj, QU.update_role_obj)) # defaultt role
self.add_role(*values(obj, QU.update_role_obj)) # defaultt role
self.song_artist_link(obj)
self.song_artist_discography(obj)
@ -415,7 +407,6 @@ class Music(KodiDb):
obj['AlbumId'] = self.create_entry_album()
self.add_single(*values(obj, QU.add_single_obj))
@stop()
@jellyfin_item()
def userdata(self, item, e_item):

View file

@ -14,7 +14,7 @@ from helper import api, catch, stop, validate, library_check, jellyfin_item, val
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
@ -114,13 +114,11 @@ class MusicVideos(KodiDb):
obj['Tags'] = tags
if update:
self.musicvideo_update(obj)
else:
self.musicvideo_add(obj)
self.update_path(*values(obj, QU.update_path_mvideo_obj))
self.update_file(*values(obj, QU.update_file_obj))
self.add_tags(*values(obj, QU.add_tags_mvideo_obj))
@ -176,7 +174,6 @@ class MusicVideos(KodiDb):
}
obj['Filename'] = "%s?%s" % (obj['Path'], urllib.urlencode(params))
@stop()
@jellyfin_item()
def userdata(self, item, e_item):
@ -185,7 +182,7 @@ class MusicVideos(KodiDb):
Poster with progress bar
'''
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
API = api.API(item, server_address)
obj = self.objects.map(item, 'MusicVideoUserData')

View file

@ -8,7 +8,7 @@ import os
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
@ -44,7 +44,7 @@ class Objects(object):
"$": lead the key name with $. Only one key value can be requested per element.
":": indicates it's a list of elements [], i.e. MediaSources/0/MediaStreams:?$Name
MediaStreams is a list.
"/": indicates where to go directly
"/": indicates where to go directly
'''
self.mapped_item = {}
@ -145,7 +145,7 @@ class Objects(object):
result = False
for key, value in filters.iteritems():
inverse = False
if value.startswith('!'):

View file

@ -16,7 +16,7 @@ from helper import api, catch, stop, validate, jellyfin_item, library_check, set
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
@ -76,7 +76,6 @@ class TVShows(KodiDb):
update = False
LOG.info("ShowId %s missing from kodi. repairing the entry.", obj['ShowId'])
obj['Path'] = API.get_file_path(obj['Path'])
obj['LibraryId'] = library['Id']
obj['LibraryName'] = library['Name']
@ -107,13 +106,11 @@ class TVShows(KodiDb):
obj['Tags'] = tags
if update:
self.tvshow_update(obj)
else:
self.tvshow_add(obj)
self.link(*values(obj, QU.update_tvshow_link_obj))
self.update_path(*values(obj, QU.update_path_tvshow_obj))
self.add_tags(*values(obj, QU.add_tags_tvshow_obj))
@ -161,10 +158,10 @@ class TVShows(KodiDb):
''' Add object to kodi.
'''
obj['RatingId'] = self.create_entry_rating()
obj['RatingId'] = self.create_entry_rating()
self.add_ratings(*values(obj, QU.add_rating_tvshow_obj))
obj['Unique'] = self.create_entry_unique_id()
obj['Unique'] = self.create_entry_unique_id()
self.add_unique_id(*values(obj, QU.add_unique_id_tvshow_obj))
obj['TopPathId'] = self.add_path(obj['TopLevel'])
@ -180,10 +177,10 @@ class TVShows(KodiDb):
''' Update object to kodi.
'''
obj['RatingId'] = self.get_rating_id(*values(obj, QU.get_unique_id_tvshow_obj))
obj['RatingId'] = self.get_rating_id(*values(obj, QU.get_unique_id_tvshow_obj))
self.update_ratings(*values(obj, QU.update_rating_tvshow_obj))
obj['Unique'] = self.get_unique_id(*values(obj, QU.get_unique_id_tvshow_obj))
obj['Unique'] = self.get_unique_id(*values(obj, QU.get_unique_id_tvshow_obj))
self.update_unique_id(*values(obj, QU.update_unique_id_tvshow_obj))
self.update(*values(obj, QU.update_tvshow_obj))
@ -209,7 +206,6 @@ class TVShows(KodiDb):
obj['TopLevel'] = "plugin://plugin.video.jellyfin/"
obj['Path'] = "%s%s/" % (obj['TopLevel'], obj['Id'])
@stop()
def season(self, item, show_id=None):
@ -244,7 +240,6 @@ class TVShows(KodiDb):
self.artwork.add(obj['Artwork'], obj['SeasonId'], "season")
LOG.info("UPDATE season [%s/%s] %s: %s", obj['ShowId'], obj['SeasonId'], obj['Title'] or obj['Index'], obj['Id'])
@stop()
@jellyfin_item()
def episode(self, item, e_item):
@ -286,7 +281,6 @@ class TVShows(KodiDb):
update = False
LOG.info("EpisodeId %s missing from kodi. repairing the entry.", obj['EpisodeId'])
obj['Path'] = API.get_file_path(obj['Path'])
obj['Index'] = obj['Index'] or -1
obj['Writers'] = " / ".join(obj['Writers'] or [])
@ -319,7 +313,7 @@ class TVShows(KodiDb):
if obj['AirsAfterSeason']:
obj['AirsBeforeSeason'] = obj['AirsAfterSeason']
obj['AirsBeforeEpisode'] = 4096 # Kodi default number for afterseason ordering
obj['AirsBeforeEpisode'] = 4096 # Kodi default number for afterseason ordering
if obj['MultiEpisode']:
obj['Title'] = "| %02d | %s" % (obj['MultiEpisode'], obj['Title'])
@ -329,13 +323,11 @@ class TVShows(KodiDb):
obj['SeasonId'] = self.get_season(*values(obj, QU.get_season_episode_obj))
if update:
self.episode_update(obj)
else:
self.episode_add(obj)
self.update_path(*values(obj, QU.update_path_episode_obj))
self.update_file(*values(obj, QU.update_file_obj))
self.add_people(*values(obj, QU.add_people_episode_obj))
@ -359,10 +351,10 @@ class TVShows(KodiDb):
''' Add object to kodi.
'''
obj['RatingId'] = self.create_entry_rating()
obj['RatingId'] = self.create_entry_rating()
self.add_ratings(*values(obj, QU.add_rating_episode_obj))
obj['Unique'] = self.create_entry_unique_id()
obj['Unique'] = self.create_entry_unique_id()
self.add_unique_id(*values(obj, QU.add_unique_id_episode_obj))
obj['PathId'] = self.add_path(*values(obj, QU.add_path_obj))
@ -387,7 +379,7 @@ class TVShows(KodiDb):
obj['RatingId'] = self.get_rating_id(*values(obj, QU.get_rating_episode_obj))
self.update_ratings(*values(obj, QU.update_rating_episode_obj))
obj['Unique'] = self.get_unique_id(*values(obj, QU.get_unique_id_episode_obj))
obj['Unique'] = self.get_unique_id(*values(obj, QU.get_unique_id_episode_obj))
self.update_unique_id(*values(obj, QU.update_unique_id_episode_obj))
self.update_episode(*values(obj, QU.update_episode_obj))
@ -440,7 +432,6 @@ class TVShows(KodiDb):
return True
@stop()
@jellyfin_item()
def userdata(self, item, e_item):

View file

@ -8,7 +8,7 @@ from helper import JSONRPC
#################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
#################################################################################################