the point is, ure asking how to compose a song, when u dont yet know how to pluck the strings(no pun intended lol). a musician's gotta practice
many ways to skin a cat. heres one using regex, good luck
Code: Select all
JSONString = {"id":16612,"slug":"twelve-minutes","name":"Twelve Minutes","screenshots":[{"title":"Screenshot","image_width":1024,"image_height":506,"id":19839,"cloudinary_id":"kywt4dprxyi4x7iqhkya"},{"title":"Screenshot","image_width":1024,"image_height":671,"id":19840,"cloudinary_id":"zkdha2uodde4ozf1w856"},{"title":"Screenshot","image_width":1024,"image_height":505,"id":19841,"cloudinary_id":"lqy0ejak38kvizvsm1gi"},{"title":"Screenshot","image_width":1024,"image_height":640,"id":19842,"cloudinary_id":"k3dqr9gk6bn0aqfap9ns"},{"title":"Screenshot","image_width":3840,"image_height":2160,"id":322754,"cloudinary_id":"sc6x1e"},{"title":"Screenshot","image_width":3840,"image_height":2160,"id":322755,"cloudinary_id":"sc6x1f"},{"title":"Screenshot","image_width":3840,"image_height":2160,"id":322752,"cloudinary_id":"sc6x1c"},{"title":"Screenshot","image_width":3840,"image_height":2160,"id":322753,"cloudinary_id":"sc6x1d"},{"title":"Screenshot","image_width":3840,"image_height":2160,"id":322751,"cloudinary_id":"sc6x1b"},{"title":"Screenshot","image_width":3840,"image_height":2160,"id":322750,"cloudinary_id":"sc6x1a"},{"title":"Screenshot","image_width":3840,"image_height":2160,"id":322749,"cloudinary_id":"sc6x19"}],"artwork":null,"cover":{"image_width":680,"image_height":907,"id":74971,"cloudinary_id":"co1luj"},"status":null,"release_date":"Aug 19, 2021","release_date_time_ago":1629331200000,"edit_url":"/games/twelve-minutes/edit","genres":[{"to_param":"adventure","name":"Adventure"},{"to_param":"indie","name":"Indie"},{"to_param":"point-and-click","name":"Point-and-click"},{"to_param":"puzzle","name":"Puzzle"}],"external_reviews":0.0,"external_reviews_count":1,"rating":null,"ratings_count":0,"summary":"\u003cp\u003eA romantic evening with your wife turns into a violent invasion, as a man breaks into your home, accuses your wife of murder and beats you to death. Only for you to wake up and find yourself stuck in a twelve-minute time loop, doomed to relive the same terror again and again.\u003c/p\u003e","websites":[{"url":"https://www.youtube.com/channel/UCoztP3NSW03Kd69KjQEIxeg","site":9},{"url":"https://twitter.com/12minutesgame","site":5},{"url":"http://twelveminutesgame.com/","site":1},{"url":"https://www.facebook.com/twelveminutesgame","site":4},{"url":"https://store.steampowered.com/app/1097200","site":13}],"website_links":[{"id":13,"slug":"steam","type":"store","name":"Steam","domains":["steampowered.com"],"icon":"fab fa-steam","svg":"steam"},{"id":17,"slug":"gog","type":"store","name":"GOG","domains":["gog.com"],"svg":"gog"},{"id":16,"slug":"epic","type":"store","name":"Epic","domains":["epicgames.com"],"svg":"epic"},{"id":12,"slug":"android","type":"store","name":"Google Play","domains":["google.com"],"svg":"play-store"},{"id":10,"slug":"iphone","type":"store","name":"App Store (iPhone)","domains":["apple.com"],"icon":"fab fa-apple","svg":"ios-iphone"},{"id":11,"slug":"ipad","type":"store","name":"App Store (iPad)","domains":["apple.com"],"icon":"fab fa-apple","svg":"ios-ipad"},{"id":15,"slug":"itch","type":"store","name":"Itch","domains":["itch.io"],"svg":"itch"},{"id":1,"slug":"official","type":"social","name":"Official Website","icon":"fa fa-external-link-alt","svg":"official-site"},{"id":6,"slug":"twitch","type":"social","name":"Twitch","domains":["twitch.tv"],"svg":"twitch"},{"id":9,"slug":"youtube","type":"social","name":"YouTube","domains":["youtube.com","youtu.be"],"prefix":"/user/","svg":"youtube"},{"id":4,"slug":"facebook","type":"social","name":"Facebook","domains":["facebook.com"],"svg":"facebook"},{"id":5,"slug":"twitter","type":"social","name":"Twitter","domains":["twitter.com"],"svg":"twitter"},{"id":8,"slug":"instagram","type":"social","name":"Instagram","domains":["instagram.com"],"svg":"instagram"},{"id":18,"slug":"discord","type":"social","name":"Discord","domains":["discord.gg","discordapp.com"],"svg":"discord"},{"id":14,"slug":"reddit","type":"social","name":"Subreddit","domains":["reddit.com"],"svg":"reddit"},{"id":2,"slug":"wikia","type":"social","name":"Wikia","icon":"far fa-file-alt","svg":"wikia"},{"id":3,"slug":"wikipedia","type":"social","name":"Wikipedia","domains":["wikipedia.org"],"icon":"fab fa-wikipedia-w","svg":"wikipedia"}],"videos":[{"title":"Release Date Trailer","url":"G6I2rP3-B9k","thumb":["//img.youtube.com/vi/G6I2rP3-B9k/0.jpg","//img.youtube.com/vi/G6I2rP3-B9k/1.jpg","//img.youtube.com/vi/G6I2rP3-B9k/2.jpg","//img.youtube.com/vi/G6I2rP3-B9k/3.jpg"],"id":50896},{"title":"Gameplay Trailer","url":"1siS7ilp8gE","thumb":["//img.youtube.com/vi/1siS7ilp8gE/0.jpg","//img.youtube.com/vi/1siS7ilp8gE/1.jpg","//img.youtube.com/vi/1siS7ilp8gE/2.jpg","//img.youtube.com/vi/1siS7ilp8gE/3.jpg"],"id":50690},{"title":"Announcement Trailer","url":"qQ2vsnapBhU","thumb":["//img.youtube.com/vi/qQ2vsnapBhU/0.jpg","//img.youtube.com/vi/qQ2vsnapBhU/1.jpg","//img.youtube.com/vi/qQ2vsnapBhU/2.jpg","//img.youtube.com/vi/qQ2vsnapBhU/3.jpg"],"id":38842},{"title":"Gamescom 2020 Cast Reveal Trailer","url":"E6CmZN9TYdI","thumb":["//img.youtube.com/vi/E6CmZN9TYdI/0.jpg","//img.youtube.com/vi/E6CmZN9TYdI/1.jpg","//img.youtube.com/vi/E6CmZN9TYdI/2.jpg","//img.youtube.com/vi/E6CmZN9TYdI/3.jpg"],"id":40096}],"developers":[["Luis Antonio","/companies/luis-antonio"]],"can_rate":false,"rating_path":"/games/16612/rates","rating_delete_url":"/games/16612/rates/delete_rating","new_list_path":"/users/list/new?game_id=16612","hype_path":"/games/16612/hypes","hypes_count":4,"changes_path":"/games/twelve-minutes/changes","loader_path":"/assets/ajax-loading-response-86bb92c6295652dc51afc6ce33b0074683688bc10f44287f5622e650823f92b9.gif","short_url":"https://www.igdb.com/g/ctg","category":0,"extension":null,"platforms":[["Xbox One","xboxone",49],["PC (Microsoft Windows)","win",6],["Xbox Series","series-x",169]],"versions_count":0,"versions_slug":"twelve-minutes"}
; are there videos at all? if so, where, at which character?
if (pos := RegExMatch(JSONString, """videos"":\[\{"))
; matches the literal string "videos":[{ note the need for both AHK and PCRE character escaping
{
; AHK's RegExMatch can only match ONCE, then it stops. because of that we need to use a loop
while pos := RegExMatch(JSONString, """title"":""(?P<Title>.*?)"",""url"":""(?P<URL>[^""]+)""", Match, pos)
; matches the pattern "title":"whatever-the-title-is","url":"whatever-the-url-is"
; u aint learning the whole of regex from a comment, so why bother explaining...
{
MsgBox % "overall match: " Match "`ntitle: " MatchTitle "`nURL: " MatchURL
; advance forward as many chars as there are in whatever had been matched
; to skip past it and continue searching for more strings
pos += StrLen(Match)
}
}