Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String from XML?
#15
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 
 
Code:
Copy      Help
"http://127.0.0.1:8080/requests/playlist.json" 
It is found in a JSON Array with the current being next to a word current underneath it (e.g
 
Code:
Copy      Help
D:/Sandbox/Test%20Work/250529%20_SNA_MIA_SDQ_Workspace/Trip%20Full%20Pics/IMG_005408.mp4)
. like so:
 
Code:
Copy      Help
{
  "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":[]
    }]
}
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.
 
Code:
Copy      Help
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)
I don't know if I was on the correct track. Thanks for any help  Smile


Messages In This Thread
String from XML? - by pctechtv - 03-04-2022, 12:14 PM
RE: String from XML? - by Kevin - 03-04-2022, 04:33 PM
RE: String from XML? - by pctechtv - 03-06-2022, 05:51 AM
RE: String from XML? - by pctechtv - 03-06-2022, 09:34 AM
RE: String from XML? - by Kevin - 03-06-2022, 02:18 PM
RE: String from XML? - by pctechtv - 03-06-2022, 09:10 PM
RE: String from XML? - by Kevin - 03-09-2022, 02:57 PM
RE: String from XML? - by pctechtv - 03-12-2022, 02:41 PM
RE: String from XML? - by pctechtv - 05-23-2023, 04:29 AM
RE: String from XML? - by pctechtv - 05-23-2023, 12:51 PM
RE: String from XML? - by Kevin - 05-23-2023, 05:34 PM
RE: String from XML? - by pctechtv - 05-25-2023, 03:54 PM
RE: String from XML? - by Kevin - 05-27-2023, 12:08 PM
RE: String from XML? - by pctechtv - 06-07-2023, 04:22 PM
RE: String from XML? - by pctechtv - 06-10-2025, 12:36 AM
RE: String from XML? - by Gintaras - 06-10-2025, 07:32 AM
RE: String from XML? - by pctechtv - 06-10-2025, 07:20 PM
RE: String from XML? - by pctechtv - 06-11-2025, 02:30 AM
RE: String from XML? - by Kevin - 06-11-2025, 02:45 AM
RE: String from XML? - by pctechtv - 06-11-2025, 11:41 AM
RE: String from XML? - by Kevin - 06-11-2025, 12:09 PM
RE: String from XML? - by Kevin - 06-11-2025, 04:23 PM
RE: String from XML? - by pctechtv - 06-11-2025, 04:50 PM
RE: String from XML? - by pctechtv - 06-12-2025, 08:33 PM
RE: String from XML? - by Kevin - 06-17-2025, 02:53 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)