jacquesh / foo_openlyrics

An open-source lyric display panel for foobar2000
MIT License
429 stars 24 forks source link

Source: megalobiz.com [Synced Lyrics] #172

Open Rexadev opened 2 years ago

Rexadev commented 2 years ago
  1. 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 image

  2. Song - https://en.wikipedia.org/wiki/Believe_(Cher_song) https://www.megalobiz.com/lrc/maker/Cher+-+Believe+%5BOfficial+Music+Video%5D.54552148 image

  3. https://www.megalobiz.com/lrc/maker/Video+games.54516021 image

  4. Song - https://en.wikipedia.org/wiki/Runaway_(Bon_Jovi_song) https://www.megalobiz.com/lrc/maker/Bon+Jovi+-+Runaway.54805058 image

Rexadev commented 1 year 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
    }
}
Rexadev commented 1 week ago

New example Available here but not in MusixMatch- https://www.megalobiz.com/lrc/maker/Selena+Gomez+-+Hands+To+Myself.54465621