Expanding the catalog

Guillaume edited this page Mar 19, 2015 · 6 revisions

Expanding the catalog

Lyrics providers are located in com.geecko.QuickLyric.lyrics.*

Before you add a new provider

  • Make sure it's not redundant (we don't need 3 providers for Punk Music. One's enough)
  • Make sure the provider has either an API (that gives you either the lyrics or the webpage with the lyrics) or guessable URLs (e.g. "lyricswebsite.com/$artist/$track.html")

Good to go? Great!

Adding a new provider

Create a class in com.geecko.QuickLyric.lyrics.

  • It should be named after the provider.
  • It should have the GPLv3 disclaimer at the top.
  • It should (normally) not extend another class or implement an interface.
  • It should have a static final String field called "domain" that contains the domain of the website, if it applies.
  • It should have at least 2 static methods returning Lyrics: fromURL(url, artist, title) and fromMetaData(artist, title).
  • Both methods and the class should have the @Reflection annotation.

You can find a template fulfilling all conditions here: LyricsProviderTemplate.

The actual coding

Use JSoup if you're parsing from XML or HTML, use the built-in JSONObject classes if you're parsing JSON.

Important: if you're using JSoup, you should preferably use .userAgent(Net.USER_AGENT)

Document document = Jsoup.connect(url).userAgent(Net.USER_AGENT).get();

If all works out well, you should return a new Lyrics object with POSITIVE_FLAG containing the artist, the title, the text, the source and, if possible, the website URL.

If you get a connection or parsing error, return an empty Lyrics object with the ERROR flag

If the provider doesn't have the lyrics for the song, return NO_RESULT if it's totally absent and NEGATIVE_RESULT if you can tell it's been removed from the database.

When you're done

Submit a pull request and I'll integrate it in the app as I see fit (either as one of the main providers or as an option).

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.