Open Rexadev opened 2 years ago
// File: src_sources.cpp
// Include the necessary headers
#include "stdafx.h"
#include "openlyrics_source.h"
// Function to fetch lyrics from www.megalobiz.com
std::string GetLyricsFromMegalobiz(const std::string& url)
{
// Implement the logic to fetch the lyrics from megalobiz.com
// You can choose your preferred web scraping or HTTP library for this task
// Here's an example using libcurl:
CURL* curl = curl_easy_init();
std::string lyrics;
if (curl)
{
// Set the necessary curl options
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &lyrics);
// Perform the curl request
CURLcode res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
// Handle the error gracefully
lyrics = "Apologies! Failed to retrieve lyrics from megalobiz.com. Please try again later.";
}
// Clean up the curl instance
curl_easy_cleanup(curl);
}
else
{
// Handle the curl initialization error
lyrics = "Apologies! Failed to initialize curl for fetching lyrics. Please check your network connection.";
}
return lyrics;
}
// Modify the openlyrics_source.cpp file to incorporate the new source
void OpenLyricsSource::GetLyrics(const std::string& url)
{
if (url.find("megalobiz.com") != std::string::npos)
{
// Fetch the lyrics from megalobiz.com
std::string lyrics = GetLyricsFromMegalobiz(url);
if (!lyrics.empty())
{
// Display or process the fetched lyrics
// Perform necessary operations based on the retrieved lyrics
}
else
{
// Handle the case when no lyrics are found
lyrics = "No lyrics found on megalobiz.com. Perhaps the song is instrumental?";
}
}
else
{
// Handle other sources gracefully
// Implement appropriate behavior for sources other than megalobiz.com
}
}
New example Available here but not in MusixMatch- https://www.megalobiz.com/lrc/maker/Selena+Gomez+-+Hands+To+Myself.54465621
Song - https://en.wikipedia.org/wiki/Satisfied_(Hamilton_song) https://www.megalobiz.com/lrc/maker/hamilton+-satisfied.54542334 https://www.google.com/search?q=hamilton+satisfied+site%3Amegalobiz.com
Song - https://en.wikipedia.org/wiki/Believe_(Cher_song) https://www.megalobiz.com/lrc/maker/Cher+-+Believe+%5BOfficial+Music+Video%5D.54552148
https://www.megalobiz.com/lrc/maker/Video+games.54516021
Song - https://en.wikipedia.org/wiki/Runaway_(Bon_Jovi_song) https://www.megalobiz.com/lrc/maker/Bon+Jovi+-+Runaway.54805058