Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ target_sources(
widgets/volumecontrol.cpp
context/lyricsettings.cpp
context/ultimatelyricsprovider.cpp
context/ultimatelyricshttpprovider.cpp
context/ultimatelyricscommandprovider.cpp
context/ultimatelyrics.cpp
context/lyricsdialog.cpp
context/contextwidget.cpp
Expand All @@ -469,6 +471,7 @@ target_sources(
context/lastfmengine.cpp
context/metaengine.cpp
context/onlineview.cpp
context/lyrics_providers/lrcliblyricsprovider.cpp
streams/streamspage.cpp
streams/streamdialog.cpp
streams/streamfetcher.cpp
Expand Down
61 changes: 33 additions & 28 deletions context/lyrics_providers.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<lyricproviders>
<provider name="azlyrics.com" charset="utf-8" url="https://www.azlyrics.com/lyrics/{artist}/{title}.html">
<provider type="http" name="azlyrics.com" charset="utf-8" url="https://www.azlyrics.com/lyrics/{artist}/{title}.html">
<urlFormat replace=" ._@,;&amp;\/()'&quot;-?" with=""/>
<extract>
<item begin="&lt;!-- END OF RINGTONE 1 --&gt;" end="&lt;!-- RINGTONE 2 --&gt;"/>
Expand All @@ -15,22 +15,22 @@
</exclude>
<invalidIndicator value="&lt;h1&gt;Welcome to AZLyrics!&lt;/h1&gt;"/>
</provider>
<provider name="bollywoodlyrics.com (Bollywood songs)" charset="utf-8" url="https://www.bollywoodlyrics.com/lyric/{Title}">
<provider type="http" name="bollywoodlyrics.com (Bollywood songs)" charset="utf-8" url="https://www.bollywoodlyrics.com/lyric/{Title}">
<urlFormat replace=" _@;\/&quot;'()[]" with="-"/>
<urlFormat replace="?" with=""/>
<extract>
<item begin="&lt;div class=&quot;entry-content&quot;&gt;" end="&lt;/div&gt;"/>
</extract>
<invalidIndicator value="Couldn't find that page."/>
</provider>
<provider name="chartlyrics.com" charset="utf-8" url="http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist={artist}&amp;song={title}">
<provider type="http" name="chartlyrics.com" charset="utf-8" url="http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist={artist}&amp;song={title}">
<urlFormat replace="_@,;&amp;\/&quot;#" with="_"/>
<extract>
<item tag="&lt;Lyric&gt;"/>
</extract>
<invalidIndicator value="ERROR"/>
</provider>
<provider name="darklyrics.com" charset="utf-8" url="http://www.darklyrics.com/lyrics/{artist2}/{album2}.html">
<provider type="http" name="darklyrics.com" charset="utf-8" url="http://www.darklyrics.com/lyrics/{artist2}/{album2}.html">
<extract> <!-- modified -->
<item begin="&lt;h3&gt;&lt;a name=&quot;{track}&quot;&gt;{track}. {Title}&lt;/a&gt;&lt;/h3&gt;&lt;br/&gt;" end="&lt;h3&gt;"/>
</extract>
Expand All @@ -42,7 +42,7 @@
</extract>
<invalidIndicator value="The page you requested was not found on DarkLyrics.com."/>
</provider>
<provider name="directlyrics.com" charset="utf-8" url="http://www.directlyrics.com/{artist}-{title}-lyrics.html"> <!-- was iso-8859-1 -->
<provider type="http" name="directlyrics.com" charset="utf-8" url="http://www.directlyrics.com/{artist}-{title}-lyrics.html"> <!-- was iso-8859-1 -->
<urlFormat replace=" _@,;&amp;\/'&quot;" with="-"/>
<urlFormat replace="." with=""/>
<extract>
Expand All @@ -59,7 +59,7 @@
<item begin="&lt;script async src=&quot;" end="&lt;/script&gt;&lt;br&gt;"/>
</exclude>
</provider>
<provider name="elyrics.net" charset="iso-8859-1" url="https://www.elyrics.net/read/{a}/{artist}-lyrics/{title}-lyrics.html">
<provider type="http" name="elyrics.net" charset="iso-8859-1" url="https://www.elyrics.net/read/{a}/{artist}-lyrics/{title}-lyrics.html">
<urlFormat replace=" _@;&amp;\/&quot;" with="-"/>
<urlFormat replace="'" with="_"/>
<extract> <!-- new -->
Expand All @@ -77,7 +77,7 @@
</exclude>
<invalidIndicator value="Page not Found"/>
</provider>
<provider name="hindilyrics.net (Bollywood songs)" charset="utf-8" url="http://www.hindilyrics.net/lyrics/of-{Title}.html">
<provider type="http" name="hindilyrics.net (Bollywood songs)" charset="utf-8" url="http://www.hindilyrics.net/lyrics/of-{Title}.html">
<urlFormat replace=" _@;\/&quot;'()[]" with="%20"/>
<urlFormat replace="?" with=""/>
<extract>
Expand All @@ -89,7 +89,7 @@
<invalidIndicator value="Couldn't find that page."/>
</provider>
<!-- Issue #1571
<provider name="Encyclopaedia Metallum" charset="utf-8" url="https://www.metal-archives.com/search/ajax-advanced/searching/songs/?songTitle={title}&amp;bandName={artist}&amp;ExactBandMatch=1">
<provider type="http" name="Encyclopaedia Metallum" charset="utf-8" url="https://www.metal-archives.com/search/ajax-advanced/searching/songs/?songTitle={title}&amp;bandName={artist}&amp;ExactBandMatch=1">
<extract>
<item url="http://www.metal-archives.com/release/ajax-view-lyrics/id/{id}"/>
<item begin="id=\&quot;lyricsLink_" end="&quot;"/>
Expand All @@ -98,7 +98,7 @@
<invalidIndicator value="lyrics not available"/>
</provider>
-->
<provider name="letras.mus.br" charset="utf-8" url="https://www.letras.mus.br/winamp.php?musica={title}&amp;artista={artist}">
<provider type="http" name="letras.mus.br" charset="utf-8" url="https://www.letras.mus.br/winamp.php?musica={title}&amp;artista={artist}">
<urlFormat replace="_@,;&amp;\/&quot;" with="_"/>
<urlFormat replace=" " with="+"/>
<extract> <!-- new -->
Expand All @@ -109,7 +109,7 @@
</extract>
<invalidIndicator value="Verifique se o nome do seu arquivo e sua"/>
</provider>
<provider name="genius.com" charset="utf-8" url="https://www.genius.com/{artist}-{title}-lyrics">
<provider type="http" name="genius.com" charset="utf-8" url="https://www.genius.com/{artist}-{title}-lyrics">
<urlFormat replace=",._@!#%^*+;\/&quot;'()[]?" with=""/>
<urlFormat replace=" :" with="-"/>
<!-- When $ is used as the dollar sign it is ommitted from the url
Expand Down Expand Up @@ -137,14 +137,14 @@
<item begin="&lt;/a" end="&gt;"/>
</exclude>
</provider>
<provider name="lololyrics.com" charset="utf-8" url="http://api.lololyrics.com/0.5/getLyric?artist={artist}&amp;track={title}">
<provider type="http" name="lololyrics.com" charset="utf-8" url="http://api.lololyrics.com/0.5/getLyric?artist={artist}&amp;track={title}">
<urlFormat replace="_@,;&amp;\/&quot;#" with="_"/>
<extract>
<item tag="&lt;response&gt;"/>
</extract>
<invalidIndicator value="ERROR"/>
</provider>
<provider name="loudson.gs" charset="utf-8" url="http://www.loudson.gs/{a}/{artist}/{album}/{title}">
<provider type="http" name="loudson.gs" charset="utf-8" url="http://www.loudson.gs/{a}/{artist}/{album}/{title}">
<urlFormat replace=" _@,;&amp;\/&quot;" with="-"/>
<urlFormat replace="." with=""/>
<extract>
Expand All @@ -154,7 +154,7 @@
<item tag="&lt;div class=&quot;middle_col_TracksLyrics&quot;&gt;"/>
</extract>
</provider>
<provider name="lyrics.com" charset="utf-8" url="https://www.lyrics.com/lyrics/{artist}/{title}.html">
<provider type="http" name="lyrics.com" charset="utf-8" url="https://www.lyrics.com/lyrics/{artist}/{title}.html">
<urlFormat replace=" _@,;&amp;\/&quot;" with="-"/>
<urlFormat replace="'." with=""/>
<extract> <!-- new -->
Expand All @@ -170,7 +170,7 @@
<invalidIndicator value="we do not have the lyric for this song"/>
<invalidIndicator value="Your name will be printed as part of the credit when your lyric is approved"/>
</provider>
<provider name="lyrics.wikia.com" charset="utf-8" url="https://lyrics.wikia.com/api.php">
<provider type="http" name="lyrics.wikia.com" charset="utf-8" url="https://lyrics.wikia.com/api.php">
<!-- These are not used, as mediawiki API is used instead...
<urlFormat replace=" _@;\&quot;" with="_"/>
<urlFormat replace="?" with="%3F"/>
Expand All @@ -183,15 +183,15 @@
</exclude>
-->
</provider>
<provider name="lyricsdownload.com" charset="utf-8" url="http://www.lyricsdownload.com/{artist}-{title}-lyrics.html">
<provider type="http" name="lyricsdownload.com" charset="utf-8" url="http://www.lyricsdownload.com/{artist}-{title}-lyrics.html">
<urlFormat replace=" _@,;&amp;\/&quot;" with="-"/>
<urlFormat replace="." with=""/>
<extract>
<item tag="&lt;div id=&quot;div_customCSS&quot;&gt;"/>
</extract>
<invalidIndicator value="We haven't lyrics of this song"/>
</provider>
<provider name="lyricsmania.com" charset="iso-8859-1" url="https://www.lyricsmania.com/{title}_lyrics_{artist}.html">
<provider type="http" name="lyricsmania.com" charset="iso-8859-1" url="https://www.lyricsmania.com/{title}_lyrics_{artist}.html">
<urlFormat replace=" _@;&amp;\/&quot;'." with="_"/>
<extract> <!-- new -->
<item tag="&lt;div id='songlyrics_h' class='dn'&gt;"/>
Expand All @@ -202,7 +202,7 @@
</extract>
<invalidIndicator value="The lyrics you requested is not in our archive yet,"/>
</provider>
<provider name="lyricsmode.com" charset="iso-8859-1" url="http://www.lyricsmode.com/lyrics/{a}/{artist}/{title}.html">
<provider type="http" name="lyricsmode.com" charset="iso-8859-1" url="http://www.lyricsmode.com/lyrics/{a}/{artist}/{title}.html">
<urlFormat replace=" ._@,;&amp;\/&quot;" with="_"/>
<extract>
<item tag="&lt;div id='songlyrics_h' class='dn'&gt;"/>
Expand All @@ -212,7 +212,7 @@
</extract>
<invalidIndicator value="Sorry, we have no"/>
</provider>
<provider name="lyricsreg.com" charset="iso-8859-1" url="https://www.lyricsreg.com/lyrics/{artist}/{title}/">
<provider type="http" name="lyricsreg.com" charset="iso-8859-1" url="https://www.lyricsreg.com/lyrics/{artist}/{title}/">
<urlFormat replace=" _@,;&amp;\/&quot;" with="+"/>
<urlFormat replace="'." with=""/>
<extract>
Expand All @@ -225,7 +225,7 @@
</extract>
<invalidIndicator value="Page not Found"/>
</provider>
<provider name="lyriki.com" charset="utf-8" url="http://www.lyriki.com/{artist}:{title}">
<provider type="http" name="lyriki.com" charset="utf-8" url="http://www.lyriki.com/{artist}:{title}">
<urlFormat replace=" _@,;&amp;\/&quot;" with="_"/>
<urlFormat replace="." with=""/>
<extract>
Expand All @@ -234,7 +234,7 @@
</extract>
</provider>
<!-- broken
<provider name="metrolyrics.com" charset="utf-8" url="http://www.metrolyrics.com/{title}-lyrics-{artist}.html">
<provider type="http" name="metrolyrics.com" charset="utf-8" url="http://www.metrolyrics.com/{title}-lyrics-{artist}.html">
<urlFormat replace=" _@,;&amp;\/&quot;" with="-"/>
<urlFormat replace="'." with=""/>
<extract>
Expand All @@ -252,7 +252,7 @@
<invalidIndicator value="These lyrics are missing"/>
</provider>
-->
<provider name="mp3lyrics.org" charset="utf-8" url="http://www.mp3lyrics.org/{a}/{artist}/{title}/">
<provider type="http" name="mp3lyrics.org" charset="utf-8" url="http://www.mp3lyrics.org/{a}/{artist}/{title}/">
<urlFormat replace=" _@,;&amp;\/&quot;" with="-"/>
<urlFormat replace="'." with=""/>
<extract>
Expand All @@ -271,7 +271,7 @@
</exclude>
<invalidIndicator value="Something went wrong"/>
</provider>
<provider name="musixmatch.com" charset="utf-8" url="https://www.musixmatch.com/lyrics/{Artist}/{Title}">
<provider type="http" name="musixmatch.com" charset="utf-8" url="https://www.musixmatch.com/lyrics/{Artist}/{Title}">
<urlFormat replace=" _@;\/&quot;'()[]" with="-"/>
<urlFormat replace="?" with=""/>
<extract>
Expand All @@ -282,7 +282,7 @@
</exclude>
<invalidIndicator value="We couldn't find that page."/>
</provider>
<provider name="songlyrics.com" charset="utf-8" url="https://www.songlyrics.com/{artist}/{title}-lyrics/">
<provider type="http" name="songlyrics.com" charset="utf-8" url="https://www.songlyrics.com/{artist}/{title}-lyrics/">
<urlFormat replace=" ._@,;&amp;\/&quot;" with="-"/>
<urlFormat replace="'" with="_"/>
<extract>
Expand All @@ -297,7 +297,7 @@
<invalidIndicator value="Sorry, we have no"/>
<invalidIndicator value="This is an upcoming album and we do not have the"/>
</provider>
<provider name="tekstowo.pl (Original lyric language)" charset="utf-8" url="http://www.tekstowo.pl/piosenka,{artist},{title}.html">
<provider type="http" name="tekstowo.pl (Original lyric language)" charset="utf-8" url="http://www.tekstowo.pl/piosenka,{artist},{title}.html">
<urlFormat replace=" _@,;&amp;\/'&quot;." with="_"/>
<extract>
<item begin="&lt;div class=&quot;song-text&quot;&gt;" end="&lt;a href=&quot;javascript:;&quot;"/>
Expand All @@ -309,7 +309,7 @@
<item begin="&lt;h2&gt;" end="&lt;/h2&gt;&lt;br /&gt;"/>
</exclude>
</provider>
<provider name="tekstowo.pl (Translated to Polish)" charset="utf-8" url="http://www.tekstowo.pl/piosenka,{artist},{title}.html">
<provider type="http" name="tekstowo.pl (Translated to Polish)" charset="utf-8" url="http://www.tekstowo.pl/piosenka,{artist},{title}.html">
<urlFormat replace=" _@,;&amp;\/'&quot;." with="_"/>
<extract>
<item begin="&lt;div id=&quot;translation&quot; class=" end="&lt;a href="/>
Expand All @@ -318,14 +318,14 @@
<item begin="&quot;id-" end="&quot;&gt;"/>
</exclude>
</provider>
<provider name="teksty.org" title="{artist} - {title} - tekst" charset="utf-8" url="http://teksty.org/{artist},{title},tekst-piosenki">
<provider type="http" name="teksty.org" title="{artist} - {title} - tekst" charset="utf-8" url="http://teksty.org/{artist},{title},tekst-piosenki">
<urlFormat replace=" _@,;&amp;\/&quot;'" with="-"/>
<urlFormat replace="." with=""/>
<extract>
<item begin="&lt;div class=&quot;songText&quot; id=&quot;songContent&quot;&gt;" end="&lt;/div&gt;"/>
</extract>
</provider>
<provider name="vagalume.com.br" charset="iso-8859-1" url="http://vagalume.com.br/{artist}/{title}.html">
<provider type="http" name="vagalume.com.br" charset="iso-8859-1" url="http://vagalume.com.br/{artist}/{title}.html">
<urlFormat replace=" _@,;&amp;\/'&quot;." with="-"/>
<extract>
<item tag="&lt;span class=&quot;editable_area&quot;&gt;"/>
Expand All @@ -334,7 +334,7 @@
<item tag="&lt;div itemprop=description&gt;"/>
</extract>
</provider>
<provider name="vagalume.com.br (PORTUGUESE)" charset="iso-8859-1" url="https://www.vagalume.com.br/{artist}/{title}-traducao.html">
<provider type="http" name="vagalume.com.br (PORTUGUESE)" charset="iso-8859-1" url="https://www.vagalume.com.br/{artist}/{title}-traducao.html">
<urlFormat replace=" _@,;&amp;\/'&quot;." with="-"/>
<extract>
<item tag="&lt;div class=&quot;tab_traducao sideBySide lyricArea tab_tra_pt&quot;&gt;"/>
Expand All @@ -344,4 +344,9 @@
<item begin="&lt;div&gt;" end="null"/>
</extract>
</provider>
<provider type="command" name="lrclib.net" executable="lrclib.sh">
<argument value="{Title}"/>
<argument value="{Artist}"/>
<argument value="{duration}"/>
</provider>
</lyricproviders>
66 changes: 66 additions & 0 deletions context/lyrics_providers/lrcliblyricsprovider.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// Created by bartkk on 17.10.2025.
//

#include "lrcliblyricsprovider.h"

#include "network/networkaccessmanager.h"

#include <QJsonDocument>
#include <QUrl>
#include <QUrlQuery>
#include <qjsonvalue.h>

void LRCLibLyricsProvider::fetchInfo(int id, Song metadata, bool removeThe)
{
(void)removeThe;

QUrl url("https://lrclib.net/api/get");

QUrlQuery query;
query.addQueryItem("track_name", QUrl::toPercentEncoding(metadata.title));
query.addQueryItem("artist_name", QUrl::toPercentEncoding(metadata.artist));
query.addQueryItem("track_duration", QString::number(metadata.time));
url.setQuery(query);

NetworkJob* reply = NetworkAccessManager::self()->get(url);
requests[reply] = id;
connect(reply, &NetworkJob::finished, this, &LRCLibLyricsProvider::lyricsFetched);
}

void LRCLibLyricsProvider::abort()
{
QHash<NetworkJob*, int>::ConstIterator it(requests.constBegin());
QHash<NetworkJob*, int>::ConstIterator end(requests.constEnd());

for (; it != end; ++it) {
it.key()->cancelAndDelete();
}
requests.clear();
}

LRCLibLyricsProvider::~LRCLibLyricsProvider()
{
LRCLibLyricsProvider::abort();
}

void LRCLibLyricsProvider::lyricsFetched()
{
NetworkJob* reply = qobject_cast<NetworkJob*>(sender());
if (!reply) {
return;
}

int id = requests.take(reply);
reply->deleteLater();

auto replyData = reply->readAll();
auto json = QJsonDocument::fromJson(replyData);

if (reply->error() == QNetworkReply::NoError) {
auto lyrics = json["plainLyrics"].toString();
emit lyricsReady(id, lyrics);
} else {
emit lyricsReady(id, "");
}
}
21 changes: 21 additions & 0 deletions context/lyrics_providers/lrcliblyricsprovider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef CANTATA_LRCLIBLYRICSPROVIDER_H
#define CANTATA_LRCLIBLYRICSPROVIDER_H
#include "context/ultimatelyricsprovider.h"

class LRCLibLyricsProvider : public UltimateLyricsProvider {
public:
static void enableDebug();

QString displayName() const override { return "LRCLib.net"; }
void fetchInfo(int id, Song metadata, bool removeThe) override;
void abort() override;
~LRCLibLyricsProvider() override;

private Q_SLOTS:
void lyricsFetched();

private:
QHash<NetworkJob*, int> requests;
};

#endif//CANTATA_LRCLIBLYRICSPROVIDER_H
Loading