diff --git a/src/lyrics/LyricsManager.h b/src/lyrics/LyricsManager.h --- a/src/lyrics/LyricsManager.h +++ b/src/lyrics/LyricsManager.h @@ -68,6 +68,9 @@ static LyricsManager* s_self; QMap m_trackMap; + + private Q_SLOTS: + void updateRedirectedUrl( const QUrl& oldUrl, const QUrl& newUrl ); }; #endif diff --git a/src/lyrics/LyricsManager.cpp b/src/lyrics/LyricsManager.cpp --- a/src/lyrics/LyricsManager.cpp +++ b/src/lyrics/LyricsManager.cpp @@ -31,7 +31,7 @@ #include -#define APIURL "http://lyrics.wikia.com/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles=" +#define APIURL "https://lyrics.fandom.com/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles=" LyricsManager* LyricsManager::s_self = nullptr; @@ -136,6 +136,10 @@ QUrl url( APIURL + artist + QLatin1Char(':') + title ); m_trackMap.insert( url, track ); + + connect( NetworkAccessManagerProxy::instance(), &NetworkAccessManagerProxy::requestRedirectedUrl, + this, &LyricsManager::updateRedirectedUrl); + NetworkAccessManagerProxy::instance()->getData( url, this, &LyricsManager::lyricsLoaded ); } @@ -273,3 +277,16 @@ return testText.isEmpty(); } + +void LyricsManager::updateRedirectedUrl(const QUrl& oldUrl, const QUrl& newUrl) +{ + if( m_trackMap.contains( oldUrl ) && !m_trackMap.contains( newUrl ) ) + { + // Get track for the old URL. + Meta::TrackPtr track = m_trackMap.value( oldUrl ); + + // Replace with redirected url for correct lookup + m_trackMap.insert( newUrl, track ); + m_trackMap.remove( oldUrl ); + } +}