Skip to content

Commit

Permalink
Minor scraper and translation update
Browse files Browse the repository at this point in the history
  • Loading branch information
Komet committed Jan 20, 2015
1 parent a81c8fe commit a2e4b9e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 22 additions & 8 deletions scrapers/UniversalMusicScraper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ void UniversalMusicScraper::parseAndAssignTadbInfos(QString json, Album *album,
if (shouldLoad(MusicScraperInfos::Title, infos, album) && !sc.property("strAlbum").isNull() && !sc.property("strAlbum").toString().isEmpty())
album->setTitle(sc.property("strAlbum").toString());

if (shouldLoad(MusicScraperInfos::Artist, infos, album) && !sc.property("strArtist").isNull())
if (shouldLoad(MusicScraperInfos::Artist, infos, album) && !sc.property("strArtist").isNull() && !sc.property("strArtist").toString().isEmpty())
album->setArtist(sc.property("strArtist").toString());

if (shouldLoad(MusicScraperInfos::Rating, infos, album) && !sc.property("intScore").isNull())
Expand Down Expand Up @@ -742,7 +742,7 @@ void UniversalMusicScraper::parseAndAssignAmInfos(QString html, Album *album, QL
rx.setPattern("<h4>[\\n\\s]*Styles[\\n\\s]*</h4>[\\n\\s]*<div>(.*)</div>");
if (rx.indexIn(html) != -1) {
QString styles = rx.cap(1);
rx.setPattern("<a [^>]*>(.*)</a>");
rx.setPattern("<a [^>]*>([^<]*)</a>");
int pos = 0;
while ((pos = rx.indexIn(styles, pos)) != -1) {
album->addStyle(trim(rx.cap(1)));
Expand Down Expand Up @@ -783,15 +783,29 @@ void UniversalMusicScraper::parseAndAssignDiscogsInfos(QString html, Album *albu
}

if (shouldLoad(MusicScraperInfos::Genres, infos, album)) {
rx.setPattern("<div class=\"content\" itemprop=\"genre\">[\\n\\s]*<a href=\"[^\"]*\">(.*)</a>[\\n\\s]*</div>");
if (rx.indexIn(html) != -1)
album->addGenre(trim(rx.cap(1)));
rx.setPattern("<div class=\"content\" itemprop=\"genre\">[\\n\\s]*(.*)[\\n\\s]*</div>");
if (rx.indexIn(html) != -1) {
QString genres = rx.cap(1);
rx.setPattern("<a href=\"[^\"]*\">([^<]*)</a>");
int pos = 0;
while ((pos = rx.indexIn(genres, pos)) != -1) {
album->addGenre(trim(rx.cap(1)));
pos += rx.matchedLength();
}
}
}

if (shouldLoad(MusicScraperInfos::Styles, infos, album)) {
rx.setPattern("<div class=\"head\">Style:</div>[\\n\\s]*<div class=\"content\">[\\n\\s]*<a href=\"[^\"]*\">(.*)</a>[\\n\\s]*</div>");
if (rx.indexIn(html) != -1)
album->addStyle(trim(rx.cap(1)));
rx.setPattern("<div class=\"head\">Style:</div>[\\n\\s]*<div class=\"content\">[\\n\\s]*(.*)[\\n\\s]*</div>");
if (rx.indexIn(html) != -1) {
QString styles = rx.cap(1);
rx.setPattern("<a href=\"[^\"]*\">(.*)</a>");
int pos = 0;
while ((pos = rx.indexIn(styles, pos)) != -1) {
album->addStyle(trim(rx.cap(1)));
pos += rx.matchedLength();
}
}
}

if (shouldLoad(MusicScraperInfos::Year, infos, album)) {
Expand Down
2 changes: 1 addition & 1 deletion smallWidgets/MusicTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void MusicTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &optio
#endif
font.setBold(false);
painter->setFont(font);
painter->drawText(albumsRect, tr("%n album(s)", "", index.data(MusicRoles::NumOfAlbums).toInt()), QTextOption(Qt::AlignVCenter));
painter->drawText(albumsRect, tr("%n albums", "", index.data(MusicRoles::NumOfAlbums).toInt()), QTextOption(Qt::AlignVCenter));

QPoint lineStart(option.rect.x(), option.rect.y());
QPoint lineEnd(option.rect.x()+option.rect.width()-1, option.rect.y());
Expand Down

0 comments on commit a2e4b9e

Please sign in to comment.