]> git.sur5r.net Git - minitube/blobdiff - src/video.h
Merge commit 'refs/merge-requests/4' of git://gitorious.org/minitube/minitube
[minitube] / src / video.h
index 81e07346ca24a2e505b27eaf45bcd3b375eb4f00..68a17f542f0ef08420524983df0adbe445e7b163 100644 (file)
@@ -10,6 +10,7 @@ class Video : public QObject {
 
 public:
     Video();
+    Video* clone();
 
     const QString title() const { return m_title; }
     void setTitle( QString title ) { m_title = title; }
@@ -23,12 +24,6 @@ public:
     const QUrl webpage() const { return m_webpage; }
     void setWebpage( QUrl webpage ) { m_webpage = webpage; }
 
-    void loadStreamUrl() {
-        if (m_streamUrl.isEmpty())
-            this->scrapeStreamUrl();
-        else emit gotStreamUrl(m_streamUrl);
-    }
-
     QList<QUrl> thumbnailUrls() const { return m_thumbnailUrls; }
     void addThumbnailUrl(QUrl url) {
         m_thumbnailUrls << url;
@@ -46,28 +41,39 @@ public:
     const QDateTime published() const { return m_published; }
     void setPublished( QDateTime published ) { m_published = published; }
 
+    bool getDefinitionCode() const { return definitionCode; }
+
+    void loadStreamUrl();
+    QUrl getStreamUrl() { return m_streamUrl; }
+
+    QString id() { return videoId; }
+
 public slots:
     void setThumbnail(QByteArray bytes);
 
 signals:
     void gotThumbnail();
     void gotStreamUrl(QUrl streamUrl);
+    void errorStreamUrl(QString message);
 
 private slots:
     void gotVideoInfo(QByteArray);
+    void errorVideoInfo(QNetworkReply*);
+    void scrapeWebPage(QByteArray);
+    void gotHeadHeaders(QNetworkReply*);
 
 private:
-    void scrapeStreamUrl();
+    void getVideoInfo();
+    void findVideoUrl(int definitionCode);
+    void foundVideoUrl(QString videoToken, int definitionCode);
 
     QString m_title;
     QString m_description;
     QString m_author;
-    // QUrl m_authorUrl;
     QUrl m_webpage;
     QUrl m_streamUrl;
     QImage m_thumbnail;
     QList<QUrl> m_thumbnailUrls;
-    // QList<QImage> m_thumbnails;
     int m_duration;
     QDateTime m_published;
     int m_viewCount;
@@ -75,6 +81,15 @@ private:
     // The YouTube video id
     // This is needed by the gotVideoInfo callback
     QString videoId;
+
+    QString videoToken;
+    int definitionCode;
+
+    // current index for the elTypes list
+    // needed to iterate on elTypes
+    int elIndex;
+    
+    bool loadingStreamUrl;
 };
 
 // This is required in order to use QPointer<Video> as a QVariant