Well, my Meditation 1.1 is currently on view at the Newark Museum of Art, which means it's time for something to break. It seems like every time this piece is exhibited, something on the back end that's out of my control crashes and renders my QR code inoperable!
To catch you up to speed, the mandala drawing in question features a hand drawn QR code, which, when scanned, sends the viewer to a randomized website, different every time it is scanned. The way I accomplished this evolved over time, but essentially the QR code contains a short link to a .php web scraper I built, which gleans a random website from a massive database and then redirects the user to it.
In 2014... the QR code generator I used was bought out and dissolved, rendering its proprietary short links deprecated. That led me to coding my own link shortener to take matters into my own hands, and hand-redrawing every QR code I had worked into a mandala to that date.
In 2015... the random website generator I had been using at randomwebsite.com shut down, causing me to rewrite my web scraper for a more stable directory called DMOZ (a 20 year long endeavor to catalog the every reputable site on the internet, relied upon by search engines such as Google and Yahoo and others, which at its peak indexed over 4 million websites!).
In 2017... DMOZ.org went down and had to be replaced with a 3rd party workaround, DMOZtools.net. This was inconvenient, but structurally identical, so it was just a matter of swapping a couple urls.
By March 2023... (right before I submitted the piece for acceptance into its current show) DMOZtools went down, and had to be replaced with an archived version hosted by someone else at DMOZ-odp.org. Thankfully also structurally identical, so this required only minor modifications to my code.
On September 28th 2023... (literally the day after the show opened), the ODP (Oracle Data Provider) database went underwater and all ODP dependent sites went down, including the DMOZ-odp archive I was using.
With just a week left in the show, I've been scrambling to find another way to scrape a random site to redirect to. That's when I had the stroke of brilliance to turn not to any current iteration of DMOZ, but to the Wayback Machine's archive of DMOZ right before it shut down! However, though it looks structurally identical to the original, the source code is very much not identical.
That meant rewriting all the code and regex expressions in my scraper, practically from scratch, to weed out all the wayback machine content and cut straight to the DMOZ archive content. This would be hard enough if it didn't mean reworking code I had written over a decade ago and now was more than a bit rusty on interpreting. The trick here was in discovering that there was a 14 digit number in the url that changed with every link followed, so I had to account for this in the regex, and that the DMOZ urls were essentially appended to the archive urls.
After about a week of debugging and re-coding, I finally managed to put together regular expressions that would encapsulate all the appropriate links without including the ones I didn't want, while also isolating the now scrambled bits of the code that would point to a possible external link as a final destination.
It was a little like finding a needle in a haystack. ...In fact that's exactly what coders call it too, as I sifted through all the junk to find the relevant portions of code!
Of course, given that the last functioning archive of DMOZ was 6 years ago, many of the external destination links are, themselves, no longer in existence. So even with a successful gleaning of an external link, it still has a decent chance to end in a 404 error. With more time I can probably find a way to capture and redirect to their archived counterparts, but the code gets so mangled that the regex I'm using is having a hard enough time finding the proverbial needles as it is.
So, as a stop-gap solution, I actually consulted ChatGPT with a coding question for the first time.
When Google seemed to lead me down many dead ends, ChatGPT instantly gave me a functional template for checking for error messages when redirecting, and, if say a 404 error is thrown, re-redirect back to my original page to try again. I tweaked this to include other common error messages, and and then if none of that works, it at least now spits out an appropriately ironic text
And so, with just 2 days left in the show, my piece is once again fit for consumption! If you read this in the next 48 hours (before 10/29/23), go visit it at the Newark Museum in Newark, NJ!
No comments:
Post a Comment