Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String from XML?
#20
Hello, and thanks for the replay. Thank you for all the help you have given with this post in general. If it is possible to get the full path via XML, I would love to see it. I was under the impression it was not. The XML version is still super useful. I use it for the original purpose, but all I can receive is the filename (no path) and the time. Now the need has emerged to get the full path. However, I was able to achieve exactly what I wanted and figured out some more very useful stuff about Quick Macros. This program is so great. However, please show me how to get the full file path from XML. Thank you again for all the great replies.
Code:
Copy      Help
str s1 l2 json1 json2
typelib WinHttp {662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1
WinHttp.WinHttpRequest h._create
WinHttp.WinHttpRequest i._create

// First Request
h.Open("GET" "http://127.0.0.1:8080/requests/playlist.json")
h.setRequestHeader("content-type", "application/json")

str enc.encrypt(4 ":vlcremote") ;;replace ":vlcremote" with your password, if no username
h.SetRequestHeader("Authorization", F"Basic {enc}")
h.Send()
err out _error.description; ret
if h.Status=200
    json1 = h.ResponseText

// Second Request
i.Open("GET" "http://127.0.0.1:8080/requests/status.json")
i.setRequestHeader("content-type", "application/json")
i.SetRequestHeader("Authorization", F"Basic {enc}")
i.Send()
err out _error.description; ret
if i.Status=200
    json2 = i.ResponseText

// Merge JSONs
s1 = F"{{''playlist'': {json1}, ''status'': {json2}}"

str pat1 rx1 sub1 pat2 rx2 sub2 rep1 rep2 rep3 finz
pat1 = "''time'':\d+"
rx1 = findrx(s1 pat1 0 1 sub1)
pat2 = "''uri''\s*:\s*''([^'']+)''[^}]*?''current''\s*:\s*''current''"
rx2 = findrx(s1 pat2 0 1 sub2)

out
out rx1
out sub1
out sub2

rep1 = "''time'':"
rep2 = "''uri'':''file:"
rep3 = "'',\n.+''current'':''current''"
out rep3
// excuse all the test code it just helps me understand better :)
out sub1.replacerx(rep1 "" 1|8)
out sub1
out sub2.replacerx(rep2 "" 1|8)
out sub2.replacerx(rep3 "" 1|8)
finz = F"{sub1},{sub2}"
out finz
l2 = "C:\Temp\vlc.txt"
finz.setfile(l2 -1 -1 1)
To be clear when I was saying I did not want to work with a external file. I mean I did not want to send my result to a *.JSON file and then try to read it and process it. I did not need specific JSON processing here like Gintaras suggests. I just need quick extraction of some text in this result. In the end when ready I produce the comma separated text result this achieves, and it is saved to an external file. It is working great!


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: 2 Guest(s)