Hi, I now want to use this same way to get two pieces of data. The difference is that they are not coming from XML. The first is also the time (e.g ''time'':314 is the line. resulting in just 314) that can be acquired by the "http://127.0.0.1:8080/requests/status.xml" data. However, I figured since I am reaching into the difference is to JSON here, I might as well keep it all JSON. The other part is the full path of the playing file. Handled by the
It is found in a JSON Array with the current being next to a word current underneath it (e.g
. like so:
I was trying to configure and test. However I need help understanding how to work with JSON in here. I also was not having much luck with what I was trying with the regex function in QuickMacros. But i figured I could try a bit. But did not get to far.
I don't know if I was on the correct track. Thanks for any help
It is found in a JSON Array with the current being next to a word current underneath it (e.g
D:/Sandbox/Test%20Work/250529%20_SNA_MIA_SDQ_Workspace/Trip%20Full%20Pics/IMG_005408.mp4)
{
"ro":"rw",
"type":"node",
"name":"",
"id":"0",
"children":[{
"ro":"ro",
"type":"node",
"name":"Playlist",
"id":"1",
"children":[{
"ro":"rw",
"type":"leaf",
"name":"IMG_005404.mp4",
"id":"3",
"duration":38,
"uri":"file:///D:/Sandbox/Test%20Work/250529%20_SNA_MIA_SDQ_Workspace/Trip%20Full%20Pics/IMG_005404.mp4"
},{
"ro":"rw",
"type":"leaf",
"name":"IMG_005408.mp4",
"id":"4",
"duration":26,
"uri":"file:///D:/Sandbox/Test%20Work/250529%20_SNA_MIA_SDQ_Workspace/Trip%20Full%20Pics/IMG_005408.mp4",
"current":"current"
},{
"ro":"rw",
"type":"leaf",
"name":"IMG_005413.mp4",
"id":"5",
"duration":10,
"uri":"file:///D:/Sandbox/Test%20Work/250529%20_SNA_MIA_SDQ_Workspace/Trip%20Full%20Pics/IMG_005413.mp4"
}]
},{
"ro":"ro",
"type":"node",
"name":"Media Library",
"id":"2",
"children":[]
}]
}
str s1 l2
typelib WinHttp {662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1
;--- Create HTTP request
WinHttp.WinHttpRequest h._create
WinHttp.WinHttpRequest p._create
h.Open("GET" "http://127.0.0.1:8080/requests/status.json")
p.Open("GET" "http://127.0.0.1:8080/requests/playlist.json")
h.setRequestHeader("content-type", "application/json")
h.setRequestHeader("content-type", "application/json")
;--- Basic auth (username:password) - just ":password" if no username
str enc.encrypt(4 ":vlcremote")
h.SetRequestHeader("Authorization", F"Basic {enc}")
;--- Send request
h.Send()
err
out _error.description
ret
;--- If successful
if h.Status=200
str json = h.ResponseText
str vlcState vlcTime vlcVolume filename
;--- Parse "state"
str myTime = "''time'':"
vlcTime = json.replacerx("(''time'':)\d+" "" )
;--- Output to console
out vlcTime
out myTime
;--- Write to file
l2 = "C:\Temp\vlc.txt"
s1 = F"{vlcTime},{filename}"
s1.setfile(l2 -1 -1 1)
