added streamdetails

This commit is contained in:
Marcel van der Veldt 2015-05-02 02:57:58 +02:00
parent b4dd9f58bd
commit 42c7256f54
2 changed files with 23 additions and 4 deletions

View file

@ -99,8 +99,8 @@ class API():
for mediaStream in MediaStreams:
if(mediaStream.get("Type") == "Video"):
videocodec = mediaStream.get("Codec")
height = str(mediaStream.get("Height"))
width = str(mediaStream.get("Width"))
height = int(mediaStream.get("Height"))
width = int(mediaStream.get("Width"))
aspectratio = mediaStream.get("AspectRatio")
if aspectratio != None and len(aspectratio) >= 3:
try:
@ -116,7 +116,7 @@ class API():
'audiocodec' : audiocodec,
'height' : height,
'width' : width,
'aspectratio' : str(aspectfloat)
'aspectratio' : aspectfloat
}
def getChecksum(self, item):

View file

@ -157,6 +157,9 @@ class WriteKodiDB():
pathsql = "INSERT into emby(emby_id, kodi_id, media_type, checksum) values(?, ?, ?, ?)"
cursor.execute(pathsql, (MBitem["Id"], movieid, "movie", API().getChecksum(MBitem)))
#add streamdetails
self.AddStreamDetailsToMedia(API().getMediaStreams(MBitem), fileid, cursor)
#### UPDATE THE MOVIE #####
else:
pathsql="update movie SET c00 = ?, c01 = ?, c02 = ?, c05 = ?, c06 = ?, c07 = ?, c09 = ? c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?, c16 = ?, c18 = ?, c19 = ? WHERE idMovie = ?"
@ -502,6 +505,9 @@ class WriteKodiDB():
pathsql = "INSERT into emby(emby_id, kodi_id, media_type, checksum, parent_id) values(?, ?, ?, ?, ?)"
cursor.execute(pathsql, (MBitem["Id"], episodeid, "episode", API().getChecksum(MBitem), showid))
#add streamdetails
self.AddStreamDetailsToMedia(API().getMediaStreams(MBitem), fileid, cursor)
# UPDATE THE EPISODE IN KODI (for now, we just send in all data)
else:
pathsql = "UPDATE episode SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?, c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ? WHERE idEpisode = ?"
@ -851,6 +857,19 @@ class WriteKodiDB():
sql="INSERT OR REPLACE into taglinks(idTag, idMedia, media_type) values(?, ?, ?)"
cursor.execute(sql, (idTag, id, mediatype))
def AddStreamDetailsToMedia(self, streamdetails, fileid, cursor):
#first remove any existing entries
cursor.execute("delete FROM streamdetails WHERE idFile = ?", (fileid,))
if streamdetails:
#video details
sql="insert into streamdetails(idFile, iStreamType, strVideoCodec, fVideoAspect, iVideoWidth, iVideoHeight) values(?, ?, ?, ?, ?, ?)"
cursor.execute(sql, (fileid,0,streamdetails.get("videocodec"),streamdetails.get("aspectratio"),streamdetails.get("width"),streamdetails.get("height")))
#audio details
sql="insert into streamdetails(idFile, iStreamType, strAudioCodec, iAudioChannels) values(?, ?, ?, ?)"
cursor.execute(sql, (fileid,1,streamdetails.get("audiocodec"),streamdetails.get("channels")))
def addBoxsetToKodiLibrary(self, boxset, connection, cursor):
strSet = boxset["Name"]