Skip to content

Instantly share code, notes, and snippets.

@geecko86
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geecko86/deeb2a9f172e937192da to your computer and use it in GitHub Desktop.
Save geecko86/deeb2a9f172e937192da to your computer and use it in GitHub Desktop.
LyricsProviderTemplate.java
/*
* *
* * This file is part of QuickLyric
* * Created by geecko
* *
* * QuickLyric is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation, either version 3 of the License, or
* * (at your option) any later version.
* *
* * QuickLyric is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* * You should have received a copy of the GNU General Public License
* * along with QuickLyric. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.geecko.QuickLyric.lyrics;
import com.geecko.QuickLyric.annotations.Reflection;
import com.geecko.QuickLyric.utils.Net;
@Reflection
public class LyricsProviderTemplate {
public static final String domain = "www.website.com";
@Reflection
public static Lyrics fromMetaData(String artist, String song) {
String url;
// do stuff with the MetaData and find out the URL
return fromURL(url, artist, song);
// or return the lyrics here if you're using an API
}
public static Lyrics fromURL(String url, String artist, String song) {
// This method should have these 3 arguments. null can be used for artist or song.
/*
do the stuff
if artist and song are null, parse them as well
You can assume that if artist is null, song is too
*/
Lyrics l = new Lyrics(Lyrics.POSITIVE_RESULT); // if the lyrics are found, use this flag
l.setArtist(artist);
l.setText(text);
l.setTitle(song);
l.setURL(url);
l.setSource(domain);
return l;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment