Verse Lyrics Get it on Google Play

A simple Kotlin based Android application that helps users to fetch lyrics of songs played in Spotify automatically.

In a rush? Here's tl;dr
I developed a Kotlin-based Android app that fetches song lyrics automatically from Spotify. When Spotify launched in India, I found myself searching for lyrics frequently. I aimed to make the process more efficient by automating it.

The app works by utilizing the Android Media Notifications API to capture song names and artist names. It then queries Google programmatically for lyrics. The initial version included all logic in one file, and it successfully retrieved lyrics from Google search results.

The user interface featured a minimalist design. Additionally, I addressed annoying repeating ads on Spotify by creating a feature that detected and muted ads. The app gained attention after posting it on Reddit, boosting its reputation and downloads.

I continued to enhance the app based on user feedback, adding features like dark/light mode, auto-scrolling lyrics, font size options, and more. Despite my transition away from Android, the project remains a valuable addition to my resume with over 1000+ downloads and a 4.8-star rating on Play Store.

Why did I build this?

If you didn’t know, Spotify launched in India sometime in late February 2019. I wasn’t an avid music enjoyer like I am today so when I wanted songs, I sailed the high seas and downloaded a bunch of my favorites. It wasn’t all bad. No ads and no unexpected songs. But some people like my friend @kubic, who makes music, was using Spotify since long ago presumably using a VPN.

When it launched in India, I started using it on my phone for a few months and found myself googling the lyrics more often. It’s not big deal right? like, I’m barely spending a few seconds to type the song name and adding lyrics keyword so google returns the lyrics.


But you know...
Automate meme
Meme


How does it work?

Well, I just explained it. What are required for getting a song’s lyrics?

  • Song name
  • Artist name (optional but helps narrow down the search)
  • lyrics keyword

Remember, I’m doing this so I don’t have to type in the song name so we need to get the name of song that is played in spotify automatically with the least amount of effort.

Research

Now that we know what we want, have to find ways to get it. Where do we see song names and artist name? Notifications. This is more of a brute force way.

Fortunately, Spotify has a public API Android Media Notifications which uses Android’s BroadcastReceiver. You can use this to subscribe to what’s happening in Spotify. This is exactly what we need.

The API exposes these metadata:

Metadata Description
id A Spotify URI for the track
artist The artist name(s) of the track
album The album name of the track
track The track name
length The length of the track, in seconds

We got the main and only ingredient. Now we need to find a way to get the lyrics. Like I said earlier, I just google the lyrics when I need them so why not do the same thing programmatically?

Implementation

In the very first version uploaded to playstore. All the logic was in a single file. Code quality who? It worked and I didn’t know any better since I didn’t follow any tutorial.

The logic was simple.

  • Get the song name and artist name from the API
  • Build a query string,
  • Somehow get the HTML of the google search result page
  • Parse the HTML to get the lyrics
id_link = "https://www.google.com/search?q=" + URLEncoder.encode(
            songname,
            "utf-8"
        ) + "+" + URLEncoder.encode(an, "utf-8") + "+" + "lyrics"

and you get something like this:

https://www.google.com/search?q=teeth+5+seconds+of+summer+lyrics

And there you have it

Verse Lyrics
Google results page
Verse Lyrics
Results page HTML


As you can see, all the lyrics are displayed in a <span> tag with the attribute [jsname='YS01Ge']. So all we have to do is parse the HTML and get the text inside the <span> tag with the attribute.


var ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
Jsoup.connect(id_link).userAgent(ua).get().run {
  val elements: Elements = select("[jsname='YS01Ge']")
    //println(elements)
    if (elements.size != 0) {
        select("[jsname='YS01Ge']").forEachIndexed { index, element ->
            var el = element.toString()
            var line =
                el.replace(("<span jsname=" + '"' + "YS01Ge" + '"' + ">"), "")
            line = line.replace("</span>", "")
            runOnUiThread(fun() {
                if (line_count >= 0) {
                    lyrics.append(line)
                    lyrics.append("\n")
                    lyrics.append("\n")
                    lyrics_appended = true
                } else {
                    line_count++
                }
            })
        }
    }
}

This is a very rudimentary way of doing it but that’s all it required. Now all that is left is to show it in the app.

App design

I was not really a UI person but always had a knack for minimalism so that’s how my first app design was. A simple screen that has lyrics.

Version 1 home page
v1 Home page

Pretty fancy for a first version right? But wait, what is the “Block ads” button doing over there?

Annoying ads

If you’ve spent anywhere near 3 minutes on Spotify, you would know how annoying their repeating ads are. I still can recite the ads by heart.

There were many open source apps that “blocked” ads or basically detect when ad is played and mute the phone and unmute when the ad is over. But they only had one function and why would I install someone’s app if I can make my own? So I did.

How does it work?

Simple. There are multiple ways to detect when an ad is played.

  1. Using the Spotify API to note the length of the song, then if we don’t get a new intent from the broadcast receiver after the song length, we can assume that the song is an ad.

  2. Or even simple(but prone to many issues) is reading the notification text and checking if it contains the word “ad”. This will break if the notifications are turned off.

I won’t go into the implementation here so if you want, you can check it out here.

Further development

