Amazon Library Linky – search any Bibliocommons library while viewing Amazon product pages

You can install the Amazon Library Linky Chrome extension from the Chrome Store.

I ported the Amazon SPL Linky Greasemonkey script to Chrome and made it a proper Chrome Extension. This extension can search any Bibliocommons library, and has an options page where you can select which library you want to search. All of the participating Bibliocommons libraries are supported (about 50).

[Update:] You can see the source code here: Amazon Library Linky on Github.

If you try it out, will you let me know how it works for you?

The following Bibliocommons libraries are supported:

Austin Public Library
Barrie Public Library
Boston Public Library
Burlington Public Library
Brantford Public Library
Burnaby Public Library
Cooperative Computer Services
Chinook Arch Regional Library System
Christchurch City Libraries
CLEVNET Library Cooperation
Daniel Boone Regional Library
Edmonton Public Library
Fort Saskatchewan Public Library
Fraser Valley Regional Library
Greater Victoria Public Library
Halton Hills Public Library
Hamilton Public Library
Johnson County Library
Markham Public Library
Milton Public Library
Multnomah County Library
New Westminster Public Library
North Vancouver District Public Library
New York Public Library
Oceanside Public Library
Omaha Public Library
Oakville Public Library
Orangeville Public Library
Ottawa Public Library
Perth East Public Library
Pickering Public Library
Princeton Public Library
Red Deer Public Library
The Richmond Hill Public Library
Santa Clara County Library
Strathcona County Library
The Seattle Public Library
Shortgrass Library System
Salt Lake City Public Library System
Santa Monica Public Library
Stratford Public Library
St. Albert Public Library
St. Marys Public Library
Tulsa City-County Library
Vancouver Island Regional Library
New Brunswick Public Library Service
Vancouver Public Library
Whatcom County Library System
Whitby Public Library
Windsor Public Library
Woodstock Public Library
West Perth Public Library
Yarra Plenty Regional Library

Chrome Extension: Making Browser Action icon open options page

Here’s how to make it so clicking the Page Action icon of a Chrome extension opens the extension options page. This code will open a new options page if one is not open, or switch to it if it’s already option.

You will need the “tabs” permission in your manifest.json:

Put this code in your background.js file:

Finding the durations of MP4 files without downloading the entire file

I wanted to find the durations of a bunch of MP4 files located out on the net – durations for the introduction videos for the top Kickstarter projects.

But I wanted to do this quickly. Downloading all those MP4 files would take too long. A little bit of research revealed that MP4 files files set up for streaming have their metadata (or moov atom) at the beginning of the file.

Now I need a way to read just the metadata, without getting the entire file.

More research reveals that I can use curl and dd to get the first bytes of a file. For some reason ‘curl -r’ doesn’t work.

So now we’re ready to go.

I made a file that had one Kickstarter project URL per line. Here’s a couple of them:

This script will load the Kickstarter project page, and get the URL-encoded download link for the project’s introductory video, if there is one:

Now we need to URL-decode the URLs:

Now we get the durations from the video urls, you’ll need Python, pip, and virtualenvwrapper installed. We make a Python virtual environment, and install hsaudiotag module to decode the mp4 metadata:

This code uses curl and dd to download only the first 512-byte block of the MP4 file.

Now we analyze the durations using a simple R script, I am on a Mac so I need to use Homebrew to install R:

Output for the top 100 Kickstarter technology projects (by amount raised) – all numbers are in seconds:

The average duration of the top 100 Kickstarter videos is 203.3 seconds, or just about 3.38 minutes.

Thanks to:

Welcome to my Notes blog!

This blog is a place for things that are off-topic to my main blog, which is on Enlightened Society, Greatness, and Teams. I wanted somewhere to post articles on random things, like software or projects I am working on, recipes, and pictures of cats. :-)