]> git.sur5r.net Git - minitube/commitdiff
Support YouTube author display names
authorFlavio <flavio@odisseo.local>
Tue, 11 Dec 2012 08:56:11 +0000 (09:56 +0100)
committerFlavio <flavio@odisseo.local>
Tue, 11 Dec 2012 08:56:11 +0000 (09:56 +0100)
src/video.cpp
src/video.h
src/youtubestreamreader.cpp

index 42c5efa3bb08518b2a02ee8fc70c966b2d6831d4..4b8e247280ee1057654407c657b138584114e7bd 100644 (file)
@@ -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;
index c7b01651fcd874653e7a86c8530917e87cd475a4..d48a848c47ce93e8946d840066f05badb05a75da 100644 (file)
@@ -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;
index 9869da758632c0e7e640fb03acc68edc87900a71..78a9675bc2dd4d06df35b6eae390bc0487ffe36f 100644 (file)
@@ -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") {