C++ (Qt)void RetrieveVideoUrl::gotVideoPage(QNetworkReply *reply){ if(reply->error() != QNetworkReply::NoError) { emit errorOcurred(m_title, (int)reply->error()); return; } QByteArray arr = reply->readAll(); if(arr.isEmpty()) { fetchYTVideoPage(id, m_title); return; } QString replyString = QString::fromUtf8(arr.constData(), arr.size()); QRegExp regex("\\\"url_encoded_fmt_stream_map\\\"\\s*:\\s*\\\"([^\\\"]*)"); regex.indexIn(replyString); QString fmtArray = regex.cap(1); fmtArray = sanitizeForUnicodePoint(fmtArray); fmtArray.replace(QRegExp("\\\\(.)"), "\\1"); htmlDecode(fmtArray); QStringList codeList = fmtArray.split(','); foreach(QString code, codeList) { // (2012-12-20) Youtube Fix by RVM for SMPlayer (http://smplayer.sourceforge.net) /* qDebug("RetrieveYoutubeUrl::parse: code: '%s'", code.toLatin1().constData()); */ int itag = 0; QString n_url; QString url; QString s_itag; QStringList par_list = code.split(QRegExp("&|\\?")); foreach(QString par, par_list) { /* qDebug("RetrieveYoutubeUrl::parse: par: %s", par.toLatin1().constData()); */ if (par.startsWith("url=")) url = par.mid(4); else if (par.startsWith("itag=")) { if (s_itag.isEmpty()) { s_itag = par; QRegExp rx("itag=(\\d+)"); if (rx.indexIn(s_itag) != -1) itag = rx.cap(1).toInt(); /* qDebug("RetrieveYoutubeUrl::parse: itag: %d", itag); */ } } else { if (!n_url.isEmpty()) n_url += "&"; n_url += par; } } n_url = url + "?" + s_itag + "&" + n_url; n_url.replace("&sig=", "&signature="); /* qDebug("RetrieveYoutubeUrl::parse: n_url: '%s'", n_url.toLatin1().constData()); */ urlMap[itag] = n_url; } emit gotUrls(urlMap, m_title, id); }