Merge branch 'CoolBurp/spotifykeydumper-main' into main
This commit is contained in:
commit
5e0142783c
@ -120,6 +120,9 @@ struct SongInfo
|
|||||||
std::string title, artist, album, cover;
|
std::string title, artist, album, cover;
|
||||||
} songInfo;
|
} songInfo;
|
||||||
|
|
||||||
|
static const std::string songRegex =
|
||||||
|
"https?:\\/\\/(?:www\.)?([-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6})"
|
||||||
|
"\\b([-a-zA-Z0-9()@:%_\\+.~#?&\\/\\/=]*)";
|
||||||
static const std::string albumSearchPattern = "\x68\x65\x69\x67\x68\x74\x22\x20\x3A\x20\x36\x34\x30";
|
static const std::string albumSearchPattern = "\x68\x65\x69\x67\x68\x74\x22\x20\x3A\x20\x36\x34\x30";
|
||||||
static const std::wstring songDirRoot = L"Downloads";
|
static const std::wstring songDirRoot = L"Downloads";
|
||||||
static std::wstring songDir = songDirRoot;
|
static std::wstring songDir = songDirRoot;
|
||||||
@ -144,14 +147,39 @@ void Utils::DownloadSong(std::string fileId, std::string trackUri, std::string k
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse storage resolve response to get the encrypted song data's URL
|
// Parse storage resolve response to get the encrypted song data's URL
|
||||||
std::string songHost = (srStr.substr(srStr.find("https://") + 8))
|
std::string songHost;
|
||||||
.erase(srStr.substr(srStr.find("https://") + 8).find("/audio/"));
|
std::string songPath;
|
||||||
std::string songPath = srStr.substr(srStr.find("/audio/")).erase(srStr.substr(srStr.find("/audio/")).find("=")
|
try
|
||||||
+ 85);
|
{
|
||||||
|
std::regex re(songRegex);
|
||||||
|
std::smatch match;
|
||||||
|
if (std::regex_search(srStr, match, re) && match.size() > 1)
|
||||||
|
{
|
||||||
|
songHost = match.str(1);
|
||||||
|
songPath = match.str(2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Error: Download URL not found" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::regex_error& e)
|
||||||
|
{
|
||||||
|
// Syntax error in the regular expression
|
||||||
|
std::cout << "Error: regex_error" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Download encrypted song data from Spotify
|
// Download encrypted song data from Spotify
|
||||||
std::string songStr = DownloadSpotifyUrl(songHost, songPath, "");
|
std::string songStr = DownloadSpotifyUrl(songHost, songPath, "");
|
||||||
|
|
||||||
|
if (songStr.empty())
|
||||||
|
{
|
||||||
|
std::cout << "Error: Could not download audio" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (songStr.length() > 6 && songStr.substr(0, 6).compare("<HTML>") == 0)
|
if (songStr.length() > 6 && songStr.substr(0, 6).compare("<HTML>") == 0)
|
||||||
{
|
{
|
||||||
std::cout << "Error: " + songStr << std::endl;
|
std::cout << "Error: " + songStr << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user