Seven days into a new year and nary a SPLOT related blog post… what’s going on around here?

Thar be rabbit holing in the code warren. I’ve still got a big surprise to add to SPLOTbox, which now has maybe all the features of three SPLOTs in one. This little bit blogged here is just a bit of cleanup, refinement, and a bit of fun API discovery. And wandering down and back from a path of malfunction.

It was an idea from Daniel Villar-Onrubia maybe a year or more ago to enable the SPLOTbox to support adding video from the Internet Archive. I noticed on a site he crafted that it also supported audio content.

The thing was, the audio player is thin, but the way I had it displayed, it took up all the space allowed for the video player.

Comparison of en emdedded video (left) and audio (right) from Internet Archive, with a large amount of wasted space because they are sized the same. It does not matter to you if you cannot see it, but...

So the thing to figure out is, from these kinds of URLs, how can you determine if it points to content that is video vs audio?

  • https://archive.org/details/audreywattersdoooworkshop
  • https://archive.org/details/Jolly_Fish_1932

I pondered it, and guessed that maybe there is an Internet Archive API I could call to find this info. The answer is yes, one can get metadata about any archive item.

You have to extract the item ID, which is the part of the URL after details/. At first I did this by simple php locating this in the URL (str_pos function) and then getting a substring to get all the characters after. Later I found this did not work with some video URLs that have extra start/end values in the URL.

Thus it is easier to take the URL as a string, use the PHP explode function to split it into arrays based on the “/” character, and the ID will always be the fourth item.

I did this by just testing a basic test script locally.

And sure enough, the test returns Jolly_Fish_1932.

I can then try out this call on either of my URLs by using this API to get just the metadata

And this is thus available via the mediatype: value (noting that Internet Archive video is sometimes mediatyped as “video” other times “movies” while I found results for audio as mediatyped “audio” or “etree”)

JSON data for results of first link, showing media:audio as the data we seek
Results for https://archive.org/metadata/audreywattersdoooworkshop/metadata
API results for the second URL as mediatype:movies
Results for https://archive.org/metadata/Jolly_Fish_1932/metadata

Without going to the bottom of the coding hole, this is my function that makes an API call for a given Internet Archive URL, and returns the resulting media type.

All of this leads to when it’s time to display the item, if it is an audio media type, it embeds via a shorter iframe size (the variable videoplayer is a leftover from when all this did ws video, but who cares?

Look at the difference!

The same paired video and audio embeds, but now there is no blank space on the audio content.
No more dead space for embedded Internet Archive audio content. Woah, Neo.

Once an item is published, the mediatype is stored as a custom post type, so we don’t have to make an API call on every load.

Okay, I then got carried a way. I noted there were equivalent embed codes for all content in the Internet Archive, and I imagined a SPLOTbox could handle text, software, all the goodies on the site. I even built out a prototype SPLOTbox as a premise that you could build a site where the only content it collected was from the Internet Archive.

OOPS. I discovered the embeds did not all display, many of them for books, texts, etc showed up blank. I did not wander farther down the road to sort out how these embeds were done, I decide to fold the tent back, and keep support limited to audio and video content, the stuff that embeds.

Wow.

I wonder if anyone would have ever noticed. But this did bother me enough to see if I could sort out this small issue. Better yet, I got better at running API calls behind the scene in WordPress (this is a huge door opener into WordPress, and as have already done, out of WordPress – which I still think is one of the biggest things I’ve code in a while. No one else seems to notice.) .

I’ve already rigged up a version of SPLOTbox that can be used to support group authored podcasts. Amazing? I thought that was insanely useful.

And this most recently updated version even has a nifty admin menu that opens the customizer to the view of the sharing form, where you can change all of the form section labels and instructions. How many themes can you do THAT on?

But Wait

Philippe Bruhat's "BUT WAIT, THERE'S MORE" slide prepared
Philippe Bruhat’s “BUT WAIT, THERE’S MORE” slide prepared flickr photo by kawanet shared under a Creative Commons (BY) license

There is something I have partly working as prototype as a new way to add media to SPLOTbox (and maybe a possible stand alone plugin) that should knock your socks off.

Until then, give the most current version of SPLOTbox a run at http://splot.ca/box or download and try it on your own domain from https://github.com/cogdog/splotbox. I am hoping soon we can get this added to Reclaim Hosting’s featured apps as a one click install.

Forget innovating in or out of boxes- build some media in your own SPLOTbox.


Feature Image: Modified a Wikimedia Commons image File:Geiger counter usage.jpg shared into the public domain as a work of a US Government agency. Changes included adding URLs and an Internet Archive logo to the cans being examined.

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Comments

  1. This is great! I feel I’ve been very remiss with my promises to test all the SPLOT goodness that you’ve been cranking out. Just as soon as I get my self settled (and get home internet!) I’ll get on it!

Leave a Reply

Your email address will not be published. Required fields are marked *