I am trying to get the audio World English Bible to work with .strm files.
I tried using a music library, but it doesn't work for me.
For one "Chapter 1.strm" looks ugly.
For another, got folder.jpg to work, but it takes up too much disk space.
I especially couldn't get fanart.jpg to work, no matter what I do.
Could not get .nfo files to use a local folder.jpg.
Fanart.jpg does not work for me, no matter what I do: .nfo file, or not.
Here is my folder sturture
special://home/media/1. World English Bible -- New Testament/
special://home/media/1. World English Bible -- New Testament/1. Matthew/
special://home/media/1. World English Bible -- New Testament/1. Matthew/Chapter 1.strm
..ect
Here is what I have come up with so far.
It probably has bugs in it.
Code:
# World English Bible: New Testament
import sys
import xbmcgui
import xbmcplugin
import os
addon = Addon('plugin.video.creationtoday_org', sys.argv)
addon_id = 'plugin.audio.MD3-Audio'
fanart = xbmc.translatePath(os.path.join('special://home/addons/' + addon_id , 'fanart.jpg'))
icon = xbmc.translatePath(os.path.join('special://home/addons/' + addon_id, 'icon.png'))
play = addon.queries.get('play', None)
path = xbmc.translatePath('special://home/media/1. World English Bible -- New Testament')
os.chdir(path)
def subdir():
for name in os.listdir("."):
addDir(name,'',1,iconimage,"",isfolder=True)
def addDir(name,url,mode,iconimage,query,isfolder=True):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+urllib.quote_plus(mode)+"&name="+urllib.quote_plus(name)+"&query="+str(query)
ok=True
name = name.replace("\\", "")
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="music", infoLabels={ "Title": name } )
liz.setProperty('fanart_image', art('fanart'))
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isfolder)
return ok
def addchapters(name,url,iconimage):
for name in os.listdir("."):
name, ext = os.path.splitext(name)
if ext = ".strm":
url=read_from_file(name, silent=False)
ok=True
xbmcplugin.setContent(addon_handle, 'audio')
liz=xbmcgui.ListItem(name, iconImage="DefaultAudio.png", thumbnailImage=iconimage)
liz.setInfo( type="Audio", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz,isFolder=False)
return ok
def read_from_file(path, silent=False):
try:
f = open(path, 'r')
r = f.read()
f.close()
return str(r)
except:
if not silent:
print("Could not read from " + path)
return None
#def play(name,url,iconimage):
# addon_handle = int(sys.argv[1])
# xbmcplugin.setContent(addon_handle, 'audio')
# li=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage); liz.setInfo( type="audio", infoLabels={ "Title": name } )
# li.setProperty('fanart_image', fanart)
# xbmc.Player ().play(url, li, False)
#def PLAYSD(name,url,iconimage):
# ok=True
# liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage); liz.setInfo( type="Video", infoLabels={ "Title": name } )
# ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
# xbmc.Player().play(url, liz, False)
#def PLAYREGEX(name,url,iconimage):
# name = name.replace(' ','')
# import urlresolver
# stream_url=url
# liz = xbmcgui.ListItem(name,iconImage=icon, thumbnailImage=icon)
# liz.setPath(stream_url)
# xbmc.Player ().play(stream_url, liz, False)
def PLAY(name,url,iconimage):
addon_handle = int(sys.argv[1])
xbmcplugin.setContent(addon_handle, 'audio')
li = xbmcgui.ListItem('[COLOR green]PLAY[/COLOR] [COLOR yellow]%s[/COLOR]' %name, iconImage=iconimage, thumbnailImage=iconimage)
li.setProperty('fanart_image', fanart)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
xbmcplugin.endOfDirectory(addon_handle)
def get_params():
param=[]
try:
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
except:
pass
# print param
return param
params = get_params()
url = None
name = None
mode = None
query = None
# Populate url, name & mode vars, if not, take default "None"
try:
url=urllib.unquote_plus(params["url"])
except:
pass
try:
name=urllib.unquote_plus(params["name"])
except:
pass
try:
mode=urllib.unquote_plus(params["mode"])
except:
pass
try:
query=urllib.unquote_plus(params["query"])
except:
pass
print "Mode: " +str(mode)
print "URL: " +str(url)
print "Name: " +str(name)
print "Query: " +str(query)
if mode==None or url==None or len(url)<1:
print ""
subdir()
elif mode==1:
print ""+url
addchapters(name,url,icon)
elif mode==2:
print ""+url
play(name,url,icon)
#xbmc.Player().play(url)
xbmcplugin.endOfDirectory(addon_handle)
#dialog.ok("Debug", str (match))
I appreciate any help you can give me on this.