A staple of my music purchasing process is going onto Amazon and complaining about how their algorithm won’t suggest anything I want to listen to, and that Spotify is hardly better. This is equal parts exaggeration and truth: Spotify’s recommendations are usually good, Amazon’s are not great. Had I but world enough and time, I’d like to pull together a music search engine where you could cross-reference by not only artist or genre but also recording label or studio, instrumentation, composer, songwriter, possibly even tour roster.
However, this is a code camp project with a necessarily limited scope, I was working to outside-imposed objective rather than my own overly ambitious goals. The objective was this: write a CLI Ruby gem to interact with a user and deliver data scraped from a website or called via API (Application Programming Interface) based on the user’s specifications.
Even with a narrowed scope I started out trying somewhat more than I could do. I wrote up a CLI that greeted the user and asked for input based on a choice of music selectors, two of which (instrumentation and composer) were not, as it turned out, standard on Bandcamp album or artist sites. Alas. So my choices were down to search by artist or search by genre. At this point it probably could have been done by If-Else statements, but I’d started out with Case statements instead with the expectation that I’d have several criteria to present to a user to pick from, and I opted not to change that for no functional reason. Using Case statements would allow me to expand in the future if Bandcamp changed their formatting or if I decided to use other websites, or for other reasons was able to search by more criteria, so the Case statements stayed.
Bandcamp artist pages don’t necessarily have tags, but all of the album pages I visited did, so I prompted for an album and an artist. It may be expecting much of the user to have that information to hand these days, but if you’re sitting at a computer with CD in hand looking for similar music such a data gem could be helpful. With that information, reformated after input to provide the data gem with the correct Bandcamp URL to look for, the scrape could begin and present the user with a list of tags to choose from.
Alternatively, the user can opt to search by genre in a broader sense. Bandcamp also sorts their offerings into genres accessible via the search bar, and since their genres are a mixture of conventional music genres and newer, less conventional ones, I included a step between selecting a genre and receiving the list of artists where the user can view a definition of the genre they’re looking into. “Rock” music as a concept carries a definite expectation of a certain sound, “Ambient” or “Experimental” as labels are less clear.
In both branches of the decision tree the ultimate result is the same: a final scrape to pull artists from the Bandcamp landing page for that genre whether selected by broad category name or tag assigned to an album and present them to the user for further study. Future versions of the program might include choosing from the sub-genre tags or even scraping from a second site (Wikipedia, maybe) to find more information on that artist or band. Even further into the future I’d like to pull together a program that searches through YouTube Music, Amazon, Bandcamp, MySpace, Wikipedia, and other sites to present information to a user about an artist’s projects, a list of projects involving a specific instrument combination, a recording studio’s albums involving a specific sound mixer, or any equally arcane combination of factors. But for now, I’m satisfied with sorting through Bandcamp.