Project: Scan CD Barcode & Play in Spotify – Part Two

Read up on Part One before continuing on – otherwise this post makes no sense.  Why are you reading it out of order?


Day Four – Things Are Working

You’ll remember at the end of Day Three I was getting frustrated with how things were working out, and that I might need to head to a different direction.  In fact, in the intervening days between pausing the project, moving to a new house, and continuing today (Tuesday), I even came across ANOTHER option that might even take all the hard work away from me:

Lifehacker: Stream a Vinyl Album By Snapping a Pic of Its Cover Art With This App

I think this project sounds awesome and is probably a better implementation of what I want to do, but at this point it’s merely a back-up option that I’m going to hold onto.

So I know for sure that using the “auto input” option (described in Day Three) definitely works – but to me that’s very clunky and goes against the entire point of what I’m trying to do with this project.  I did some extra digging and found a barcode for Maroon 5’s Red Pill Blues album (Best Buy is very handy with listing EAN barcode numbers, it turns out).

I went back to AutoSpotify and figured out how to get it to search and return results properly.  I fiddled around briefly with broadcasting intents, and they worked to some extent – but not the way I wanted.

In the end I realized there was a “play media” function with AutoSpotify that I wasn’t leveraging before.  I was able to play the album directly from the URL (obtained from the AutoSpotify Search).

Just to drive the point home, I want to say again – it worked.  I took the barcode from the album (Red Pill Blues), searched the EAN database for the name, plugged the name into a search of Spotify’s database, and then automatically played the album.

I haven’t tested it fully with the barcode scan – that’s next.  But just a quick summary again of the apps I needed to make this work:

  • Tasker
  • AutoTools (JSON Read)
  • AutoSpotify (Search & Play Media)
  • Also need an EAN Database API login (free version)

Full barcode test is next.


Day Five – Putting It All Together (Again)

Finally, it all came together!  I grabbed some CDs from my collection.  Only one of them worked – The Sheepdogs’ Learn & Burn.  That’s okay – I fully expect some of these scans not to return any information (or the correct information).

The ultimate point is that I was able to scan a barcode, look up the album name in Spotify, and play it automatically.  It took me a while to get there, but I’ve got it all set now.

I think the next step will be to add some checks – for example, if it can’t find product information, tell me so that I can decide to try to look it up via image search (the one I mentioned from Day Four).  That type of thing.  Make it a little smarter.

Anyway, if you want a copy of the task (assuming you have Android, and all of the required apps / plugins), let me know and I’ll make it available after I clean it up.

Project Time: Scan CD Barcode & Play in Spotify

It’s been a long time since I’ve started a fun tech project.  I’m not too hands-on when it comes to the hardware, but I like dabbling in the software side of things.  Without further ado, here’s what I’m trying to accomplish, in a nutshell:

Using my phone (or a tablet, that works too), scan a CD barcode and play it in Spotify (or whatever music app I happen to be subscribed to at the time).

This post is being written as I walk through the project.  There are quite a few pieces involved in getting it to work, and I’m piecing it together one at a time.


Day One – Gathering Materials & Initial Tests

This is where I figure out what it is that I need to make this thing work.  As far as I can tell, this is what I’ll need:

The first test I came up with was to figure out how to trigger everything in the first place.  I found this handy Reddit post that used a different method to scan barcodes as a starting off point.  To save you a click though, I’m triggering the task by launching when the Barcode Scanner app is open AND the clipboard is set (that’s how the app works – it copies the barcode to the clipboard).

In the task itself, I want to look up the barcode information.  Apparently you can do this using EAN, which stands for International Article Number (it was originally European, hence the “E”).  Autoweb has a web service to look up product info from the EAN database, which is perfect! So in Tasker, I am sending the barcode (which is stored in the clipboard at this point) to the EAN database, which returns a bunch of different results from product name, description, category, etc.  Well, as long as all that information is in the database, that is.

Grand & Toy Highlighter
Grand & Toy Highlighter

I tested it with the closest object I could find with a barcode – a Grand & Toy highlighter (pictured).  Unfortunately that test didn’t give me any meaningful results, so I had to test something else.  I tried a bag of chips (it was free – technically expired, from the vending machine) and still, nothing came up.  I seem to be doing something wrong.  I think the rest of Day One will be spent trying to figure this out.

So I figured it out with a different method.  I couldn’t figure out how to use the Autoweb API action, so I decided to just eliminate that variable and use an Autotools JSON Read (you can view a tutorial here).  In conjunction with the JSON Editor Online (link), I figured out how to get Tasker to display the information I needed.  After some fiddling, success!  “Roundedge Yellow Highlighter” (incidentally the EAN entry for Grand & Toy has the company name entered as “Grand & Tory”).

Now that I’ve got this basic, most important part of the process figured out, I can now start scanning CDs to see what information comes up in the JSON file and look up via Spotify.

