[vlmc-devel] YouTube: Fix YouTube API changes.

Rohit Yadav git at videolan.org
Mon Jun 6 16:17:55 CEST 2011


vlmc | branch: master | Rohit Yadav <rohityadav89 at gmail.com> | Mon Jun  6 20:04:05 2011 +0530| [e8a3a914a80709becb02e5cc61269c9ac65cf80a] | committer: Rohit Yadav

YouTube: Fix YouTube API changes.

This patch fixes authentication http post url and couple of minor changes
recently introduced in YouTube APIs.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=e8a3a914a80709becb02e5cc61269c9ac65cf80a
---

 src/Services/YouTube/YouTubeAuthenticator.cpp |   17 ++---------------
 src/Services/YouTube/YouTubeAuthenticator.h   |    4 +---
 src/Services/YouTube/YouTubeUploader.cpp      |    5 +++--
 3 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/src/Services/YouTube/YouTubeAuthenticator.cpp b/src/Services/YouTube/YouTubeAuthenticator.cpp
index 76490c5..0ed6d95 100644
--- a/src/Services/YouTube/YouTubeAuthenticator.cpp
+++ b/src/Services/YouTube/YouTubeAuthenticator.cpp
@@ -65,7 +65,6 @@ void
 YouTubeAuthenticator::authInit()
 {
     m_isAuthenticated = false;
-    m_nick.clear();
     m_authString.clear();
     m_authError.clear();
 }
@@ -141,13 +140,6 @@ YouTubeAuthenticator::getAuthString()
     return m_authString;
 }
 
-
-const QString&
-YouTubeAuthenticator::getNick()
-{
-    return m_nick;
-}
-
 void
 YouTubeAuthenticator::setCredentials( const QString& username, const QString& password )
 {
@@ -161,7 +153,7 @@ YouTubeAuthenticator::setPOSTData()
 {
     m_postData.clear();
     m_postData += QString("accountType=HOSTED_OR_GOOGLE&Email=%1&Passwd=%2"
-                          "&service=youtube&source=VLMC").arg(m_username, m_password);
+                          "&service=youtube&source=VLMC").arg( m_username, m_password );
 }
 
 void
@@ -192,14 +184,9 @@ YouTubeAuthenticator::setAuthData( QByteArray& data )
             m_authString = tokenList.at(1);
             continue;
         }
-
-        if( tokenList.at(0) == "YouTubeUser" )
-        {
-            m_nick = tokenList.at(1);
-        }
     }
 
-    if( !m_authString.isEmpty() && !m_nick.isEmpty() && m_authError.isEmpty() )
+    if( !m_authString.isEmpty() && m_authError.isEmpty() )
         m_isAuthenticated = true;
 
     emit authOver();
diff --git a/src/Services/YouTube/YouTubeAuthenticator.h b/src/Services/YouTube/YouTubeAuthenticator.h
index df7ed96..ad9bde4 100644
--- a/src/Services/YouTube/YouTubeAuthenticator.h
+++ b/src/Services/YouTube/YouTubeAuthenticator.h
@@ -25,7 +25,7 @@
 
 #include <QObject>
 
-#define LOGIN_URL "https://www.google.com/youtube/accounts/ClientLogin"
+#define LOGIN_URL "https://www.google.com/accounts/ClientLogin"
 
 class QByteArray;
 class QNetworkAccessManager;
@@ -46,7 +46,6 @@ class YouTubeAuthenticator : public QObject
         bool  isAuthenticated();
 
         const QString& getAuthString();
-        const QString& getNick();
 
         void  setServiceProvider( YouTubeService* service );
         void  setCredentials( const QString& username, const QString& password );
@@ -70,7 +69,6 @@ class YouTubeAuthenticator : public QObject
 
         /* Youtube tokens */
         QString                m_authString;
-        QString                m_nick;
         bool                   m_isAuthenticated;
         QString                m_authError;
 
diff --git a/src/Services/YouTube/YouTubeUploader.cpp b/src/Services/YouTube/YouTubeUploader.cpp
index 260c508..22539d9 100644
--- a/src/Services/YouTube/YouTubeUploader.cpp
+++ b/src/Services/YouTube/YouTubeUploader.cpp
@@ -85,7 +85,7 @@ YouTubeUploader::uploadInit()
         "    <media:description type='plain'>%2</media:description>\r\n"  // 2 description
         "    <media:category scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>%3\r\n" // 3 category
         "    </media:category>\r\n"
-        "    <media:keywords>%4</media:keywords>\r\n%5"                   // 4 key words, 5 private video                                                        // 5 isPrivate
+        "    <media:keywords>%4</media:keywords>\r\n%5"                   // 4 key words, 5 private video
         "  </media:group>\r\n"
         "</entry>\r\n";
 
@@ -136,6 +136,7 @@ YouTubeUploader::uploadFinished()
     QNetworkReply *reply = static_cast<QNetworkReply *>( sender() );
     const QByteArray data = reply->readAll();
 
+    qDebug() << "In YouTubeUploader::uploadFinished: data received = " << data; 
     m_service->m_state = UploadFinish;
 
     /* Feed parser called to parse the XML data received */
@@ -205,7 +206,7 @@ YouTubeUploader::getMimeHead()
     data.append( "Content-Type: application/atom+xml; charset=UTF-8\r\n\r\n" );
     data.append( API_XML_REQUEST );
     data.append( "--" + m_boundary + "\r\n" );
-    data.append( "Content-Type: video/*\r\nContent-Transfer-Encoding: binary\r\n\r\n" );
+    data.append( "Content-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" );
 
     return data;
 }



More information about the Vlmc-devel mailing list