Skip to content
Snippets Groups Projects
Commit e65a57c8 authored by 42loop's avatar 42loop
Browse files

added file list request

parent efb443cd
No related branches found
No related tags found
No related merge requests found
......@@ -6,11 +6,35 @@ import json
import threading
import time
import socket
import glob
from lib import client as mqtt
__addon__ = xbmcaddon.Addon()
__version__ = __addon__.getAddonInfo('version')
def getmedia(dir):
all=glob.glob(dir+'*.mp4')
all.extend(glob.glob(dir+'*.mov'))
all.extend(glob.glob(dir+'*.m4v'))
all.extend(glob.glob(dir+'*.wav'))
all.extend(glob.glob(dir+'*.mp3'))
all.extend(glob.glob(dir+'*.mpg'))
all.extend(glob.glob(dir+'*.mpeg'))
all.extend(glob.glob(dir+'*.MP4'))
all.extend(glob.glob(dir+'*.MOV'))
all.extend(glob.glob(dir+'*.M4V'))
all.extend(glob.glob(dir+'*.WAV'))
all.extend(glob.glob(dir+'*.MP3'))
all.extend(glob.glob(dir+'*.MPG'))
all.extend(glob.glob(dir+'*.MPEG'))
all.sort()
# xbmc.log(str(all))
return all
def getSetting(setting):
return __addon__.getSetting(setting).strip()
......@@ -74,6 +98,18 @@ def publishstat(suffix,val,more):
mqc.publish(fulltopic,jsonstr,qos=0,retain=True)
def publishmedialist(suffix,val,more):
global topic,mqc
robj={}
robj["val"]=val
if more is not None:
robj.update(more)
jsonstr=json.dumps(robj)
fulltopic="media/"+topic+suffix
mqttlogging("MQTT: Publishing @"+fulltopic+": "+jsonstr)
mqc.publish(fulltopic,jsonstr,qos=0,retain=True)
#
# Set and publishes the playback state. Publishes more info if
# the state is "playing"
......@@ -249,6 +285,16 @@ def processvolume(data):
def processgetstatus():
publishstatus()
def processgetmedia():
mqttlogging("have getmedia")
result=getmedia("/home/osmc/video/")
res2=""
for entry in result:
mqttlogging(entry)
res2+=entry+","
publishmedialist("files",res2,None)
def processcommand(topic,data):
if topic=="notify":
......@@ -263,6 +309,8 @@ def processcommand(topic,data):
processgetstatus()
elif topic=="volume":
processvolume(data)
elif topic=="getmedia":
processgetmedia()
else:
mqttlogging("MQTT: Unknown command "+topic)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment