mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 10:46:11 +00:00
code reduce
This commit is contained in:
parent
8db97c5d3d
commit
b143f34fbf
1 changed files with 2446 additions and 2470 deletions
|
@ -249,10 +249,9 @@ class Movies(Items):
|
||||||
count = 0
|
count = 0
|
||||||
for boxset in items:
|
for boxset in items:
|
||||||
|
|
||||||
title = boxset['Name']
|
|
||||||
if pdialog:
|
if pdialog:
|
||||||
percentage = int((float(count) / float(total))*100)
|
percentage = int((float(count) / float(total))*100)
|
||||||
pdialog.update(percentage, message=title)
|
pdialog.update(percentage, message=boxset['Name'])
|
||||||
count += 1
|
count += 1
|
||||||
self.add_updateBoxset(boxset)
|
self.add_updateBoxset(boxset)
|
||||||
|
|
||||||
|
@ -521,8 +520,7 @@ class Movies(Items):
|
||||||
process.append(current_movie)
|
process.append(current_movie)
|
||||||
|
|
||||||
# New list to compare
|
# New list to compare
|
||||||
boxsetMovies = emby.getMovies_byBoxset(boxsetid)
|
for movie in emby.getMovies_byBoxset(boxsetid)['Items']:
|
||||||
for movie in boxsetMovies['Items']:
|
|
||||||
|
|
||||||
itemid = movie['Id']
|
itemid = movie['Id']
|
||||||
|
|
||||||
|
@ -935,8 +933,7 @@ class MusicVideos(Items):
|
||||||
"AND media_type = 'musicvideo'"
|
"AND media_type = 'musicvideo'"
|
||||||
))
|
))
|
||||||
kodicursor.execute(query, (mvideoid,))
|
kodicursor.execute(query, (mvideoid,))
|
||||||
rows = kodicursor.fetchall()
|
for row in kodicursor.fetchall():
|
||||||
for row in rows:
|
|
||||||
|
|
||||||
url = row[0]
|
url = row[0]
|
||||||
imagetype = row[1]
|
imagetype = row[1]
|
||||||
|
@ -1211,7 +1208,6 @@ class TVShows(Items):
|
||||||
artwork = self.artwork
|
artwork = self.artwork
|
||||||
|
|
||||||
seasonnum = item.get('IndexNumber', 1)
|
seasonnum = item.get('IndexNumber', 1)
|
||||||
itemid = item['Id']
|
|
||||||
|
|
||||||
if showid is None:
|
if showid is None:
|
||||||
try:
|
try:
|
||||||
|
@ -1229,14 +1225,13 @@ class TVShows(Items):
|
||||||
|
|
||||||
if item['LocationType'] != "Virtual":
|
if item['LocationType'] != "Virtual":
|
||||||
# Create the reference in emby table
|
# Create the reference in emby table
|
||||||
emby_db.addReference(itemid, seasonid, "Season", "season", parentid=showid)
|
emby_db.addReference(item['Id'], seasonid, "Season", "season", parentid=showid)
|
||||||
|
|
||||||
# Process artwork
|
# Process artwork
|
||||||
artwork.addArtwork(artwork.getAllArtwork(item), seasonid, "season", kodicursor)
|
artwork.addArtwork(artwork.getAllArtwork(item), seasonid, "season", kodicursor)
|
||||||
|
|
||||||
def add_updateEpisode(self, item):
|
def add_updateEpisode(self, item):
|
||||||
# Process single episode
|
# Process single episode
|
||||||
kodiversion = self.kodiversion
|
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
emby_db = self.emby_db
|
emby_db = self.emby_db
|
||||||
kodi_db = self.kodi_db
|
kodi_db = self.kodi_db
|
||||||
|
@ -1384,7 +1379,7 @@ class TVShows(Items):
|
||||||
self.logMsg("UPDATE episode itemid: %s - Title: %s" % (itemid, title), 1)
|
self.logMsg("UPDATE episode itemid: %s - Title: %s" % (itemid, title), 1)
|
||||||
|
|
||||||
# Update the movie entry
|
# Update the movie entry
|
||||||
if kodiversion in (16, 17):
|
if self.kodiversion in (16, 17):
|
||||||
# Kodi Jarvis, Krypton
|
# Kodi Jarvis, Krypton
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
|
@ -1423,7 +1418,7 @@ class TVShows(Items):
|
||||||
fileid = kodi_db.addFile(filename, pathid)
|
fileid = kodi_db.addFile(filename, pathid)
|
||||||
|
|
||||||
# Create the episode entry
|
# Create the episode entry
|
||||||
if kodiversion in (16, 17):
|
if self.kodiversion in (16, 17):
|
||||||
# Kodi Jarvis, Krypton
|
# Kodi Jarvis, Krypton
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
|
@ -1531,9 +1526,8 @@ class TVShows(Items):
|
||||||
kodi_db.addTag(kodiid, "Favorite tvshows", "tvshow")
|
kodi_db.addTag(kodiid, "Favorite tvshows", "tvshow")
|
||||||
else:
|
else:
|
||||||
kodi_db.removeTag(kodiid, "Favorite tvshows", "tvshow")
|
kodi_db.removeTag(kodiid, "Favorite tvshows", "tvshow")
|
||||||
|
elif mediatype == "episode":
|
||||||
# Process playstates
|
# Process playstates
|
||||||
if mediatype == "episode":
|
|
||||||
playcount = userdata['PlayCount']
|
playcount = userdata['PlayCount']
|
||||||
dateplayed = userdata['LastPlayedDate']
|
dateplayed = userdata['LastPlayedDate']
|
||||||
resume = API.adjustResume(userdata['Resume'])
|
resume = API.adjustResume(userdata['Resume'])
|
||||||
|
@ -1672,27 +1666,23 @@ class TVShows(Items):
|
||||||
def removeShow(self, kodiid):
|
def removeShow(self, kodiid):
|
||||||
|
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
artwork = self.artwork
|
self.artwork.deleteArtwork(kodiid, "tvshow", kodicursor)
|
||||||
|
|
||||||
artwork.deleteArtwork(kodiid, "tvshow", kodicursor)
|
|
||||||
kodicursor.execute("DELETE FROM tvshow WHERE idShow = ?", (kodiid,))
|
kodicursor.execute("DELETE FROM tvshow WHERE idShow = ?", (kodiid,))
|
||||||
self.logMsg("Removed tvshow: %s." % kodiid, 2)
|
self.logMsg("Removed tvshow: %s." % kodiid, 2)
|
||||||
|
|
||||||
def removeSeason(self, kodiid):
|
def removeSeason(self, kodiid):
|
||||||
|
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
artwork = self.artwork
|
|
||||||
|
|
||||||
artwork.deleteArtwork(kodiid, "season", kodicursor)
|
self.artwork.deleteArtwork(kodiid, "season", kodicursor)
|
||||||
kodicursor.execute("DELETE FROM seasons WHERE idSeason = ?", (kodiid,))
|
kodicursor.execute("DELETE FROM seasons WHERE idSeason = ?", (kodiid,))
|
||||||
self.logMsg("Removed season: %s." % kodiid, 2)
|
self.logMsg("Removed season: %s." % kodiid, 2)
|
||||||
|
|
||||||
def removeEpisode(self, kodiid, fileid):
|
def removeEpisode(self, kodiid, fileid):
|
||||||
|
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
artwork = self.artwork
|
|
||||||
|
|
||||||
artwork.deleteArtwork(kodiid, "episode", kodicursor)
|
self.artwork.deleteArtwork(kodiid, "episode", kodicursor)
|
||||||
kodicursor.execute("DELETE FROM episode WHERE idEpisode = ?", (kodiid,))
|
kodicursor.execute("DELETE FROM episode WHERE idEpisode = ?", (kodiid,))
|
||||||
kodicursor.execute("DELETE FROM files WHERE idFile = ?", (fileid,))
|
kodicursor.execute("DELETE FROM files WHERE idFile = ?", (fileid,))
|
||||||
self.logMsg("Removed episode: %s." % kodiid, 2)
|
self.logMsg("Removed episode: %s." % kodiid, 2)
|
||||||
|
@ -1717,10 +1707,9 @@ class Music(Items):
|
||||||
count = 0
|
count = 0
|
||||||
for artist in items:
|
for artist in items:
|
||||||
|
|
||||||
title = artist['Name']
|
|
||||||
if pdialog:
|
if pdialog:
|
||||||
percentage = int((float(count) / float(total))*100)
|
percentage = int((float(count) / float(total))*100)
|
||||||
pdialog.update(percentage, message=title)
|
pdialog.update(percentage, message=artist['Name'])
|
||||||
count += 1
|
count += 1
|
||||||
self.add_updateArtist(artist)
|
self.add_updateArtist(artist)
|
||||||
# Add albums
|
# Add albums
|
||||||
|
@ -1733,10 +1722,9 @@ class Music(Items):
|
||||||
count = 0
|
count = 0
|
||||||
for album in items:
|
for album in items:
|
||||||
|
|
||||||
title = album['Name']
|
|
||||||
if pdialog:
|
if pdialog:
|
||||||
percentage = int((float(count) / float(total))*100)
|
percentage = int((float(count) / float(total))*100)
|
||||||
pdialog.update(percentage, message=title)
|
pdialog.update(percentage, message=album['Name'])
|
||||||
count += 1
|
count += 1
|
||||||
self.add_updateAlbum(album)
|
self.add_updateAlbum(album)
|
||||||
# Add songs
|
# Add songs
|
||||||
|
@ -1749,10 +1737,9 @@ class Music(Items):
|
||||||
count = 0
|
count = 0
|
||||||
for song in items:
|
for song in items:
|
||||||
|
|
||||||
title = song['Name']
|
|
||||||
if pdialog:
|
if pdialog:
|
||||||
percentage = int((float(count) / float(total))*100)
|
percentage = int((float(count) / float(total))*100)
|
||||||
pdialog.update(percentage, message=title)
|
pdialog.update(percentage, message=song['Name'])
|
||||||
count += 1
|
count += 1
|
||||||
self.add_updateSong(song)
|
self.add_updateSong(song)
|
||||||
if not pdialog and self.contentmsg:
|
if not pdialog and self.contentmsg:
|
||||||
|
@ -1760,7 +1747,6 @@ class Music(Items):
|
||||||
|
|
||||||
def add_updateArtist(self, item, artisttype="MusicArtist"):
|
def add_updateArtist(self, item, artisttype="MusicArtist"):
|
||||||
# Process a single artist
|
# Process a single artist
|
||||||
kodiversion = self.kodiversion
|
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
emby_db = self.emby_db
|
emby_db = self.emby_db
|
||||||
kodi_db = self.kodi_db
|
kodi_db = self.kodi_db
|
||||||
|
@ -1843,7 +1829,6 @@ class Music(Items):
|
||||||
def add_updateAlbum(self, item):
|
def add_updateAlbum(self, item):
|
||||||
# Process a single artist
|
# Process a single artist
|
||||||
emby = self.emby
|
emby = self.emby
|
||||||
kodiversion = self.kodiversion
|
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
emby_db = self.emby_db
|
emby_db = self.emby_db
|
||||||
kodi_db = self.kodi_db
|
kodi_db = self.kodi_db
|
||||||
|
@ -1903,7 +1888,7 @@ class Music(Items):
|
||||||
|
|
||||||
|
|
||||||
# Process the album info
|
# Process the album info
|
||||||
if kodiversion == 17:
|
if self.kodiversion == 17:
|
||||||
# Kodi Krypton
|
# Kodi Krypton
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
|
@ -1914,7 +1899,7 @@ class Music(Items):
|
||||||
))
|
))
|
||||||
kodicursor.execute(query, (artistname, year, genre, bio, thumb, rating, lastScraped,
|
kodicursor.execute(query, (artistname, year, genre, bio, thumb, rating, lastScraped,
|
||||||
"album", albumid))
|
"album", albumid))
|
||||||
elif kodiversion == 16:
|
elif self.kodiversion == 16:
|
||||||
# Kodi Jarvis
|
# Kodi Jarvis
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
|
@ -1925,7 +1910,7 @@ class Music(Items):
|
||||||
))
|
))
|
||||||
kodicursor.execute(query, (artistname, year, genre, bio, thumb, rating, lastScraped,
|
kodicursor.execute(query, (artistname, year, genre, bio, thumb, rating, lastScraped,
|
||||||
"album", albumid))
|
"album", albumid))
|
||||||
elif kodiversion == 15:
|
elif self.kodiversion == 15:
|
||||||
# Kodi Isengard
|
# Kodi Isengard
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
||||||
|
@ -2012,7 +1997,6 @@ class Music(Items):
|
||||||
|
|
||||||
def add_updateSong(self, item):
|
def add_updateSong(self, item):
|
||||||
# Process single song
|
# Process single song
|
||||||
kodiversion = self.kodiversion
|
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
emby = self.emby
|
emby = self.emby
|
||||||
emby_db = self.emby_db
|
emby_db = self.emby_db
|
||||||
|
@ -2155,7 +2139,7 @@ class Music(Items):
|
||||||
self.logMsg("Failed to add album. Creating singles.", 1)
|
self.logMsg("Failed to add album. Creating singles.", 1)
|
||||||
kodicursor.execute("select coalesce(max(idAlbum),0) from album")
|
kodicursor.execute("select coalesce(max(idAlbum),0) from album")
|
||||||
albumid = kodicursor.fetchone()[0] + 1
|
albumid = kodicursor.fetchone()[0] + 1
|
||||||
if kodiversion == 16:
|
if self.kodiversion == 16:
|
||||||
# Kodi Jarvis
|
# Kodi Jarvis
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
|
@ -2165,7 +2149,7 @@ class Music(Items):
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
kodicursor.execute(query, (albumid, genre, year, "single"))
|
kodicursor.execute(query, (albumid, genre, year, "single"))
|
||||||
elif kodiversion == 15:
|
elif self.kodiversion == 15:
|
||||||
# Kodi Isengard
|
# Kodi Isengard
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
|
@ -2289,11 +2273,11 @@ class Music(Items):
|
||||||
result = kodicursor.fetchone()
|
result = kodicursor.fetchone()
|
||||||
if result and result[0] != album_artists:
|
if result and result[0] != album_artists:
|
||||||
# Field is empty
|
# Field is empty
|
||||||
if kodiversion in (16, 17):
|
if self.kodiversion in (16, 17):
|
||||||
# Kodi Jarvis, Krypton
|
# Kodi Jarvis, Krypton
|
||||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||||
kodicursor.execute(query, (album_artists, albumid))
|
kodicursor.execute(query, (album_artists, albumid))
|
||||||
elif kodiversion == 15:
|
elif self.kodiversion == 15:
|
||||||
# Kodi Isengard
|
# Kodi Isengard
|
||||||
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
|
||||||
kodicursor.execute(query, (album_artists, albumid))
|
kodicursor.execute(query, (album_artists, albumid))
|
||||||
|
@ -2391,10 +2375,9 @@ class Music(Items):
|
||||||
self.removeSong(kodiid)
|
self.removeSong(kodiid)
|
||||||
# This should only address single song scenario, where server doesn't actually
|
# This should only address single song scenario, where server doesn't actually
|
||||||
# create an album for the song.
|
# create an album for the song.
|
||||||
customitems = emby_db.getItem_byWildId(itemid)
|
|
||||||
emby_db.removeWildItem(itemid)
|
emby_db.removeWildItem(itemid)
|
||||||
|
|
||||||
for item in customitems:
|
for item in emby_db.getItem_byWildId(itemid):
|
||||||
|
|
||||||
item_kid = item[0]
|
item_kid = item[0]
|
||||||
item_mediatype = item[1]
|
item_mediatype = item[1]
|
||||||
|
@ -2448,23 +2431,16 @@ class Music(Items):
|
||||||
def removeSong(self, kodiid):
|
def removeSong(self, kodiid):
|
||||||
|
|
||||||
kodicursor = self.kodicursor
|
kodicursor = self.kodicursor
|
||||||
artwork = self.artwork
|
|
||||||
|
|
||||||
artwork.deleteArtwork(kodiid, "song", kodicursor)
|
self.artwork.deleteArtwork(kodiid, "song", self.kodicursor)
|
||||||
kodicursor.execute("DELETE FROM song WHERE idSong = ?", (kodiid,))
|
self.kodicursor.execute("DELETE FROM song WHERE idSong = ?", (kodiid,))
|
||||||
|
|
||||||
def removeAlbum(self, kodiid):
|
def removeAlbum(self, kodiid):
|
||||||
|
|
||||||
kodicursor = self.kodicursor
|
self.artwork.deleteArtwork(kodiid, "album", self.kodicursor)
|
||||||
artwork = self.artwork
|
self.kodicursor.execute("DELETE FROM album WHERE idAlbum = ?", (kodiid,))
|
||||||
|
|
||||||
artwork.deleteArtwork(kodiid, "album", kodicursor)
|
|
||||||
kodicursor.execute("DELETE FROM album WHERE idAlbum = ?", (kodiid,))
|
|
||||||
|
|
||||||
def removeArtist(self, kodiid):
|
def removeArtist(self, kodiid):
|
||||||
|
|
||||||
kodicursor = self.kodicursor
|
self.artwork.deleteArtwork(kodiid, "artist", self.kodicursor)
|
||||||
artwork = self.artwork
|
self.kodicursor.execute("DELETE FROM artist WHERE idArtist = ?", (kodiid,))
|
||||||
|
|
||||||
artwork.deleteArtwork(kodiid, "artist", kodicursor)
|
|
||||||
kodicursor.execute("DELETE FROM artist WHERE idArtist = ?", (kodiid,))
|
|
||||||
|
|
Loading…
Reference in a new issue