When I first published it to playstore, I didn’t expect anyone to use it. I made it for my specific use case but why not publish it to playstore? I mean, you have to pay $25 to publish an app to playstore so I might as well make it worth it. I also posted about it on reddit and it kinda blew up.(I won’t share my reddit account here but the post got 355 upvotes and 73 comments and a shit ton of feedback). I would say that really boosted my app’s reputation in playstore.

Everyday, I would wake up and see the number of downloads increase by 10-15 and it was the ✨best✨ feeling. Like I’m just a student who made my first android app and people are downloading it?? Damnn.

Downloads were from all over the world. India, United States, Philippines, United Arab Emirates, Argentina, Australia, Aruba, Ghana, Italy, Nigeria, Pakistan, South Africa.

I actually didn’t care what most of the graphs means in the console dashboard. I just like looking at them going up and up.

conversion rate
Conversion rate

Just look at it!

Testimonials

Every time I get a comment on playstore, It make my day. Like you install an app and you use it. You don’t have any obligation to leave a comment but you do. That’s just amazing. Obviously I’m going to share all of them here, why do you ask?

2020
November
(en)

Nov 11, 2020

Setup is confusing. Font is too large and has too much spacing, can't adjust font or size. Lyrics must be manually scrolled and very little show on screen. Too many lyrics are not found, which is a deal breaker.

July
(en)

Jul 5, 2020

Noice!!

(en)

Jul 29, 2020

This app Works perfectly for me.

(en)

Jul 29, 2020

It didn't work for me, no lyrics nothing

(en)

Jul 29, 2020

Can't wait to see how the app evolves. Great right now.

(en)

Jul 30, 2020

Came here from Reddit. Wasn't disappointed at all. Keep it up, man!

(en)

Jul 31, 2020

Great app got a few suggestions: 1. Add an option to change fonts & colors 2. Add the features you absolutely have to but always keep the app minimalistic 3. Lyrics aren't available for some songs like 2 in 10 4. App should be able to detect when spotify is playing something automatically & show a notification to open with a click

September
(en)

Sep 3, 2020

The app is really cool and simple alternative to Shazam. Will definitely recommend this to others. Kudos to the dev.

(en)

Sep 24, 2020

Powered by ACRCloud

August
(en)

Aug 2, 2020

Great app overall. I have some suggestions: 1. Have the notification show lyrics(rather than open app, when songs plays, have notification of lyrics so that I can view it) 2. Is it possible to sync lyrics with the song? 3. Maybe have pop-up feature? (like chat head for messenger?) 4. Able to change font and colour. In live with the app right now. Can't wait this app to develop into something amazing.

(en)

Aug 13, 2020

I really love this app, I don't really have anything to complain because it works smoothly to me. Amazing app!!

(en)

Aug 28, 2020

Works perfectly

(en)

Aug 28, 2020

This app is amazing.

2021
May
(en)

May 11, 2021

I've been looking for a app like this for so long I almost gave up. simple to use, yet gives the Lyrics I want, well done.

(en)

May 21, 2021

This app is good it helps me a lot but i see a lot of mistakes in lyrics which is frustrating ( actually a lot of songs have this problem) pls fix this. I have some suggestions for you : 1- it would be good if we could add lyrics or save lyrics. 2- add more fonts to change. This app is so good and fast , of you fix that problem i'll definetly give 5 stars :)

July
(en)

Jul 31, 2021

Harus lagu Spotify

December
(en)

Dec 20, 2021

Doesn't open, can't use it

January
(en)

Jan 3, 2021

Doesn't mute ads which is what I really wanted it for

(de)

Jan 14, 2021

Die App zeigt zuverlässig die Songtexte der Songs aus der Playlist von Spotify an. Hierzu muss sie separat geöffnet werden. Es wird aber nicht geskrollt, so wie der Text gesungen wird. Bis jetzt hat die App bis auf einen Titel alle meine Songs angezeigt. Zu wünschen wäre eine Funktion welche die Texte in andere Sprachen übersetzt.

2022
April
(fr)

Apr 1, 2022

Love this app

(en)

Apr 1, 2022

Pretty straightforward and no-nonsense, does what its supposed to do, minus superfluous stuff. The static lyrics are effortless, but the dynamic/live lyrics are a bit delayed, but they're still beta so cant bash the dev for it. The fonts are beautiful, the interface is lovely, and dark mode is an added bonus. Plus you can manually mute ads. A suggestion would be a widget window that could display the lyrics while im scrolling through instagram. Awesome app. 10/10

2023
July
(lv)

Jul 26, 2023

Excellent application.

Positive or negative, I like all of them!

Other features

I also added a few other features that has been requested by users.

  • Dark mode/ Light mode
  • Auto scroll lyrics(although it’s not perfect)
  • Better UI
  • Font size change(4 sizes, grape, apple, mango, banana, pineapple, watermelon—inspired by reddit)
  • All google fonts available
  • Added Buy me a coffee button as requested by a user through email

Conclusion

This project started as one to solve my problems and along with it, it has been a great addition to my resume now that there are 1000+ downloads and 4.8 star rating on playstore. I’m probably done with this project as I don’t use android anymore and lyrics is added to Spotify in most countries now.