Open Mrakobes666 opened 2 years ago
Code not tested
Using Curl
// Include necessary libraries and headers
#include <string>
#include <curl/curl.h>
// Function to retrieve lyrics from Bandcamp
std::string getBandcampLyrics(const std::string& trackUrl) {
std::string lyrics;
// Make a request to the track URL
CURL* curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, trackUrl.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
// Specify any additional CURL options if required
// Perform the HTTP request and retrieve the response
CURLcode res = curl_easy_perform(curl);
if (res == CURLE_OK) {
// Process the response to extract the lyrics
lyrics = extractLyricsFromResponse(curl);
}
// Clean up the CURL resources
curl_easy_cleanup(curl);
}
return lyrics;
}
// Modify the existing fetchLyrics() function in the foo_openlyrics source file
void fetchLyrics(const std::string& trackUrl) {
std::string lyrics;
// Check if the track URL is from Bandcamp
if (isBandcampTrack(trackUrl)) {
lyrics = getBandcampLyrics(trackUrl);
}
// Handle the fetched lyrics as per the existing logic
handleFetchedLyrics(lyrics);
}
@jacquesh When using this. Add option to only search on bandcamp.com when file has source metadata has word bandcamp in it.
A request for lyrics from a site that has a structure that parses well, this site is a trend for a huge number of musicians
https://deltasleep.bandcamp.com/album/spring-island?from=discover-top