added copying theme music - plus workaround for reported boxset issues

This commit is contained in:
im85288 2015-03-24 22:39:19 +00:00
parent 1ca1c55345
commit 851e65374b
2 changed files with 39 additions and 1 deletions

View File

@ -265,6 +265,37 @@ class CreateFiles():
return changes
def copyThemeMusic(self,item):
downloadUtils = DownloadUtils()
userid = downloadUtils.getUserId()
port = addon.getSetting('port')
host = addon.getSetting('ipaddress')
server = host + ":" + port
item_type=str(item.get("Type"))
if item_type == "Movie":
itemPath = os.path.join(movieLibrary,item["Id"])
themeFile = os.path.join(itemPath,"theme.mp3")
if item_type == "Series":
itemPath = os.path.join(tvLibrary,item["Id"])
themeFile = os.path.join(itemPath,"theme.mp3")
if not xbmcvfs.exists(themeFile):
utils.logMsg("MB3 Syncer","creating Theme file " + themeFile,2)
#theme music link
themeMusicUrl = "http://" + server + "/mediabrowser/Items/" + item["Id"] + "/ThemeSongs?format=json"
jsonData = downloadUtils.downloadUrl(themeMusicUrl, suppress=True, popup=0 )
if(jsonData != ""):
themeMusic = json.loads(jsonData)
if(themeMusic != None and themeMusic["TotalRecordCount"] > 0):
themeItems = themeMusic["Items"]
if themeItems[0] != None:
mediasources = themeItems[0]["MediaSources"]
if mediasources[0]["Container"] == "mp3":
themeUrl = PlayUtils().getPlayUrl(server,themeItems[0]["Id"],themeItems[0])
xbmcvfs.copy(themeUrl,themeFile)
def CleanName(self, name):
name = name.replace(":", "-")
name = name.replace("\\", "-")

View File

@ -683,6 +683,9 @@ class WriteKodiDB():
# create strm file
changes |= CreateFiles().createSTRM(item)
#add theme music
CreateFiles().copyThemeMusic(item)
if changes:
utils.logMsg("MB3 Sync","Added movie to Kodi Library",item["Id"] + " - " + item["Name"])
@ -768,6 +771,9 @@ class WriteKodiDB():
#create nfo file
changes = CreateFiles().createNFO(item)
#add theme music
CreateFiles().copyThemeMusic(item)
if changes:
utils.logMsg("Added TV Show to Kodi Library ",item["Id"] + " - " + item["Name"])
@ -972,4 +978,5 @@ class WriteKodiDB():
def updateBoxsetToKodiLibrary(self, boxsetmovie, boxset):
strSet = boxset["Name"]
kodiMovie = ReadKodiDB().getKodiMovie(boxsetmovie["Id"])
WriteKodiDB().updateProperty(kodiMovie,"set",strSet,"movie",True)
if kodiMovie != None:
WriteKodiDB().updateProperty(kodiMovie,"set",strSet,"movie",True)