Merge pull request #5 from piotrsmolinski/master

Support for metadata display in file browser
This commit is contained in:
croneter 2016-04-25 17:01:50 +02:00
commit d50288ff8f

View file

@ -442,6 +442,17 @@ class Movies(Items):
'mode': "play" 'mode': "play"
} }
filename = "%s?%s" % (path, urllib.urlencode(params)) filename = "%s?%s" % (path, urllib.urlencode(params))
playurl = filename
# Even if the item is only updated, the file may have been moved or updated.
# In the worst case we get exactly the same values as we had before.
pathid = kodi_db.addPath(path)
fileid = kodi_db.addFile(filename, pathid)
# movie table:
# c22 - playurl
# c23 - pathid
# This information is used later by file browser.
# UPDATE THE MOVIE ##### # UPDATE THE MOVIE #####
if update_item: if update_item:
@ -453,12 +464,12 @@ class Movies(Items):
"UPDATE movie", "UPDATE movie",
"SET c00 = ?, c01 = ?, c02 = ?, c03 = ?, c04 = ?, c05 = ?, c06 = ?,", "SET c00 = ?, c01 = ?, c02 = ?, c03 = ?, c04 = ?, c05 = ?, c06 = ?,",
"c07 = ?, c09 = ?, c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?,", "c07 = ?, c09 = ?, c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?,",
"c16 = ?, c18 = ?, c19 = ?, c21 = ?", "c16 = ?, c18 = ?, c19 = ?, c21 = ?, c22 = ?, c23 = ?",
"WHERE idMovie = ?" "WHERE idMovie = ?"
)) ))
kodicursor.execute(query, (title, plot, shortplot, tagline, votecount, rating, writer, kodicursor.execute(query, (title, plot, shortplot, tagline, votecount, rating, writer,
year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio, trailer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio, trailer,
country, movieid)) country, playurl, pathid, movieid))
# Update the checksum in emby table # Update the checksum in emby table
emby_db.updateReference(itemid, checksum) emby_db.updateReference(itemid, checksum)
@ -466,25 +477,20 @@ class Movies(Items):
##### OR ADD THE MOVIE ##### ##### OR ADD THE MOVIE #####
else: else:
self.logMsg("ADD movie itemid: %s - Title: %s" % (itemid, title), 1) self.logMsg("ADD movie itemid: %s - Title: %s" % (itemid, title), 1)
# Add path
pathid = kodi_db.addPath(path)
# Add the file
fileid = kodi_db.addFile(filename, pathid)
# Create the movie entry # Create the movie entry
query = ( query = (
''' '''
INSERT INTO movie( INSERT INTO movie(
idMovie, idFile, c00, c01, c02, c03, c04, c05, c06, c07, idMovie, idFile, c00, c01, c02, c03, c04, c05, c06, c07,
c09, c10, c11, c12, c14, c15, c16, c18, c19, c21) c09, c10, c11, c12, c14, c15, c16, c18, c19, c21, c22, c23)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''' '''
) )
kodicursor.execute(query, (movieid, fileid, title, plot, shortplot, tagline, votecount, kodicursor.execute(query, (movieid, fileid, title, plot, shortplot, tagline, votecount,
rating, writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, rating, writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title,
studio, trailer, country)) studio, trailer, country, playurl, pathid))
# Create the reference in emby table # 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)
@ -1343,9 +1349,20 @@ class TVShows(Items):
'mode': "play" 'mode': "play"
} }
filename = "%s?%s" % (path, urllib.urlencode(params)) filename = "%s?%s" % (path, urllib.urlencode(params))
playurl = filename
parentPathId = kodi_db.addPath( parentPathId = kodi_db.addPath(
'plugin://plugin.video.plexkodiconnect.tvshows/') 'plugin://plugin.video.plexkodiconnect.tvshows/')
# Even if the item is only updated, the file may have been moved or updated.
# In the worst case we get exactly the same values as we had before.
pathid = kodi_db.addPath(path)
fileid = kodi_db.addFile(filename, pathid)
# episodes table:
# c18 - playurl
# c19 - pathid
# This information is used later by file browser.
# UPDATE THE EPISODE ##### # UPDATE THE EPISODE #####
if update_item: if update_item:
self.logMsg("UPDATE episode itemid: %s" % (itemid), 1) self.logMsg("UPDATE episode itemid: %s" % (itemid), 1)
@ -1357,23 +1374,24 @@ class TVShows(Items):
"UPDATE episode", "UPDATE episode",
"SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?,", "SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?,",
"c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, idSeason = ?", "c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, c18 = ?, c19 = ?,",
"idSeason = ?",
"WHERE idEpisode = ?" "WHERE idEpisode = ?"
)) ))
kodicursor.execute(query, (title, plot, rating, writer, premieredate, kodicursor.execute(query, (title, plot, rating, writer, premieredate,
runtime, director, season, episode, title, airsBeforeSeason, runtime, director, season, episode, title, airsBeforeSeason,
airsBeforeEpisode, seasonid, episodeid)) airsBeforeEpisode, playurl, pathid, seasonid, episodeid))
else: else:
query = ' '.join(( query = ' '.join((
"UPDATE episode", "UPDATE episode",
"SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?,", "SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?,",
"c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?", "c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, c18 = ?, c19 = ?",
"WHERE idEpisode = ?" "WHERE idEpisode = ?"
)) ))
kodicursor.execute(query, (title, plot, rating, writer, premieredate, kodicursor.execute(query, (title, plot, rating, writer, premieredate,
runtime, director, season, episode, title, airsBeforeSeason, runtime, director, season, episode, title, airsBeforeSeason,
airsBeforeEpisode, episodeid)) airsBeforeEpisode, playurl, pathid, episodeid))
# Update the checksum in emby table # Update the checksum in emby table
emby_db.updateReference(itemid, checksum) emby_db.updateReference(itemid, checksum)
@ -1383,11 +1401,7 @@ class TVShows(Items):
##### OR ADD THE EPISODE ##### ##### OR ADD THE EPISODE #####
else: else:
self.logMsg("ADD episode itemid: %s" % (itemid), 1) self.logMsg("ADD episode itemid: %s" % (itemid), 1)
# Add path
pathid = kodi_db.addPath(path)
# Add the file
fileid = kodi_db.addFile(filename, pathid)
# Create the episode entry # Create the episode entry
if kodiversion in (16, 17): if kodiversion in (16, 17):
# Kodi Jarvis, Krypton # Kodi Jarvis, Krypton
@ -1395,27 +1409,27 @@ class TVShows(Items):
''' '''
INSERT INTO episode( INSERT INTO episode(
idEpisode, idFile, c00, c01, c03, c04, c05, c09, c10, c12, c13, c14, idEpisode, idFile, c00, c01, c03, c04, c05, c09, c10, c12, c13, c14,
idShow, c15, c16, idSeason) idShow, c15, c16, c18, c19, idSeason)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''' '''
) )
kodicursor.execute(query, (episodeid, fileid, title, plot, rating, writer, kodicursor.execute(query, (episodeid, fileid, title, plot, rating, writer,
premieredate, runtime, director, season, episode, title, showid, premieredate, runtime, director, season, episode, title, showid,
airsBeforeSeason, airsBeforeEpisode, seasonid)) airsBeforeSeason, airsBeforeEpisode, playurl, pathid, seasonid))
else: else:
query = ( query = (
''' '''
INSERT INTO episode( INSERT INTO episode(
idEpisode, idFile, c00, c01, c03, c04, c05, c09, c10, c12, c13, c14, idEpisode, idFile, c00, c01, c03, c04, c05, c09, c10, c12, c13, c14,
idShow, c15, c16) idShow, c15, c16, c18, c19)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''' '''
) )
kodicursor.execute(query, (episodeid, fileid, title, plot, rating, writer, kodicursor.execute(query, (episodeid, fileid, title, plot, rating, writer,
premieredate, runtime, director, season, episode, title, showid, premieredate, runtime, director, season, episode, title, showid,
airsBeforeSeason, airsBeforeEpisode)) airsBeforeSeason, airsBeforeEpisode, playurl, pathid))
# Create the reference in emby table # Create the reference in emby table
emby_db.addReference(itemid, episodeid, "Episode", "episode", fileid, pathid, emby_db.addReference(itemid, episodeid, "Episode", "episode", fileid, pathid,