From: Flavio Date: Tue, 11 Dec 2012 08:56:11 +0000 (+0100) Subject: Support YouTube author display names X-Git-Tag: 2.0~48 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1fe4c71707136fcaa9e87b31f0a0b97bac63fa0c;p=minitube Support YouTube author display names --- diff --git a/src/video.cpp b/src/video.cpp index 42c5efa..4b8e247 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -19,6 +19,7 @@ Video* Video::clone() { cloneVideo->m_title = m_title; cloneVideo->m_description = m_description; cloneVideo->m_author = m_author; + cloneVideo->m_authorUri = m_authorUri; cloneVideo->m_webpage = m_webpage; cloneVideo->m_streamUrl = m_streamUrl; cloneVideo->m_thumbnail = m_thumbnail; diff --git a/src/video.h b/src/video.h index c7b0165..d48a848 100644 --- a/src/video.h +++ b/src/video.h @@ -21,6 +21,9 @@ public: const QString author() const { return m_author; } void setAuthor( QString author ) { m_author = author; } + const QString authorUri() const { return m_authorUri; } + void setAuthorUri( QString authorUri ) { m_authorUri = authorUri; } + const QUrl webpage() const { return m_webpage; } void setWebpage( QUrl webpage ) { m_webpage = webpage; } @@ -70,6 +73,7 @@ private: QString m_title; QString m_description; QString m_author; + QString m_authorUri; QUrl m_webpage; QUrl m_streamUrl; QImage m_thumbnail; diff --git a/src/youtubestreamreader.cpp b/src/youtubestreamreader.cpp index 9869da7..78a9675 100644 --- a/src/youtubestreamreader.cpp +++ b/src/youtubestreamreader.cpp @@ -57,22 +57,23 @@ void YouTubeStreamReader::readEntry() { ) { QString webpage = attributes().value("href").toString(); webpage.remove("&feature=youtube_gdata"); - // qDebug() << "Webpage: " << webpage; video->setWebpage(QUrl(webpage)); - } else if (name() == "author") { - readNext(); - if (name() == "name") { - QString author = readElementText(); - // qDebug() << "Author: " << author; - video->setAuthor(author); - } + while(readNextStartElement()) + if (name() == "name") { + QString author = readElementText(); + video->setAuthor(author); + } else if (name() == "uri") { + QString uri = readElementText(); + int i = uri.lastIndexOf('/'); + if (i != -1) uri = uri.mid(i+1); + video->setAuthorUri(uri); + } else skipCurrentElement(); } else if (name() == "published") { video->setPublished(QDateTime::fromString(readElementText(), Qt::ISODate)); - } else if (namespaceUri() == "http://gdata.youtube.com/schemas/2007" && name() == "statistics") { - + } else if (namespaceUri() == "http://gdata.youtube.com/schemas/2007" + && name() == "statistics") { QString viewCount = attributes().value("viewCount").toString(); - // qDebug() << "viewCount: " << viewCount; video->setViewCount(viewCount.toInt()); } else if (namespaceUri() == "http://search.yahoo.com/mrss/" && name() == "group") {