Files
ncmpcpp/src/lyrics_fetcher.h
2010-08-09 11:39:41 +02:00

75 lines
2.8 KiB
C++

/***************************************************************************
* Copyright (C) 2008-2010 by Andrzej Rybczak *
* electricityispower@gmail.com *
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef _LYRICS_FETCHER_H
#define _LYRICS_FETCHER_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_CURL_CURL_H
#include <string>
struct LyricsFetcher
{
typedef std::pair<bool, std::string> Result;
virtual const char *name() = 0;
virtual Result fetch(const std::string &artist, const std::string &title);
protected:
virtual const char *getURL() = 0;
virtual const char *getOpenTag() = 0;
virtual const char *getCloseTag() = 0;
virtual bool notLyrics(GNUC_UNUSED const std::string &data) { return false; }
virtual void postProcess(std::string &data);
};
struct LyrcComArFetcher : public LyricsFetcher
{
virtual const char *name() { return "lyrc.com.ar"; }
protected:
virtual const char *getURL() { return "http://lyrc.com.ar/tema1es.php?artist=%artist%&songname=%title%"; }
virtual const char *getOpenTag() { return "</table>"; }
virtual const char *getCloseTag() { return "<p>"; }
};
struct LyricsflyFetcher : public LyricsFetcher
{
virtual const char *name() { return "lyricsfly.com"; }
protected:
virtual const char *getURL() { return "http://api.lyricsfly.com/api/api.php?i=1b76e55254f5f22ae-temporary.API.access&a=%artist%&t=%title%"; }
virtual const char *getOpenTag() { return "<tx>"; }
virtual const char *getCloseTag() { return "</tx>"; }
virtual void postProcess(std::string &data);
};
extern LyricsFetcher *lyricsPlugins[];
#endif // HAVE_CURL_CURL_H
#endif