mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
Pylint (#67)
This commit is contained in:
parent
6eb8cdfa30
commit
2b0c9d1bbc
11 changed files with 268 additions and 327 deletions
|
@ -110,7 +110,7 @@ class DownloadUtils(object):
|
|||
}
|
||||
|
||||
self.downloadUrl(url, postBody=data, action_type="POST")
|
||||
log.debug("Posted capabilities to %s" % self.session['Server'])
|
||||
log.debug("Posted capabilities to %s", self.session['Server'])
|
||||
|
||||
# Attempt at getting sessionId
|
||||
url = "{server}/emby/Sessions?DeviceId=%s&format=json" % device_id
|
||||
|
@ -301,7 +301,7 @@ class DownloadUtils(object):
|
|||
raise Warning('restricted')
|
||||
|
||||
elif (response.headers['X-Application-Error-Code'] ==
|
||||
"UnauthorizedAccessException"):
|
||||
"UnauthorizedAccessException"):
|
||||
# User tried to do something his emby account doesn't allow
|
||||
pass
|
||||
|
||||
|
|
|
@ -3,23 +3,10 @@
|
|||
##################################################################################################
|
||||
|
||||
import logging
|
||||
import urllib
|
||||
from ntpath import dirname
|
||||
from datetime import datetime
|
||||
|
||||
import xbmc
|
||||
import xbmcgui
|
||||
import xbmcvfs
|
||||
|
||||
import api
|
||||
import artwork
|
||||
import downloadutils
|
||||
import embydb_functions as embydb
|
||||
import kodidb_functions as kodidb
|
||||
import read_embyserver as embyserver
|
||||
import musicutils
|
||||
from objects import Movies, MusicVideos, TVShows, Music
|
||||
from utils import window, settings, language as lang, kodiSQL
|
||||
from utils import settings, kodiSQL
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
@ -36,27 +23,14 @@ class Items(object):
|
|||
self.embycursor = embycursor
|
||||
self.kodicursor = kodicursor
|
||||
|
||||
self.doUtils = downloadutils.DownloadUtils()
|
||||
|
||||
self.kodiversion = int(xbmc.getInfoLabel('System.BuildVersion')[:2])
|
||||
self.directpath = settings('useDirectPaths') == "1"
|
||||
self.music_enabled = settings('enableMusic') == "true"
|
||||
self.contentmsg = settings('newContent') == "true"
|
||||
self.newvideo_time = int(settings('newvideotime'))*1000
|
||||
self.newmusic_time = int(settings('newmusictime'))*1000
|
||||
|
||||
self.artwork = artwork.Artwork()
|
||||
self.emby = embyserver.Read_EmbyServer()
|
||||
self.emby_db = embydb.Embydb_Functions(embycursor)
|
||||
self.kodi_db = kodidb.Kodidb_Functions(kodicursor)
|
||||
self.music_enabled = settings('enableMusic') == "true"
|
||||
|
||||
|
||||
def itemsbyId(self, items, process, pdialog=None):
|
||||
# Process items by itemid. Process can be added, update, userdata, remove
|
||||
emby = self.emby
|
||||
embycursor = self.embycursor
|
||||
kodicursor = self.kodicursor
|
||||
music_enabled = self.music_enabled
|
||||
|
||||
itemtypes = {
|
||||
|
||||
|
@ -80,11 +54,10 @@ class Items(object):
|
|||
if total == 0:
|
||||
return False
|
||||
|
||||
log.info("Processing %s: %s" % (process, items))
|
||||
log.info("Processing %s: %s", process, items)
|
||||
if pdialog:
|
||||
pdialog.update(heading="Processing %s: %s items" % (process, total))
|
||||
|
||||
count = 0
|
||||
for itemtype in items:
|
||||
|
||||
# Safety check
|
||||
|
@ -100,7 +73,7 @@ class Items(object):
|
|||
musicconn = None
|
||||
|
||||
if itemtype in ('MusicAlbum', 'MusicArtist', 'AlbumArtist', 'Audio'):
|
||||
if music_enabled:
|
||||
if self.music_enabled:
|
||||
musicconn = kodiSQL('music')
|
||||
musiccursor = musicconn.cursor()
|
||||
items_process = itemtypes[itemtype](embycursor, musiccursor, pdialog)
|
||||
|
@ -113,18 +86,17 @@ class Items(object):
|
|||
|
||||
|
||||
if process == "added":
|
||||
processItems = itemlist
|
||||
items_process.add_all(itemtype, itemlist)
|
||||
elif process == "remove":
|
||||
items_process.remove_all(itemtype, itemlist)
|
||||
else:
|
||||
processItems = emby.getFullItems(itemlist)
|
||||
items_process.process_all(itemtype, process, processItems, total)
|
||||
process_items = self.emby.getFullItems(itemlist)
|
||||
items_process.process_all(itemtype, process, process_items, total)
|
||||
|
||||
|
||||
if musicconn is not None:
|
||||
# close connection for special types
|
||||
log.info("Updating music database.")
|
||||
log.info("updating music database")
|
||||
musicconn.commit()
|
||||
musiccursor.close()
|
||||
|
||||
|
|
|
@ -999,14 +999,11 @@ class ManualSync(LibrarySync):
|
|||
|
||||
|
||||
def __init__(self):
|
||||
|
||||
LibrarySync.__init__(self)
|
||||
|
||||
def sync(self):
|
||||
|
||||
return self.fullSync(manualrun=True)
|
||||
|
||||
|
||||
def movies(self, embycursor, kodicursor, pdialog):
|
||||
return Movies(embycursor, kodicursor, pdialog).compare_all()
|
||||
|
||||
|
|
|
@ -78,11 +78,11 @@ class Items(object):
|
|||
if self.pdialog and view:
|
||||
self.pdialog.update(heading="Processing %s / %s items" % (view['name'], total))
|
||||
|
||||
action = self._get_func(item_type, "added")
|
||||
process = self._get_func(item_type, "added")
|
||||
if view:
|
||||
action(items, total, view)
|
||||
process(items, total, view)
|
||||
else:
|
||||
action(items, total)
|
||||
process(items, total)
|
||||
|
||||
def process_all(self, item_type, action, items, total=None, view=None):
|
||||
|
||||
|
|
|
@ -4,12 +4,9 @@
|
|||
|
||||
import logging
|
||||
import urllib
|
||||
from ntpath import dirname
|
||||
from datetime import datetime
|
||||
|
||||
import api
|
||||
import common
|
||||
import downloadutils
|
||||
import embydb_functions as embydb
|
||||
import kodidb_functions as kodidb
|
||||
from utils import window, settings, language as lang, catch_except
|
||||
|
@ -62,7 +59,7 @@ class Movies(common.Items):
|
|||
pdialog = self.pdialog
|
||||
views = self.emby_db.getView_byType('movies')
|
||||
views += self.emby_db.getView_byType('mixed')
|
||||
log.info("Media folders: %s" % views)
|
||||
log.info("Media folders: %s", views)
|
||||
|
||||
try:
|
||||
all_kodisets = dict(self.emby_db.get_checksum('BoxSet'))
|
||||
|
@ -107,7 +104,7 @@ class Movies(common.Items):
|
|||
# Only update if movie is not in Kodi or checksum is different
|
||||
updatelist.append(itemid)
|
||||
|
||||
log.info("Movies to update for %s: %s" % (viewName, updatelist))
|
||||
log.info("Movies to update for %s: %s", viewName, updatelist)
|
||||
embymovies = self.emby.getFullItems(updatelist)
|
||||
total = len(updatelist)
|
||||
del updatelist[:]
|
||||
|
@ -137,7 +134,7 @@ class Movies(common.Items):
|
|||
updatelist.append(itemid)
|
||||
embyboxsets.append(boxset)
|
||||
|
||||
log.info("Boxsets to update: %s" % updatelist)
|
||||
log.info("Boxsets to update: %s", updatelist)
|
||||
self.total = len(updatelist)
|
||||
|
||||
if pdialog:
|
||||
|
@ -158,14 +155,14 @@ class Movies(common.Items):
|
|||
for kodimovie in all_kodimovies:
|
||||
if kodimovie not in all_embymoviesIds:
|
||||
self.remove(kodimovie)
|
||||
else:
|
||||
log.info("Movies compare finished.")
|
||||
|
||||
log.info("Movies compare finished.")
|
||||
|
||||
for boxset in all_kodisets:
|
||||
if boxset not in all_embyboxsetsIds:
|
||||
self.remove(boxset)
|
||||
else:
|
||||
log.info("Boxsets compare finished.")
|
||||
|
||||
log.info("Boxsets compare finished.")
|
||||
|
||||
return True
|
||||
|
||||
|
@ -193,11 +190,11 @@ class Movies(common.Items):
|
|||
movieid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
pathid = emby_dbitem[2]
|
||||
log.info("movieid: %s fileid: %s pathid: %s" % (movieid, fileid, pathid))
|
||||
log.info("movieid: %s fileid: %s pathid: %s", movieid, fileid, pathid)
|
||||
|
||||
except TypeError:
|
||||
update_item = False
|
||||
log.debug("movieid: %s not found." % itemid)
|
||||
log.debug("movieid: %s not found", itemid)
|
||||
# movieid
|
||||
kodicursor.execute("select coalesce(max(idMovie),0) from movie")
|
||||
movieid = kodicursor.fetchone()[0] + 1
|
||||
|
@ -211,12 +208,12 @@ class Movies(common.Items):
|
|||
except TypeError:
|
||||
# item is not found, let's recreate it.
|
||||
update_item = False
|
||||
log.info("movieid: %s missing from Kodi, repairing the entry." % movieid)
|
||||
log.info("movieid: %s missing from Kodi, repairing the entry", movieid)
|
||||
|
||||
if not view:
|
||||
# Get view tag from emby
|
||||
viewtag, viewid, mediatype = self.emby.getView_embyId(itemid)
|
||||
log.debug("View tag found: %s" % viewtag)
|
||||
log.debug("View tag found: %s", viewtag)
|
||||
else:
|
||||
viewtag = view['name']
|
||||
viewid = view['id']
|
||||
|
@ -272,12 +269,12 @@ class Movies(common.Items):
|
|||
trailer = None
|
||||
else:
|
||||
try:
|
||||
trailerId = trailer.rsplit('=', 1)[1]
|
||||
trailer_id = trailer.rsplit('=', 1)[1]
|
||||
except IndexError:
|
||||
log.info("Failed to process trailer: %s" % trailer)
|
||||
log.info("Failed to process trailer: %s", trailer)
|
||||
trailer = None
|
||||
else:
|
||||
trailer = "plugin://plugin.video.youtube/play/?video_id=%s" % trailerId
|
||||
trailer = "plugin://plugin.video.youtube/play/?video_id=%s" % trailer_id
|
||||
|
||||
|
||||
##### GET THE FILE AND PATH #####
|
||||
|
@ -311,7 +308,7 @@ class Movies(common.Items):
|
|||
|
||||
##### UPDATE THE MOVIE #####
|
||||
if update_item:
|
||||
log.info("UPDATE movie itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("UPDATE movie itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Update the movie entry
|
||||
if self.kodi_version > 16:
|
||||
|
@ -324,8 +321,9 @@ class Movies(common.Items):
|
|||
"WHERE idMovie = ?"
|
||||
))
|
||||
kodicursor.execute(query, (title, plot, shortplot, tagline, votecount, rating,
|
||||
writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio,
|
||||
trailer, country, year, movieid))
|
||||
writer, year, imdb, sorttitle, runtime, mpaa, genre,
|
||||
director, title, studio, trailer, country, year,
|
||||
movieid))
|
||||
else:
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -336,15 +334,14 @@ class Movies(common.Items):
|
|||
"WHERE idMovie = ?"
|
||||
))
|
||||
kodicursor.execute(query, (title, plot, shortplot, tagline, votecount, rating,
|
||||
writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio,
|
||||
trailer, country, movieid))
|
||||
|
||||
writer, year, imdb, sorttitle, runtime, mpaa, genre,
|
||||
director, title, studio, trailer, country, movieid))
|
||||
# Update the checksum in emby table
|
||||
emby_db.updateReference(itemid, checksum)
|
||||
|
||||
##### OR ADD THE MOVIE #####
|
||||
else:
|
||||
log.info("ADD movie itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("ADD movie itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Add path
|
||||
pathid = self.kodi_db.addPath(path)
|
||||
|
@ -363,8 +360,9 @@ class Movies(common.Items):
|
|||
'''
|
||||
)
|
||||
kodicursor.execute(query, (movieid, fileid, title, plot, shortplot, tagline,
|
||||
votecount, rating, writer, year, imdb, sorttitle, runtime, mpaa, genre,
|
||||
director, title, studio, trailer, country, year))
|
||||
votecount, rating, writer, year, imdb, sorttitle,
|
||||
runtime, mpaa, genre, director, title, studio, trailer,
|
||||
country, year))
|
||||
else:
|
||||
query = (
|
||||
'''
|
||||
|
@ -376,11 +374,12 @@ class Movies(common.Items):
|
|||
'''
|
||||
)
|
||||
kodicursor.execute(query, (movieid, fileid, title, plot, shortplot, tagline,
|
||||
votecount, rating, writer, year, imdb, sorttitle, runtime, mpaa, genre,
|
||||
director, title, studio, trailer, country))
|
||||
|
||||
votecount, rating, writer, year, imdb, sorttitle,
|
||||
runtime, mpaa, genre, director, title, studio, trailer,
|
||||
country))
|
||||
# Create the reference in emby table
|
||||
emby_db.addReference(itemid, movieid, "Movie", "movie", fileid, pathid, None, checksum, viewid)
|
||||
emby_db.addReference(itemid, movieid, "Movie", "movie", fileid, pathid, None,
|
||||
checksum, viewid)
|
||||
|
||||
# Update the path
|
||||
query = ' '.join((
|
||||
|
@ -472,10 +471,10 @@ class Movies(common.Items):
|
|||
try:
|
||||
movieid = emby_dbitem[0]
|
||||
except TypeError:
|
||||
log.info("Failed to add: %s to boxset." % movie['Name'])
|
||||
log.info("Failed to add: %s to boxset", movie['Name'])
|
||||
continue
|
||||
|
||||
log.info("New addition to boxset %s: %s" % (title, movie['Name']))
|
||||
log.info("New addition to boxset %s: %s", title, movie['Name'])
|
||||
self.kodi_db.assignBoxset(setid, movieid)
|
||||
# Update emby reference
|
||||
emby_db.updateParentId(itemid, setid)
|
||||
|
@ -486,7 +485,7 @@ class Movies(common.Items):
|
|||
# Process removals from boxset
|
||||
for movie in process:
|
||||
movieid = current[movie]
|
||||
log.info("Remove from boxset %s: %s" % (title, movieid))
|
||||
log.info("Remove from boxset %s: %s", title, movieid)
|
||||
self.kodi_db.removefromBoxset(movieid)
|
||||
# Update emby reference
|
||||
emby_db.updateParentId(movie, None)
|
||||
|
@ -511,7 +510,7 @@ class Movies(common.Items):
|
|||
try:
|
||||
movieid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
log.info("Update playstate for movie: %s fileid: %s" % (item['Name'], fileid))
|
||||
log.info("Update playstate for movie: %s fileid: %s", item['Name'], fileid)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
@ -527,7 +526,7 @@ class Movies(common.Items):
|
|||
resume = API.adjust_resume(userdata['Resume'])
|
||||
total = round(float(runtime), 6)
|
||||
|
||||
log.debug("%s New resume point: %s" % (itemid, resume))
|
||||
log.debug("%s New resume point: %s", itemid, resume)
|
||||
|
||||
self.kodi_db.addPlaystate(fileid, resume, total, playcount, dateplayed)
|
||||
emby_db.updateReference(itemid, checksum)
|
||||
|
@ -543,7 +542,7 @@ class Movies(common.Items):
|
|||
kodiid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
mediatype = emby_dbitem[4]
|
||||
log.info("Removing %sid: %s fileid: %s" % (mediatype, kodiid, fileid))
|
||||
log.info("Removing %sid: %s fileid: %s", mediatype, kodiid, fileid)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
@ -569,4 +568,4 @@ class Movies(common.Items):
|
|||
|
||||
kodicursor.execute("DELETE FROM sets WHERE idSet = ?", (kodiid,))
|
||||
|
||||
log.info("Deleted %s %s from kodi database" % (mediatype, itemid))
|
||||
log.info("Deleted %s %s from kodi database", mediatype, itemid)
|
||||
|
|
|
@ -3,13 +3,10 @@
|
|||
##################################################################################################
|
||||
|
||||
import logging
|
||||
import urllib
|
||||
from ntpath import dirname
|
||||
from datetime import datetime
|
||||
|
||||
import api
|
||||
import common
|
||||
import downloadutils
|
||||
import embydb_functions as embydb
|
||||
import kodidb_functions as kodidb
|
||||
import musicutils
|
||||
|
@ -133,7 +130,7 @@ class Music(common.Items):
|
|||
if all_kodisongs.get(itemid) != API.get_checksum():
|
||||
# Only update if songs is not in Kodi or checksum is different
|
||||
updatelist.append(itemid)
|
||||
log.info("%s to update: %s" % (data_type, updatelist))
|
||||
log.info("%s to update: %s", data_type, updatelist)
|
||||
embyitems = self.emby.getFullItems(updatelist)
|
||||
self.total = len(updatelist)
|
||||
del updatelist[:]
|
||||
|
@ -152,18 +149,20 @@ class Music(common.Items):
|
|||
for kodiartist in all_kodiartists:
|
||||
if kodiartist not in all_embyartistsIds and all_kodiartists[kodiartist] is not None:
|
||||
self.remove(kodiartist)
|
||||
else:
|
||||
log.info("Artist compare finished.")
|
||||
|
||||
log.info("Artist compare finished.")
|
||||
|
||||
for kodialbum in all_kodialbums:
|
||||
if kodialbum not in all_embyalbumsIds:
|
||||
self.remove(kodialbum)
|
||||
else:
|
||||
log.info("Albums compare finished.")
|
||||
|
||||
log.info("Albums compare finished.")
|
||||
|
||||
for kodisong in all_kodisongs:
|
||||
if kodisong not in all_embysongsIds:
|
||||
self.remove(kodisong)
|
||||
else:
|
||||
log.info("Songs compare finished.")
|
||||
|
||||
log.info("Songs compare finished.")
|
||||
return True
|
||||
|
||||
|
||||
|
@ -212,7 +211,7 @@ class Music(common.Items):
|
|||
artistid = emby_dbitem[0]
|
||||
except TypeError:
|
||||
update_item = False
|
||||
log.debug("artistid: %s not found." % itemid)
|
||||
log.debug("artistid: %s not found", itemid)
|
||||
|
||||
##### The artist details #####
|
||||
lastScraped = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
@ -239,20 +238,19 @@ class Music(common.Items):
|
|||
|
||||
##### UPDATE THE ARTIST #####
|
||||
if update_item:
|
||||
log.info("UPDATE artist itemid: %s - Name: %s" % (itemid, name))
|
||||
log.info("UPDATE artist itemid: %s - Name: %s", itemid, name)
|
||||
# Update the checksum in emby table
|
||||
emby_db.updateReference(itemid, checksum)
|
||||
|
||||
##### OR ADD THE ARTIST #####
|
||||
else:
|
||||
log.info("ADD artist itemid: %s - Name: %s" % (itemid, name))
|
||||
log.info("ADD artist itemid: %s - Name: %s", itemid, name)
|
||||
# safety checks: It looks like Emby supports the same artist multiple times.
|
||||
# Kodi doesn't allow that. In case that happens we just merge the artist entries.
|
||||
artistid = self.kodi_db.addArtist(name, musicBrainzId)
|
||||
# Create the reference in emby table
|
||||
emby_db.addReference(itemid, artistid, artisttype, "artist", checksum=checksum)
|
||||
|
||||
|
||||
# Process the artist
|
||||
if self.kodi_version in (16, 17):
|
||||
query = ' '.join((
|
||||
|
@ -272,8 +270,7 @@ class Music(common.Items):
|
|||
"WHERE idArtist = ?"
|
||||
))
|
||||
kodicursor.execute(query, (genres, bio, thumb, fanart, lastScraped,
|
||||
dateadded, artistid))
|
||||
|
||||
dateadded, artistid))
|
||||
|
||||
# Update artwork
|
||||
artwork.add_artwork(artworks, artistid, "artist", kodicursor)
|
||||
|
@ -296,7 +293,7 @@ class Music(common.Items):
|
|||
albumid = emby_dbitem[0]
|
||||
except TypeError:
|
||||
update_item = False
|
||||
log.debug("albumid: %s not found." % itemid)
|
||||
log.debug("albumid: %s not found", itemid)
|
||||
|
||||
##### The album details #####
|
||||
lastScraped = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
@ -325,13 +322,13 @@ class Music(common.Items):
|
|||
|
||||
##### UPDATE THE ALBUM #####
|
||||
if update_item:
|
||||
log.info("UPDATE album itemid: %s - Name: %s" % (itemid, name))
|
||||
log.info("UPDATE album itemid: %s - Name: %s", itemid, name)
|
||||
# Update the checksum in emby table
|
||||
emby_db.updateReference(itemid, checksum)
|
||||
|
||||
##### OR ADD THE ALBUM #####
|
||||
else:
|
||||
log.info("ADD album itemid: %s - Name: %s" % (itemid, name))
|
||||
log.info("ADD album itemid: %s - Name: %s", itemid, name)
|
||||
# safety checks: It looks like Emby supports the same artist multiple times.
|
||||
# Kodi doesn't allow that. In case that happens we just merge the artist entries.
|
||||
albumid = self.kodi_db.addAlbum(name, musicBrainzId)
|
||||
|
@ -350,7 +347,7 @@ class Music(common.Items):
|
|||
"WHERE idAlbum = ?"
|
||||
))
|
||||
kodicursor.execute(query, (artistname, year, genre, bio, thumb, rating, lastScraped,
|
||||
"album", albumid))
|
||||
"album", albumid))
|
||||
elif self.kodi_version == 16:
|
||||
# Kodi Jarvis
|
||||
query = ' '.join((
|
||||
|
@ -361,7 +358,7 @@ class Music(common.Items):
|
|||
"WHERE idAlbum = ?"
|
||||
))
|
||||
kodicursor.execute(query, (artistname, year, genre, bio, thumb, rating, lastScraped,
|
||||
"album", albumid))
|
||||
"album", albumid))
|
||||
elif self.kodi_version == 15:
|
||||
# Kodi Isengard
|
||||
query = ' '.join((
|
||||
|
@ -372,7 +369,7 @@ class Music(common.Items):
|
|||
"WHERE idAlbum = ?"
|
||||
))
|
||||
kodicursor.execute(query, (artistname, year, genre, bio, thumb, rating, lastScraped,
|
||||
dateadded, "album", albumid))
|
||||
dateadded, "album", albumid))
|
||||
else:
|
||||
# Kodi Helix
|
||||
query = ' '.join((
|
||||
|
@ -383,7 +380,7 @@ class Music(common.Items):
|
|||
"WHERE idAlbum = ?"
|
||||
))
|
||||
kodicursor.execute(query, (artistname, year, genre, bio, thumb, rating, lastScraped,
|
||||
dateadded, albumid))
|
||||
dateadded, albumid))
|
||||
|
||||
# Assign main artists to album
|
||||
for artist in item['AlbumArtists']:
|
||||
|
@ -458,7 +455,7 @@ class Music(common.Items):
|
|||
albumid = emby_dbitem[3]
|
||||
except TypeError:
|
||||
update_item = False
|
||||
log.debug("songid: %s not found." % itemid)
|
||||
log.debug("songid: %s not found", itemid)
|
||||
|
||||
##### The song details #####
|
||||
checksum = API.get_checksum()
|
||||
|
@ -518,7 +515,7 @@ class Music(common.Items):
|
|||
|
||||
##### UPDATE THE SONG #####
|
||||
if update_item:
|
||||
log.info("UPDATE song itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("UPDATE song itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Update path
|
||||
query = "UPDATE path SET strPath = ? WHERE idPath = ?"
|
||||
|
@ -534,14 +531,14 @@ class Music(common.Items):
|
|||
"WHERE idSong = ?"
|
||||
))
|
||||
kodicursor.execute(query, (albumid, artists, genre, title, track, duration, year,
|
||||
filename, playcount, dateplayed, rating, comment, songid))
|
||||
filename, playcount, dateplayed, rating, comment, songid))
|
||||
|
||||
# Update the checksum in emby table
|
||||
emby_db.updateReference(itemid, checksum)
|
||||
|
||||
##### OR ADD THE SONG #####
|
||||
else:
|
||||
log.info("ADD song itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("ADD song itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Add path
|
||||
pathid = self.kodi_db.addPath(path)
|
||||
|
@ -554,12 +551,12 @@ class Music(common.Items):
|
|||
# Verify if there's an album associated.
|
||||
album_name = item.get('Album')
|
||||
if album_name:
|
||||
log.info("Creating virtual music album for song: %s." % itemid)
|
||||
log.info("Creating virtual music album for song: %s", itemid)
|
||||
albumid = self.kodi_db.addAlbum(album_name, API.get_provider('MusicBrainzAlbum'))
|
||||
emby_db.addReference("%salbum%s" % (itemid, albumid), albumid, "MusicAlbum_", "album")
|
||||
else:
|
||||
# No album Id associated to the song.
|
||||
log.error("Song itemid: %s has no albumId associated." % itemid)
|
||||
log.error("Song itemid: %s has no albumId associated", itemid)
|
||||
return False
|
||||
|
||||
except TypeError:
|
||||
|
@ -571,7 +568,7 @@ class Music(common.Items):
|
|||
emby_dbalbum = emby_db.getItem_byId(emby_albumId)
|
||||
try:
|
||||
albumid = emby_dbalbum[0]
|
||||
log.info("Found albumid: %s" % albumid)
|
||||
log.info("Found albumid: %s", albumid)
|
||||
except TypeError:
|
||||
# No album found, create a single's album
|
||||
log.info("Failed to add album. Creating singles.")
|
||||
|
@ -622,12 +619,12 @@ class Music(common.Items):
|
|||
'''
|
||||
)
|
||||
kodicursor.execute(query, (songid, albumid, pathid, artists, genre, title, track,
|
||||
duration, year, filename, musicBrainzId, playcount, dateplayed, rating))
|
||||
duration, year, filename, musicBrainzId, playcount,
|
||||
dateplayed, rating))
|
||||
|
||||
# Create the reference in emby table
|
||||
emby_db.addReference(itemid, songid, "Audio", "song", pathid=pathid, parentid=albumid,
|
||||
checksum=checksum)
|
||||
|
||||
checksum=checksum)
|
||||
|
||||
# Link song to album
|
||||
query = (
|
||||
|
@ -720,30 +717,30 @@ class Music(common.Items):
|
|||
'''
|
||||
)
|
||||
kodicursor.execute(query, (artistid, item['Album'], 0))
|
||||
else:
|
||||
album_artists = " / ".join(album_artists)
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT strArtists",
|
||||
"FROM album",
|
||||
"WHERE idAlbum = ?"
|
||||
))
|
||||
kodicursor.execute(query, (albumid,))
|
||||
result = kodicursor.fetchone()
|
||||
if result and result[0] != album_artists:
|
||||
# Field is empty
|
||||
if self.kodi_version in (16, 17):
|
||||
# Kodi Jarvis, Krypton
|
||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||
kodicursor.execute(query, (album_artists, albumid))
|
||||
elif self.kodi_version == 15:
|
||||
# Kodi Isengard
|
||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||
kodicursor.execute(query, (album_artists, albumid))
|
||||
else:
|
||||
# Kodi Helix
|
||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||
kodicursor.execute(query, (album_artists, albumid))
|
||||
album_artists = " / ".join(album_artists)
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT strArtists",
|
||||
"FROM album",
|
||||
"WHERE idAlbum = ?"
|
||||
))
|
||||
kodicursor.execute(query, (albumid,))
|
||||
result = kodicursor.fetchone()
|
||||
if result and result[0] != album_artists:
|
||||
# Field is empty
|
||||
if self.kodi_version in (16, 17):
|
||||
# Kodi Jarvis, Krypton
|
||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||
kodicursor.execute(query, (album_artists, albumid))
|
||||
elif self.kodi_version == 15:
|
||||
# Kodi Isengard
|
||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||
kodicursor.execute(query, (album_artists, albumid))
|
||||
else:
|
||||
# Kodi Helix
|
||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||
kodicursor.execute(query, (album_artists, albumid))
|
||||
|
||||
# Add genres
|
||||
self.kodi_db.addMusicGenres(songid, genres, "song")
|
||||
|
@ -751,7 +748,7 @@ class Music(common.Items):
|
|||
# Update artwork
|
||||
allart = artwork.get_all_artwork(item, parent_info=True)
|
||||
if hasEmbeddedCover:
|
||||
allart["Primary"] = "image://music@" + artwork.single_urlencode( playurl )
|
||||
allart["Primary"] = "image://music@" + artwork.single_urlencode(playurl)
|
||||
artwork.add_artwork(allart, songid, "song", kodicursor)
|
||||
|
||||
if item.get('AlbumId') is None:
|
||||
|
@ -771,7 +768,6 @@ class Music(common.Items):
|
|||
itemid = item['Id']
|
||||
checksum = API.get_checksum()
|
||||
userdata = API.get_userdata()
|
||||
runtime = API.get_runtime()
|
||||
rating = userdata['UserRating']
|
||||
|
||||
# Get Kodi information
|
||||
|
@ -779,7 +775,7 @@ class Music(common.Items):
|
|||
try:
|
||||
kodiid = emby_dbitem[0]
|
||||
mediatype = emby_dbitem[4]
|
||||
log.info("Update playstate for %s: %s" % (mediatype, item['Name']))
|
||||
log.info("Update playstate for %s: %s", mediatype, item['Name'])
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
@ -814,14 +810,12 @@ class Music(common.Items):
|
|||
def remove(self, itemid):
|
||||
# Remove kodiid, fileid, pathid, emby reference
|
||||
emby_db = self.emby_db
|
||||
kodicursor = self.kodicursor
|
||||
artwork = self.artwork
|
||||
|
||||
emby_dbitem = emby_db.getItem_byId(itemid)
|
||||
try:
|
||||
kodiid = emby_dbitem[0]
|
||||
mediatype = emby_dbitem[4]
|
||||
log.info("Removing %s kodiid: %s" % (mediatype, kodiid))
|
||||
log.info("Removing %s kodiid: %s", mediatype, kodiid)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
|
|
@ -4,15 +4,12 @@
|
|||
|
||||
import logging
|
||||
import urllib
|
||||
from ntpath import dirname
|
||||
from datetime import datetime
|
||||
|
||||
import api
|
||||
import common
|
||||
import downloadutils
|
||||
import embydb_functions as embydb
|
||||
import kodidb_functions as kodidb
|
||||
from utils import window, settings, language as lang, catch_except
|
||||
from utils import window, language as lang, catch_except
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -53,7 +50,7 @@ class MusicVideos(common.Items):
|
|||
pdialog = self.pdialog
|
||||
# Pull the list of musicvideos in Kodi
|
||||
views = self.emby_db.getView_byType('musicvideos')
|
||||
log.info("Media folders: %s" % views)
|
||||
log.info("Media folders: %s", views)
|
||||
|
||||
try:
|
||||
all_kodimvideos = dict(self.emby_db.get_checksum('MusicVideo'))
|
||||
|
@ -92,7 +89,7 @@ class MusicVideos(common.Items):
|
|||
# Only update if musicvideo is not in Kodi or checksum is different
|
||||
updatelist.append(itemid)
|
||||
|
||||
log.info("MusicVideos to update for %s: %s" % (viewName, updatelist))
|
||||
log.info("MusicVideos to update for %s: %s", viewName, updatelist)
|
||||
embymvideos = self.emby.getFullItems(updatelist)
|
||||
self.total = len(updatelist)
|
||||
del updatelist[:]
|
||||
|
@ -116,9 +113,8 @@ class MusicVideos(common.Items):
|
|||
for kodimvideo in all_kodimvideos:
|
||||
if kodimvideo not in all_embymvideosIds:
|
||||
self.remove(kodimvideo)
|
||||
else:
|
||||
log.info("MusicVideos compare finished.")
|
||||
|
||||
log.info("MusicVideos compare finished.")
|
||||
return True
|
||||
|
||||
|
||||
|
@ -144,11 +140,11 @@ class MusicVideos(common.Items):
|
|||
mvideoid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
pathid = emby_dbitem[2]
|
||||
log.info("mvideoid: %s fileid: %s pathid: %s" % (mvideoid, fileid, pathid))
|
||||
log.info("mvideoid: %s fileid: %s pathid: %s", mvideoid, fileid, pathid)
|
||||
|
||||
except TypeError:
|
||||
update_item = False
|
||||
log.debug("mvideoid: %s not found." % itemid)
|
||||
log.debug("mvideoid: %s not found", itemid)
|
||||
# mvideoid
|
||||
kodicursor.execute("select coalesce(max(idMVideo),0) from musicvideo")
|
||||
mvideoid = kodicursor.fetchone()[0] + 1
|
||||
|
@ -162,12 +158,12 @@ class MusicVideos(common.Items):
|
|||
except TypeError:
|
||||
# item is not found, let's recreate it.
|
||||
update_item = False
|
||||
log.info("mvideoid: %s missing from Kodi, repairing the entry." % mvideoid)
|
||||
log.info("mvideoid: %s missing from Kodi, repairing the entry.", mvideoid)
|
||||
|
||||
if not view:
|
||||
# Get view tag from emby
|
||||
viewtag, viewid, mediatype = self.emby.getView_embyId(itemid)
|
||||
log.debug("View tag found: %s" % viewtag)
|
||||
log.debug("View tag found: %s", viewtag)
|
||||
else:
|
||||
viewtag = view['name']
|
||||
viewid = view['id']
|
||||
|
@ -226,7 +222,7 @@ class MusicVideos(common.Items):
|
|||
|
||||
##### UPDATE THE MUSIC VIDEO #####
|
||||
if update_item:
|
||||
log.info("UPDATE mvideo itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("UPDATE mvideo itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Update path
|
||||
query = "UPDATE path SET strPath = ? WHERE idPath = ?"
|
||||
|
@ -245,14 +241,13 @@ class MusicVideos(common.Items):
|
|||
"WHERE idMVideo = ?"
|
||||
))
|
||||
kodicursor.execute(query, (title, runtime, director, studio, year, plot, album,
|
||||
artist, genre, track, mvideoid))
|
||||
|
||||
artist, genre, track, mvideoid))
|
||||
# Update the checksum in emby table
|
||||
emby_db.updateReference(itemid, checksum)
|
||||
|
||||
##### OR ADD THE MUSIC VIDEO #####
|
||||
else:
|
||||
log.info("ADD mvideo itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("ADD mvideo itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Add path
|
||||
query = ' '.join((
|
||||
|
@ -300,12 +295,11 @@ class MusicVideos(common.Items):
|
|||
'''
|
||||
)
|
||||
kodicursor.execute(query, (mvideoid, fileid, title, runtime, director, studio,
|
||||
year, plot, album, artist, genre, track))
|
||||
year, plot, album, artist, genre, track))
|
||||
|
||||
# Create the reference in emby table
|
||||
emby_db.addReference(itemid, mvideoid, "MusicVideo", "musicvideo", fileid, pathid,
|
||||
checksum=checksum, mediafolderid=viewid)
|
||||
|
||||
checksum=checksum, mediafolderid=viewid)
|
||||
|
||||
# Process cast
|
||||
people = item['People']
|
||||
|
@ -354,9 +348,7 @@ class MusicVideos(common.Items):
|
|||
try:
|
||||
mvideoid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
log.info(
|
||||
"Update playstate for musicvideo: %s fileid: %s"
|
||||
% (item['Name'], fileid))
|
||||
log.info("Update playstate for musicvideo: %s fileid: %s", item['Name'], fileid)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
@ -386,7 +378,7 @@ class MusicVideos(common.Items):
|
|||
mvideoid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
pathid = emby_dbitem[2]
|
||||
log.info("Removing mvideoid: %s fileid: %s" % (mvideoid, fileid, pathid))
|
||||
log.info("Removing mvideoid: %s fileid: %s pathid: %s", mvideoid, fileid, pathid)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
@ -412,4 +404,4 @@ class MusicVideos(common.Items):
|
|||
kodicursor.execute("DELETE FROM path WHERE idPath = ?", (pathid,))
|
||||
self.embycursor.execute("DELETE FROM emby WHERE emby_id = ?", (itemid,))
|
||||
|
||||
log.info("Deleted musicvideo %s from kodi database" % itemid)
|
||||
log.info("Deleted musicvideo %s from kodi database", itemid)
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
import logging
|
||||
import urllib
|
||||
from ntpath import dirname
|
||||
from datetime import datetime
|
||||
|
||||
import api
|
||||
import common
|
||||
import downloadutils
|
||||
import embydb_functions as embydb
|
||||
import kodidb_functions as kodidb
|
||||
from utils import window, settings, language as lang, catch_except
|
||||
|
@ -69,7 +67,7 @@ class TVShows(common.Items):
|
|||
pdialog = self.pdialog
|
||||
views = self.emby_db.getView_byType('tvshows')
|
||||
views += self.emby_db.getView_byType('mixed')
|
||||
log.info("Media folders: %s" % views)
|
||||
log.info("Media folders: %s", views)
|
||||
|
||||
# Pull the list of tvshows and episodes in Kodi
|
||||
try:
|
||||
|
@ -118,7 +116,7 @@ class TVShows(common.Items):
|
|||
# Only update if movie is not in Kodi or checksum is different
|
||||
updatelist.append(itemid)
|
||||
|
||||
log.info("TVShows to update for %s: %s" % (viewName, updatelist))
|
||||
log.info("TVShows to update for %s: %s", viewName, updatelist)
|
||||
embytvshows = self.emby.getFullItems(updatelist)
|
||||
self.total = len(updatelist)
|
||||
del updatelist[:]
|
||||
|
@ -164,7 +162,7 @@ class TVShows(common.Items):
|
|||
# Only update if movie is not in Kodi or checksum is different
|
||||
updatelist.append(itemid)
|
||||
|
||||
log.info("Episodes to update for %s: %s" % (viewName, updatelist))
|
||||
log.info("Episodes to update for %s: %s", viewName, updatelist)
|
||||
embyepisodes = self.emby.getFullItems(updatelist)
|
||||
self.total = len(updatelist)
|
||||
del updatelist[:]
|
||||
|
@ -181,19 +179,19 @@ class TVShows(common.Items):
|
|||
|
||||
##### PROCESS DELETES #####
|
||||
|
||||
log.info("all_embytvshowsIds = %s " % all_embytvshowsIds)
|
||||
log.info("all_embytvshowsIds = %s ", all_embytvshowsIds)
|
||||
|
||||
for koditvshow in all_koditvshows:
|
||||
if koditvshow not in all_embytvshowsIds:
|
||||
self.remove(koditvshow)
|
||||
else:
|
||||
log.info("TVShows compare finished.")
|
||||
|
||||
log.info("TVShows compare finished.")
|
||||
|
||||
for kodiepisode in all_kodiepisodes:
|
||||
if kodiepisode not in all_embyepisodesIds:
|
||||
self.remove(kodiepisode)
|
||||
else:
|
||||
log.info("Episodes compare finished.")
|
||||
|
||||
log.info("Episodes compare finished.")
|
||||
|
||||
return True
|
||||
|
||||
|
@ -238,7 +236,7 @@ class TVShows(common.Items):
|
|||
API = api.API(item)
|
||||
|
||||
if settings('syncEmptyShows') == "false" and not item.get('RecursiveItemCount'):
|
||||
log.info("Skipping empty show: %s" % item['Name'])
|
||||
log.info("Skipping empty show: %s", item['Name'])
|
||||
return
|
||||
# If the item already exist in the local Kodi DB we'll perform a full item update
|
||||
# If the item doesn't exist, we'll add it to the database
|
||||
|
@ -249,11 +247,11 @@ class TVShows(common.Items):
|
|||
try:
|
||||
showid = emby_dbitem[0]
|
||||
pathid = emby_dbitem[2]
|
||||
log.info("showid: %s pathid: %s" % (showid, pathid))
|
||||
log.info("showid: %s pathid: %s", showid, pathid)
|
||||
|
||||
except TypeError:
|
||||
update_item = False
|
||||
log.debug("showid: %s not found." % itemid)
|
||||
log.debug("showid: %s not found", itemid)
|
||||
kodicursor.execute("select coalesce(max(idShow),0) from tvshow")
|
||||
showid = kodicursor.fetchone()[0] + 1
|
||||
|
||||
|
@ -266,7 +264,7 @@ class TVShows(common.Items):
|
|||
except TypeError:
|
||||
# item is not found, let's recreate it.
|
||||
update_item = False
|
||||
log.info("showid: %s missing from Kodi, repairing the entry." % showid)
|
||||
log.info("showid: %s missing from Kodi, repairing the entry", showid)
|
||||
# Force re-add episodes after the show is re-created.
|
||||
force_episodes = True
|
||||
|
||||
|
@ -274,17 +272,14 @@ class TVShows(common.Items):
|
|||
if view is None:
|
||||
# Get view tag from emby
|
||||
viewtag, viewid, mediatype = emby.getView_embyId(itemid)
|
||||
log.debug("View tag found: %s" % viewtag)
|
||||
log.debug("View tag found: %s", viewtag)
|
||||
else:
|
||||
viewtag = view['name']
|
||||
viewid = view['id']
|
||||
|
||||
# fileId information
|
||||
checksum = API.get_checksum()
|
||||
dateadded = API.get_date_created()
|
||||
userdata = API.get_userdata()
|
||||
playcount = userdata['PlayCount']
|
||||
dateplayed = userdata['LastPlayedDate']
|
||||
|
||||
# item details
|
||||
genres = item['Genres']
|
||||
|
@ -314,10 +309,10 @@ class TVShows(common.Items):
|
|||
emby_other_item = emby_db.getItem_byId(emby_other[0])
|
||||
showid = emby_other_item[0]
|
||||
pathid = emby_other_item[2]
|
||||
log.info("showid: %s pathid: %s" % (showid, pathid))
|
||||
log.info("showid: %s pathid: %s", showid, pathid)
|
||||
# Create the reference in emby table
|
||||
emby_db.addReference(itemid, showid, "Series", "tvshow", pathid=pathid,
|
||||
checksum=checksum, mediafolderid=viewid)
|
||||
checksum=checksum, mediafolderid=viewid)
|
||||
update_item = True
|
||||
|
||||
|
||||
|
@ -347,7 +342,7 @@ class TVShows(common.Items):
|
|||
|
||||
##### UPDATE THE TVSHOW #####
|
||||
if update_item:
|
||||
log.info("UPDATE tvshow itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("UPDATE tvshow itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Update the tvshow entry
|
||||
query = ' '.join((
|
||||
|
@ -358,14 +353,14 @@ class TVShows(common.Items):
|
|||
"WHERE idShow = ?"
|
||||
))
|
||||
kodicursor.execute(query, (title, plot, rating, premieredate, genre, title,
|
||||
tvdb, mpaa, studio, sorttitle, showid))
|
||||
tvdb, mpaa, studio, sorttitle, showid))
|
||||
|
||||
# Update the checksum in emby table
|
||||
emby_db.updateReference(itemid, checksum)
|
||||
|
||||
##### OR ADD THE TVSHOW #####
|
||||
else:
|
||||
log.info("ADD tvshow itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("ADD tvshow itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Add top path
|
||||
toppathid = self.kodi_db.addPath(toplevelpath)
|
||||
|
@ -383,14 +378,13 @@ class TVShows(common.Items):
|
|||
# Create the tvshow entry
|
||||
query = (
|
||||
'''
|
||||
INSERT INTO tvshow(
|
||||
idShow, c00, c01, c04, c05, c08, c09, c12, c13, c14, c15)
|
||||
INSERT INTO tvshow(idShow, c00, c01, c04, c05, c08, c09, c12, c13, c14, c15)
|
||||
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
'''
|
||||
)
|
||||
kodicursor.execute(query, (showid, title, plot, rating, premieredate, genre,
|
||||
title, tvdb, mpaa, studio, sorttitle))
|
||||
title, tvdb, mpaa, studio, sorttitle))
|
||||
|
||||
# Link the path
|
||||
query = "INSERT INTO tvshowlinkpath(idShow, idPath) values(?, ?)"
|
||||
|
@ -398,7 +392,7 @@ class TVShows(common.Items):
|
|||
|
||||
# Create the reference in emby table
|
||||
emby_db.addReference(itemid, showid, "Series", "tvshow", pathid=pathid,
|
||||
checksum=checksum, mediafolderid=viewid)
|
||||
checksum=checksum, mediafolderid=viewid)
|
||||
|
||||
# Update the path
|
||||
query = ' '.join((
|
||||
|
@ -436,7 +430,7 @@ class TVShows(common.Items):
|
|||
|
||||
if force_episodes:
|
||||
# We needed to recreate the show entry. Re-add episodes now.
|
||||
log.info("Repairing episodes for showid: %s %s" % (showid, title))
|
||||
log.info("Repairing episodes for showid: %s %s", showid, title)
|
||||
all_episodes = emby.getEpisodesbyShow(itemid)
|
||||
self.added_episode(all_episodes['Items'], None)
|
||||
|
||||
|
@ -494,11 +488,11 @@ class TVShows(common.Items):
|
|||
episodeid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
pathid = emby_dbitem[2]
|
||||
log.info("episodeid: %s fileid: %s pathid: %s" % (episodeid, fileid, pathid))
|
||||
log.info("episodeid: %s fileid: %s pathid: %s", episodeid, fileid, pathid)
|
||||
|
||||
except TypeError:
|
||||
update_item = False
|
||||
log.debug("episodeid: %s not found." % itemid)
|
||||
log.debug("episodeid: %s not found", itemid)
|
||||
# episodeid
|
||||
kodicursor.execute("select coalesce(max(idEpisode),0) from episode")
|
||||
episodeid = kodicursor.fetchone()[0] + 1
|
||||
|
@ -512,7 +506,7 @@ class TVShows(common.Items):
|
|||
except TypeError:
|
||||
# item is not found, let's recreate it.
|
||||
update_item = False
|
||||
log.info("episodeid: %s missing from Kodi, repairing the entry." % episodeid)
|
||||
log.info("episodeid: %s missing from Kodi, repairing the entry", episodeid)
|
||||
|
||||
# fileId information
|
||||
checksum = API.get_checksum()
|
||||
|
@ -536,7 +530,7 @@ class TVShows(common.Items):
|
|||
seriesId = item['SeriesId']
|
||||
except KeyError:
|
||||
# Missing seriesId, skip
|
||||
log.error("Skipping: %s. SeriesId is missing." % itemid)
|
||||
log.error("Skipping: %s. SeriesId is missing.", itemid)
|
||||
return False
|
||||
|
||||
season = item.get('ParentIndexNumber')
|
||||
|
@ -574,7 +568,7 @@ class TVShows(common.Items):
|
|||
try:
|
||||
showid = show[0]
|
||||
except TypeError:
|
||||
log.error("Skipping: %s. Unable to add series: %s." % (itemid, seriesId))
|
||||
log.error("Skipping: %s. Unable to add series: %s", itemid, seriesId)
|
||||
return False
|
||||
|
||||
seasonid = self.kodi_db.addSeason(showid, season)
|
||||
|
@ -611,7 +605,7 @@ class TVShows(common.Items):
|
|||
|
||||
##### UPDATE THE EPISODE #####
|
||||
if update_item:
|
||||
log.info("UPDATE episode itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("UPDATE episode itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Update the movie entry
|
||||
if self.kodi_version in (16, 17):
|
||||
|
@ -623,9 +617,9 @@ class TVShows(common.Items):
|
|||
"c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, idSeason = ?, idShow = ?",
|
||||
"WHERE idEpisode = ?"
|
||||
))
|
||||
kodicursor.execute(query, (title, plot, rating, writer, premieredate,
|
||||
runtime, director, season, episode, title, airsBeforeSeason,
|
||||
airsBeforeEpisode, seasonid, showid, episodeid))
|
||||
kodicursor.execute(query, (title, plot, rating, writer, premieredate, runtime,
|
||||
director, season, episode, title, airsBeforeSeason,
|
||||
airsBeforeEpisode, seasonid, showid, episodeid))
|
||||
else:
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -634,10 +628,9 @@ class TVShows(common.Items):
|
|||
"c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, idShow = ?",
|
||||
"WHERE idEpisode = ?"
|
||||
))
|
||||
kodicursor.execute(query, (title, plot, rating, writer, premieredate,
|
||||
runtime, director, season, episode, title, airsBeforeSeason,
|
||||
airsBeforeEpisode, showid, episodeid))
|
||||
|
||||
kodicursor.execute(query, (title, plot, rating, writer, premieredate, runtime,
|
||||
director, season, episode, title, airsBeforeSeason,
|
||||
airsBeforeEpisode, showid, episodeid))
|
||||
# Update the checksum in emby table
|
||||
emby_db.updateReference(itemid, checksum)
|
||||
# Update parentid reference
|
||||
|
@ -645,7 +638,7 @@ class TVShows(common.Items):
|
|||
|
||||
##### OR ADD THE EPISODE #####
|
||||
else:
|
||||
log.info("ADD episode itemid: %s - Title: %s" % (itemid, title))
|
||||
log.info("ADD episode itemid: %s - Title: %s", itemid, title)
|
||||
|
||||
# Add path
|
||||
pathid = self.kodi_db.addPath(path)
|
||||
|
@ -665,8 +658,8 @@ class TVShows(common.Items):
|
|||
'''
|
||||
)
|
||||
kodicursor.execute(query, (episodeid, fileid, title, plot, rating, writer,
|
||||
premieredate, runtime, director, season, episode, title, showid,
|
||||
airsBeforeSeason, airsBeforeEpisode, seasonid))
|
||||
premieredate, runtime, director, season, episode, title,
|
||||
showid, airsBeforeSeason, airsBeforeEpisode, seasonid))
|
||||
else:
|
||||
query = (
|
||||
'''
|
||||
|
@ -678,12 +671,12 @@ class TVShows(common.Items):
|
|||
'''
|
||||
)
|
||||
kodicursor.execute(query, (episodeid, fileid, title, plot, rating, writer,
|
||||
premieredate, runtime, director, season, episode, title, showid,
|
||||
airsBeforeSeason, airsBeforeEpisode))
|
||||
premieredate, runtime, director, season, episode, title,
|
||||
showid, airsBeforeSeason, airsBeforeEpisode))
|
||||
|
||||
# Create the reference in emby table
|
||||
emby_db.addReference(itemid, episodeid, "Episode", "episode", fileid, pathid,
|
||||
seasonid, checksum)
|
||||
seasonid, checksum)
|
||||
|
||||
# Update the path
|
||||
query = ' '.join((
|
||||
|
@ -750,9 +743,7 @@ class TVShows(common.Items):
|
|||
kodiid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
mediatype = emby_dbitem[4]
|
||||
log.info(
|
||||
"Update playstate for %s: %s fileid: %s"
|
||||
% (mediatype, item['Name'], fileid))
|
||||
log.info("Update playstate for %s: %s fileid: %s", mediatype, item['Name'], fileid)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
@ -769,7 +760,7 @@ class TVShows(common.Items):
|
|||
resume = API.adjust_resume(userdata['Resume'])
|
||||
total = round(float(runtime), 6)
|
||||
|
||||
log.debug("%s New resume point: %s" % (itemid, resume))
|
||||
log.debug("%s New resume point: %s", itemid, resume)
|
||||
|
||||
self.kodi_db.addPlaystate(fileid, resume, total, playcount, dateplayed)
|
||||
if not self.direct_path and not resume:
|
||||
|
@ -796,18 +787,15 @@ class TVShows(common.Items):
|
|||
def remove(self, itemid):
|
||||
# Remove showid, fileid, pathid, emby reference
|
||||
emby_db = self.emby_db
|
||||
embycursor = self.embycursor
|
||||
kodicursor = self.kodicursor
|
||||
artwork = self.artwork
|
||||
|
||||
emby_dbitem = emby_db.getItem_byId(itemid)
|
||||
try:
|
||||
kodiid = emby_dbitem[0]
|
||||
fileid = emby_dbitem[1]
|
||||
pathid = emby_dbitem[2]
|
||||
parentid = emby_dbitem[3]
|
||||
mediatype = emby_dbitem[4]
|
||||
log.info("Removing %s kodiid: %s fileid: %s" % (mediatype, kodiid, fileid))
|
||||
log.info("Removing %s kodiid: %s fileid: %s", mediatype, kodiid, fileid)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
@ -816,7 +804,6 @@ class TVShows(common.Items):
|
|||
# Remove the emby reference
|
||||
emby_db.removeItem(itemid)
|
||||
|
||||
|
||||
##### IF EPISODE #####
|
||||
|
||||
if mediatype == "episode":
|
||||
|
@ -897,14 +884,14 @@ class TVShows(common.Items):
|
|||
self.removeShow(parentid)
|
||||
emby_db.removeItem_byKodiId(parentid, "tvshow")
|
||||
|
||||
log.info("Deleted %s: %s from kodi database" % (mediatype, itemid))
|
||||
log.info("Deleted %s: %s from kodi database", mediatype, itemid)
|
||||
|
||||
def removeShow(self, kodiid):
|
||||
|
||||
kodicursor = self.kodicursor
|
||||
self.artwork.delete_artwork(kodiid, "tvshow", kodicursor)
|
||||
kodicursor.execute("DELETE FROM tvshow WHERE idShow = ?", (kodiid,))
|
||||
log.debug("Removed tvshow: %s." % kodiid)
|
||||
log.debug("Removed tvshow: %s", kodiid)
|
||||
|
||||
def removeSeason(self, kodiid):
|
||||
|
||||
|
@ -912,7 +899,7 @@ class TVShows(common.Items):
|
|||
|
||||
self.artwork.delete_artwork(kodiid, "season", kodicursor)
|
||||
kodicursor.execute("DELETE FROM seasons WHERE idSeason = ?", (kodiid,))
|
||||
log.debug("Removed season: %s." % kodiid)
|
||||
log.debug("Removed season: %s", kodiid)
|
||||
|
||||
def removeEpisode(self, kodiid, fileid):
|
||||
|
||||
|
@ -921,4 +908,4 @@ class TVShows(common.Items):
|
|||
self.artwork.delete_artwork(kodiid, "episode", kodicursor)
|
||||
kodicursor.execute("DELETE FROM episode WHERE idEpisode = ?", (kodiid,))
|
||||
kodicursor.execute("DELETE FROM files WHERE idFile = ?", (fileid,))
|
||||
log.debug("Removed episode: %s." % kodiid)
|
||||
log.debug("Removed episode: %s", kodiid)
|
||||
|
|
Loading…
Reference in a new issue