How do I create a addon to play .strm files?
#1
Are there any GPL music addons that plays .strm files?

I am trying to figure out how to do a addon that shows files in a folder without the .strm extension, and when you click on the file, it plays the .strm file.

I am a newbie in python, but I have done freebasic programming.

I appreciate any help I can get.
Reply
#2
Have a read through this thread:

Your 2nd Add-On: Online Videos!

The example could probably be modified to work with local .strm files.
Kodi Krypton (17.6) on ThinkPad T400 Lubuntu 18.04 | Kodi Krypton (17.6) on HTPC Lubuntu 16.04 | My Add-ons | My Repo
Reply
#3
(2017-11-02, 02:57)Lasar3 Wrote: Are there any GPL music addons that plays .strm files?

I am trying to figure out how to do a addon that shows files in a folder without the .strm extension, and when you click on the file, it plays the .strm file.

I am a newbie in python, but I have done freebasic programming.

I appreciate any help I can get.


I'm at a loss understanding the need for a plugin to play a strm... extremely redundant  methodology.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Twitter
Reply
#4
You don't need an add-on to play a Strm (wiki) file do you? I thought it was native, you just point kodi at it or open it via the library or file mode.
| Banned add-ons (wiki) | Forum rules (wiki) | VPN policy (wiki) | First time user (wiki) | FAQs (wiki) | Troubleshooting (wiki) | Add-ons (wiki) | Free content (wiki) | Debug Log (wiki) | Free Movies/TV Shows |
Reply
#5
(2017-11-02, 11:00)DarrenHill Wrote: You don't need an add-on to play a Strm (wiki) file do you? I thought it was native, you just point kodi at it or open it via the library or file mode.

Correct. Kodi plays .strm files by default.

@Lasar3 if you already have the .strm files in a folder, can you not just scan them into your Kodi library?
Reply
#6
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.
Reply
#7
Im new to trying to make an addon to play youtube playlists / vids for kodi i need a template so i can edit and test it out cus im a nppb and want to learn without hassel as im easyly confused who can help?
Reply
#8
noob *
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
How do I create a addon to play .strm files?00