Beispiel #1
0
void db_lyrdb::GetResults(window_config *wcfg, std::vector<lyric_data>* results, tstring title, tstring artist, tstring album)
{

  title = ReplaceString(_T("&"), _T("and"), title);
  artist = ReplaceString(_T("&"), _T("and"), artist);
  title = ReplaceString(_T("pt."), _T("part"), title);
  artist = ReplaceString(_T("pt."), _T("part"), artist);

  bool useFulltext = false;
  bool found = false;
  tstring out;

  if (!useFulltext)
  {
    out = _T("lookup.php?q=");
    out += CURLEncode::Encode(artist);
    out += _T("|");
    out += CURLEncode::Encode(title);
    out += _T("&for=match&agent=foo_uie_lyrics2");
  }
  else
  {
    out = _T("lookup.php?q=");
    out += CURLEncode::Encode(artist);
    out += _T(" - ");
    out += CURLEncode::Encode(title);
    out += _T("&for=fullt&agent=foo_uie_lyrics2");
  }

  out += _T("&query=plugin&type=plugin");

  tstring remoteText;

  if (!ReadInternetText(remoteText, _T("FOO_UIE_LYRICS2"), _T("webservices.lyrdb.com"), 80, out, _T(""), false, wcfg->cfg_timeout, wcfg) && remoteText != _T(""))
    return ;

  tstring::size_type ptr = 0;

  tstring::size_type end = 0;

  while (true)
  {
    if (ptr >= remoteText.size() || ptr == tstring::npos)
      break;

    end = remoteText.find(_T("\r\n"), ptr);

    if (end == tstring::npos && ptr == 0)
      end = remoteText.size() - 1;

    if (end >= remoteText.size() || end == tstring::npos)
      break;

    tstring line = remoteText.substr(ptr, end + 1 - ptr);

    // parse
    tstring::size_type pos = line.find(_T("\\"));

    if (pos != tstring::npos)
    {
      tstring line_id = line.substr(0, pos);
      tstring line_title = _T("");
      tstring line_artist = _T("");

      if (pos + 1 < line.size())
      {
        tstring::size_type pos2 = line.find(_T("\\"), pos + 1);

        if (pos2 != tstring::npos)
        {
          line_title = line.substr(pos + 1, pos2 - pos + 1);

          if (pos2 + 2 < line.size())
          {
            tstring::size_type pos3 = line.find(_T("\\"), pos2 + 1);

            if (pos3 != tstring::npos)
              line_artist = line.substr(pos2 + 1, pos3 - pos2 + 1);
          }
        }
      }

      lyric_data newData(wcfg);
      newData.SourceType = ST_INTERNET;
      newData.IsLoaded = false;
      newData.IsTimestamped = false;
      newData.matchAlbum = _T("");
      newData.matchArtist = line_artist;
      newData.matchTitle = line_title;
      newData.db = this;
      newData.OnlineService = LD_LYRDB;
      newData.Quality = Q_MEDIUM;
      newData.Source = _T("http://www.lyrdb.com/getlyr.php?q=");
      newData.Source += line_id;

      results->push_back(newData);

    }

    ptr = end + 2;
  }

  return ;
}
Beispiel #2
0
void db_lyricsfly::GetResults(window_config *wcfg, std::vector<lyric_data>* results, tstring title, tstring artist, tstring album)
{
  title = ReplaceString(_T("&"), _T("and"), title);
  artist = ReplaceString(_T("&"), _T("and"), artist);
  title = ReplaceString(_T("pt."), _T("part"), title);
  artist = ReplaceString(_T("pt."), _T("part"), artist);

  tstring out;
  out = _T("api/api.php?i=");
  out += _T("55562032656-reeloo.net/wordpress/lyrics-for-lastfm-radio");
  out += _T("&a=");
  out += CURLEncode::Encode(artist);
  out += _T("&t=");
  out += CURLEncode::Encode(title);

  tstring remoteText;

  if (!ReadInternetText(remoteText, _T("Mozilla/4.0 (compatible) Greasemonkey"), _T("api.lyricsfly.com"), 80, out, _T(""), false, wcfg->cfg_timeout, wcfg))
    return ;

  CMarkup xml;

  if (!xml.SetDoc(remoteText.c_str()))
    return ;

  while (xml.FindChildElem(_T("sg")))
  {
    xml.IntoElem();

    tstring info_artist, info_title, info_album, info_lyrics;

    if (xml.FindChildElem(_T("tx")))
    {
      info_lyrics = xml.GetChildData();
    }
    else
    {
      xml.OutOfElem();
      continue;
    }

    xml.ResetChildPos();

    if (xml.FindChildElem(_T("ar")))
    {
      info_artist = xml.GetChildData();
    }

    xml.ResetChildPos();

    if (xml.FindChildElem(_T("al")))
    {
      info_album = xml.GetChildData();
    }

    xml.ResetChildPos();

    if (xml.FindChildElem(_T("tt")))
    {
      info_title = xml.GetChildData();
    }

    lyric_data newData(wcfg);
    newData.SourceType = ST_INTERNET;
    newData.IsLoaded = true;
    newData.matchArtist = info_artist;
    newData.matchAlbum = info_album;
    newData.matchTitle = info_title;
    newData.db = this;
    newData.OnlineService = LD_LYRICSFLY;
    newData.Quality = Q_MEDIUM;
    newData.Source = _T("lyricsfly");

    newData.Text = info_lyrics;
    newData.Text = ReplaceString(_T("[br]"), _T(""), newData.Text);
    newData.Text = ReplaceString(_T("\r"), _T(""), newData.Text);
    newData.Text = ReplaceString(_T("\n"), _T("\r\n"), newData.Text);

    if (newData.Text.find(_T("[")) != tstring::npos)
      newData.IsTimestamped = true;
    else
      newData.IsTimestamped = false;

    results->push_back(newData);

    xml.OutOfElem();
  }

}
Beispiel #3
0
void db_leos::GetResults(window_config *wcfg, std::vector<lyric_data>* results, tstring title, tstring artist, tstring album)
{

  title = ReplaceString(_T("&"), _T("and"), title);
  artist = ReplaceString(_T("&"), _T("and"), artist);
  title = ReplaceString(_T("pt."), _T("part"), title);
  artist = ReplaceString(_T("pt."), _T("part"), artist);

  tstring out;

  out = _T("api_search.php?auth=foo_uie_lyrics2&artist=");
  out += CURLEncode::Encode(artist);
  out += _T("&songtitle=");
  out += CURLEncode::Encode(title);

  tstring remoteText;

  if (!ReadInternetText(remoteText, _T("FOO_UIE_LYRICS2"), _T("api.leoslyrics.com"), 80, out, _T(""), false, wcfg->cfg_timeout, wcfg))
    return ;

  CMarkup xml;

  if (!xml.SetDoc(remoteText.c_str()))
    return ;

  if (xml.FindChildElem(_T("searchResults")))
  {
    xml.IntoElem();

    while (xml.FindChildElem(_T("result")))
    {
      xml.IntoElem();

      if (!_wcsicmp(_T("true"), xml.GetAttrib(_T("exactMatch")).c_str()))
      {
        tstring hid = xml.GetAttrib(_T("hid"));

        if (!hid.empty())
        {

          lyric_data newData(wcfg);
          newData.SourceType = ST_INTERNET;
          newData.IsLoaded = false;
          newData.IsTimestamped = false;
          newData.matchArtist = _T("");
          newData.matchAlbum = _T("");
          newData.matchTitle = title;
          newData.db = this;
          newData.OnlineService = LD_LEOS;
          newData.Quality = Q_MEDIUM;
          newData.Source = _T("http://api.leoslyrics.com/api_lyrics.php?auth=foo_uie_lyrics2&hid=");
          newData.Source += hid;

          results->push_back(newData);
        }
      }

      xml.OutOfElem();
    }

    xml.OutOfElem();
  }

}