I’m having mixed results – my personal CD collection is packed away right now, so I’m using my parents’ collection to test.  I got a positive match for “Crazy for Gershwin”, but looking up the barcode for Gordon Lightfoot’s Gord’s Gold gave me the following product description:

Lorcos Cinnamon Orange Christmas Cat In A Boot Single Soap Bar 10.5 Oz. From France

So…this might not be the smoothest exercise, but it DOES work.  Sort of.  I count this as a success.


Day Two – Connecting with Spotify

Connecting to Spotify has been somewhat problematic.  While I’ve been able to read barcodes and get the album name, searching the Spotify database hasn’t been so easy.  I used the Tasker plugin AutoSpotify to run a search.  I think I’m just not clear on how the plugin works because no information would return to me.  None of my attempts to get the Spotify API in Autoweb to work either.

So that’s frustrating.  To top it off, randomly my “HTTP GET” action (the function that is reading the EAN database) is failing.

All said, things are not going as smoothly as I would like.


Day Three – Changing things up

I was getting frustrated on day two trying to get the Spotify automation to work.  So I decided to change things up and go back to methods I know have worked for me in the past.  Enter AutoInput; it’s another plugin that simulates and automates user input.

I created a test task with a pre-set search string.  It opens Spotify, clicks on the search icon, pastes the search string, and clicks on the top result.  For the two tests that I ran, I used “our lady peace clumsy” and “oasis what’s the story morning glory”.  In both cases the top result was the correct album.  So this part of the puzzle works fine.  The next step was to put the barcode read and the automated search function and put them together.

I’m not having very much luck.  I think the problem is that I’m sorely lacking in CDs to test with; I did one test at Wal-Mart, but came up with nothing.  I think if I had the CD in hand I might be able to see if it returned actual artist / album information as opposed to what I’ve been looking at (an amalgamation of the two on a greatest hits album – reportedly, greatest hits albums aren’t reliable for EAN scans).

Leaning more toward the much more manual intensive process of printing QR codes for each album. I’d rather not put that much work into it, however.


To Be Continued…

I’m going to put this project on hold for now.  The bones are there, I just don’t have the time or the materials present to continue testing.  There will definitely be a follow-up to this entry though!

#myAndroid

Over the weekend I caught wind of a neat little toy released on Android.com called “My Android” (colloquially, #myAndroid).  The basic idea behind it is to show you how many different ways you can customize your Android set-up beyond the stock screen that you get when you first turn on your Android phone.

How does it work?

Once you head over to the #myAndroid website, and click on the ‘Find Your Match’ button, you’re guided through a series of (mostly) binary tests.  They want you to react, not to think, as you make your selections.

Some of the options are obvious, but there’s a test near the end that asks “Hot dogs or legs?” that is pretty funny, but I’m not sure what results are derived from it.

What does your match give you?

After you complete the little quiz, you’re shown three home screen options that are tailored to your tastes based on your selections.  A quick animation gives you an overview of what your home screen might look like.

Scroll down a bit further and it gives you some more details about each home screen: the launcher (this is the “skin” or “theme” layered on top of Android – more info here), icon pack, wallpaper, and keyboard (more on that in a second).  Along with each item there’s a direct Play Store link so you can download them.

Problems with the process

I mentioned that I’d get to the keyboard suggestion; that’s where there’s at least one problem with the whole process.  Every time you complete the test to find your match, every keyboard recommended is Gboard.  I’m not saying that Gboard is a bad keyboard (it’s the one I use, in fact), but it seems a bit disingenuous that no matter what, the #myAndroid website will suggest it every time without fail.  There are a lot of different keyboards out there, and different styles will suit some more than others; this test should just leave the keyboard match out completely.

The wallpaper suggestion leaves a little to be desired too.  It will give you one of two options: Backdrops or Zedge.  It will show you the suggestion based on your test selections, but won’t give you the name of it or what to search for in order to find it in the selected app.

Lastly, I’d also love to be able to sample some of the launchers in a virtual environment before trying them.  They give you a very brief animation but to me that’s not enough.

Overall impressions

This is a great tool, for both new and experienced Android users alike.  I’ve even seen mention on the Android subreddit from iPhone users that this has helped convince them to switch.

I’ve found two new launchers – Evie and Smart Launcher 3.  I’ve used Nova Launcher for almost the entire time I’ve used Android, but thought I’d try something new based on the suggestions given here.

I use Evie on my Galaxy S7 edge, and Smart Launcher on my Galaxy Tab S2.  Both have their advantages/disadvantages, and so far I feel that Smart Launcher works better on my tablet and I wouldn’t really like it on my phone.  Similarly with Evie, I find that it works great on my phone but isn’t something I’d use on my tablet.

Even if you just want to shake things up a little, I recommend taking the #myAndroid test to find your match.

On a side note – I finally have a set publishing schedule!  Enjoy new posts from me every Tuesday and Thursday from here on out.