]> git.sur5r.net Git - minitube/blobdiff - src/video.h
New upstream version 3.1
[minitube] / src / video.h
index 4b15e3738aacd6e7d40b3ab628f717c223700123..723be191d592764c0f6667d6431254dd4a59a96a 100644 (file)
+/* $BEGIN_LICENSE
+
+This file is part of Minitube.
+Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
+
+Minitube is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Minitube is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
+
+$END_LICENSE */
+
 #ifndef VIDEO_H
 #define VIDEO_H
 
+#include <QtCore>
 #include <QtGui>
-#include <QtNetwork>
 
-class Video : public QObject {
+class YTVideo;
 
+class Video : public QObject {
     Q_OBJECT
 
 public:
     Video();
-    Video* clone();
+    ~Video();
+    Video *clone();
+
+    enum License { LicenseYouTube = 1, LicenseCC };
+    Q_ENUM(License)
 
-    const QString title() const { return m_title; }
-    void setTitle( QString title ) { m_title = title; }
+    const QString &getTitle() const { return title; }
+    void setTitle(const QString &value) { title = value; }
 
-    const QString description() const { return m_description; }
-    void setDescription( QString description ) { m_description = description; }
+    const QString &getDescription() const { return description; }
+    void setDescription(const QString &value) { description = value; }
 
-    const QString author() const { return m_author; }
-    void setAuthor( QString author ) { m_author = author; }
+    const QString &getChannelTitle() const { return channelTitle; }
+    void setChannelTitle(const QString &value) { channelTitle = value; }
 
-    const QString authorUri() const { return m_authorUri; }
-    void setAuthorUri( QString authorUri ) { m_authorUri = authorUri; }
+    const QString &getChannelId() const { return channelId; }
+    void setChannelId(const QString &value) { channelId = value; }
 
-    const QUrl webpage() const { return m_webpage; }
-    void setWebpage(QUrl webpage);
+    const QString &getWebpage();
+    void setWebpage(const QString &value);
 
     void loadThumbnail();
-    const QPixmap & thumbnail() const { return m_thumbnail; }
+    const QPixmap &getThumbnail() const { return thumbnail; }
 
-    QString thumbnailUrl() { return m_thumbnailUrl; }
-    void setThumbnailUrl(QString url) { m_thumbnailUrl = url; }
+    const QString &getThumbnailUrl() const { return thumbnailUrl; }
+    void setThumbnailUrl(const QString &value) { thumbnailUrl = value; }
 
-    void loadMediumThumbnail();
-    QString mediumThumbnailUrl() { return m_mediumThumbnailUrl; }
-    void setMediumThumbnailUrl(QString url) { m_mediumThumbnailUrl = url; }
+    const QString &getMediumThumbnailUrl() const { return mediumThumbnailUrl; }
+    void setMediumThumbnailUrl(const QString &value) { mediumThumbnailUrl = value; }
 
-    int duration() const { return m_duration; }
-    void setDuration( int duration ) { m_duration = duration; }
-    QString formattedDuration() const;
+    const QString &getLargeThumbnailUrl() const { return largeThumbnailUrl; }
+    void setLargeThumbnailUrl(const QString &value) { largeThumbnailUrl = value; }
 
-    int viewCount() const { return m_viewCount; }
-    void setViewCount( int viewCount ) { m_viewCount = viewCount; }
+    int getDuration() const { return duration; }
+    void setDuration(int value);
+    const QString &getFormattedDuration() const { return formattedDuration; }
 
-    const QDateTime published() const { return m_published; }
-    void setPublished( QDateTime published ) { m_published = published; }
+    int getViewCount() const { return viewCount; }
+    void setViewCount(int value);
+    const QString &getFormattedViewCount() const { return formattedViewCount; }
+
+    const QDateTime &getPublished() const { return published; }
+    void setPublished(const QDateTime &value);
+    const QString &getFormattedPublished() const { return formattedPublished; }
 
     int getDefinitionCode() const { return definitionCode; }
 
     void loadStreamUrl();
-    QUrl getStreamUrl() { return m_streamUrl; }
+    const QString &getStreamUrl() { return streamUrl; }
+    bool isLoadingStreamUrl() const { return ytVideo != nullptr; }
+    void abortLoadStreamUrl();
+
+    const QString &getId() const { return id; }
+    void setId(const QString &value) { id = value; }
 
-    QString id() const { return videoId; }
+    License getLicense() const { return license; }
+    void setLicense(License value) { license = value; }
 
 signals:
     void gotThumbnail();
-    void gotMediumThumbnail(QByteArray bytes);
-    void gotStreamUrl(QUrl streamUrl);
-    void errorStreamUrl(QString message);
+    void gotMediumThumbnail(const QByteArray &bytes);
+    void gotLargeThumbnail(const QByteArray &bytes);
+    void gotStreamUrl(const QString &videoUrl, const QString &audioUrl);
+    void errorStreamUrl(const QString &message);
 
 private slots:
-    void setThumbnail(QByteArray bytes);
-    void gotVideoInfo(QByteArray);
-    void errorVideoInfo(QNetworkReply*);
-    void scrapeWebPage(QByteArray);
-    void gotHeadHeaders(QNetworkReply*);
+    void setThumbnail(const QByteArray &bytes);
+    void streamUrlLoaded(const QString &streamUrl, const QString &audioUrl);
 
 private:
-    void getVideoInfo();
-    void findVideoUrl(int definitionCode);
-    void foundVideoUrl(QString videoToken, int definitionCode);
-
-    QString m_title;
-    QString m_description;
-    QString m_author;
-    QString m_authorUri;
-    QUrl m_webpage;
-    QUrl m_streamUrl;
-    QPixmap m_thumbnail;
-    QString m_thumbnailUrl;
-    QString m_mediumThumbnailUrl;
-    int m_duration;
-    QDateTime m_published;
-    int m_viewCount;
-
-    QString videoId;
-    QString videoToken;
+    QString title;
+    QString description;
+    QString channelTitle;
+    QString channelId;
+    QString webpage;
+    QString streamUrl;
+    QPixmap thumbnail;
+    QString thumbnailUrl;
+    QString mediumThumbnailUrl;
+    QString largeThumbnailUrl;
+    int duration;
+    QString formattedDuration;
+
+    QDateTime published;
+    QString formattedPublished;
+    int viewCount;
+    QString formattedViewCount;
+    License license;
+    QString id;
     int definitionCode;
 
-    // current index for the elTypes list
-    // needed to iterate on elTypes
-    int elIndex;
-    
-    bool loadingStreamUrl;
+    bool loadingThumbnail;
+
+    YTVideo *ytVideo;
 };
 
 // This is required in order to use QPointer<Video> as a QVariant