Image 01
profile-image

RausD

Ralf B
Audex

Utilities by marcomaniac 232 comments

for all who still use audex and want to repair the cover fetcher after things changed again on Google's side, here's my actual CoverFetcher::parse_html_response:
*********************************
void CoverFetcher::parse_html_response(const QString& xml) {

cover_urls_thumbnails.clear();
cover_urls.clear();
cover_names.clear();
cover_tbnids.clear();
cover_thumbnails.clear();

/* QRegExp rx("<a\\shref=\"(\\/imgres\\?imgurl=[^\"]+)\">[\\s\\n]*<img[^>]+src=\"([^>]+)\"></a>"); */
QRegExp rx("<a\\shref=\"(\\/url\\?q=[^\"]+)\"><img[^>]+height=\"\\d+\"\\s*src=\"([^>]+)\"\\s*width=\"\\d+\"></a>\.*([345]\\d\\d)\\s*&times;\\s*(\\d*)\\s*-\\s*(\\d*)\\s*\\w\\w");
/* qDebug() << xml; */
/* QString html = xml; */
/* html.replace(QLatin1String("&amp;"), QLatin1String("&")); */
rx.setMinimal(TRUE);

int pos = 0; int i = 0;
/* while (((pos = rx.indexIn(html, pos)) != -1) && (i < fetch_no)) { */
while (((pos = rx.indexIn(xml, pos)) != -1) && (i < fetch_no)) {

/* KUrl url("http://www.google.com"+rx.cap(1));
cover_urls << url.queryItemValue("imgurl");
QString w = url.queryItemValue("w");
QString h = url.queryItemValue("h");
QString sz = url.queryItemValue("sz");
cover_names << i18n("%1x%2, %3 KiB", w, h, sz);
cover_tbnids << url.queryItemValue("tbnid"); */

cover_urls << rx.cap(2);
QString w = rx.cap(3);
QString h = rx.cap(4);
QString sz = rx.cap(5);
cover_names << i18n("%1x%2, %3 KiB", w, h, sz);

if (!rx.cap(2).isEmpty()) {
cover_urls_thumbnails << rx.cap(2);
} else {
cover_urls_thumbnails << cover_urls.last();
}

pos += rx.matchedLength();

++i;

}

}
***************************************** - Jan 05 2014
Audex

Utilities by marcomaniac 232 comments

despite my limited programming knowledege I finally managed to get it working. This is what I changed in utils/coverfetcher.cpp (beginning at line 165):

**************************
QRegExp rx("<a\\shref=\"(\\/imgres\\?imgurl=[^\"]+)\">[\\s\\n]*<img\\ssrc=\"([^\\s>]+)\"[^>]+>[\\s\\n]*</a>");
QString html = xml;
html.replace( QLatin1String("&amp;"), QLatin1String("&") );

rx.setMinimal(TRUE);

int pos = 0; int i = 0;
while (((pos = rx.indexIn(html, pos)) != -1) && (i < fetch_no)) {
**************************

Works perfectly for me. Apparently the queryItemValue method of KUrl doesn't like the "&amp;" representation of ampersant characters. - Jul 12 2011