[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdeplasma-addons/plasma/sreich/youtube-runner] runners/youtube: properly extract out the thumbnail
From:       Shaun Reich <shaun.reich () kdemail ! net>
Date:       2012-02-25 3:57:25
Message-ID: 20120225035725.23AADA60CD () git ! kde ! org
[Download RAW message or body]

Git commit 95f2af52ab7f557a0174fa68a2cf21eb51f47946 by Shaun Reich.
Committed on 25/02/2012 at 04:57.
Pushed by sreich into branch 'plasma/sreich/youtube-runner'.

properly extract out the thumbnail url. sort of

M  +20   -12   runners/youtube/youtube.cpp

http://commits.kde.org/kdeplasma-addons/95f2af52ab7f557a0174fa68a2cf21eb51f47946

diff --git a/runners/youtube/youtube.cpp b/runners/youtube/youtube.cpp
index e86bc90..fde1617 100644
--- a/runners/youtube/youtube.cpp
+++ b/runners/youtube/youtube.cpp
@@ -104,7 +104,9 @@ void YouTube::parseXML(QByteArray data)
         }
 
         if (token == QXmlStreamReader::StartElement) {
-            parseVideo(xml);
+            if (xml.name() == "group") {
+                parseVideo(xml);
+            }
         }
     }
 }
@@ -119,15 +121,21 @@ void YouTube::parseVideo(QXmlStreamReader& xml)
 
     kDebug() << "NAME: " << name;
 
-    if (name == "group") {
-        while (!xml.atEnd() && xml.tokenType() != QXmlStreamReader::EndDocument) {
-            kDebug() << "WHILE LOOP(((((((((((((((((()))))))))))))))))), name: " << xml.name();
+    QXmlStreamAttributes attributes = xml.attributes();
+    while (!xml.atEnd() && xml.tokenType() != QXmlStreamReader::EndDocument) {
+        kDebug() << "WHILE LOOP(((((((((((((((((()))))))))))))))))), name: " << xml.name();
 
-            QXmlStreamAttributes attributes = xml.attributes();
 
-            if (currentElement == "title") {
-                kDebug() << attributes.value("plain").toString();
-            }
+        kDebug() << "CURRENTELEMENT: " << currentElement;
+
+        if (xml.name() == "title") {
+            kDebug() << attributes.value("plain").toString();
+        }
+
+        if (xml.name() == "thumbnail") {
+            QStringRef attribute = attributes.value("url");
+            kDebug() << "ATTRIBUTE: " << attribute;
+        }
 //            if (name == "title") {
 //                kDebug() << "GOT TITLE: " << name;
 //                videoTitles.append(xml.readElementText());
@@ -143,10 +151,10 @@ void YouTube::parseVideo(QXmlStreamReader& xml)
 //                }
 //            }
 
-            xml.readNext();
-            currentElement = xml.readElementText();
-            kDebug() << currentElement;
-        }
+        xml.readNext();
+        attributes = xml.attributes();
+        currentElement = xml.readElementText();
+        kDebug() << currentElement;
     }
 
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic