Talk:Snapshot API
From Second Life Wiki
Regex for matching the snapshot API
Eyo! Not sure if anyone would find this useful, but I needed to parse the snapshot api easily, so I wrote a regex, and sharing it here for anyone who may find it useful. Not important enough to go on the wiki page for it, so I put it here as "extra info". It is written in python but should be easy to grab and port over to stuff like perl, ruby, and php.
#!/usr/bin/env python3 import re #Composed from information on wiki.secondlife.com/wiki/Snapshot_API #Written by Chaser.Zaks / softhyena.com #Unlicensed/CC0, do what you wish with it. :3 http://unlicense.org/ #Using explicit \n instead of """stuff""" for sanity reasons rePostcardDetails = re.compile(r"<!-- BEGIN POSTCARD DETAILS\n" "agent_id=(?P<agent_id>[a-f0-9]{4}(?:[a-f0-9]{4}-){4}[a-f0-9]{12})\n" "username=\"(?P<username>[^\"]+)\"\n" "region_id=(?P<region_id>[a-f0-9]{4}(?:[a-f0-9]{4}-){4}[a-f0-9]{12})\n" "sim_name=\"(?P<sim_name>[^\"]+)\"\n" "global_x=(?P<global_x>[0-9]+)\n" "global_y=(?P<global_y>[0-9]+)\n" "local_x=(?P<local_x>[0-9.]+)\n" "local_y=(?P<local_y>[0-9.]+)\n" "local_z=(?P<local_z>[0-9.]+)\n" "END POSTCARD DETAILS -->", re.IGNORECASE) if __name__ == "__main__": test = rePostcardDetails.match("""<!-- BEGIN POSTCARD DETAILS agent_id=c4822e40-f763-4eec-bba3-e4bf842a074a username="Dedric Mauriac" region_id=714a15be-8511-4842-a8c1-38c1f54f3c58 sim_name="Applewood" global_x=260282 global_y=235143 local_x=186 local_y=135 local_z=56 END POSTCARD DETAILS -->""") print("This snapshot was taken by {} at {} ({}, {}, {})!".format( test.group("username"), test.group("sim_name"), test.group("local_x"), test.group("local_y"), test.group("local_z") ))
--Chaser Zaks (talk) 22:04, 20 March 2017 (PDT)