+/* $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
public:
Video();
+ Video* clone();
+
+ enum License {
+ LicenseYouTube = 1,
+ LicenseCC
+ };
- const QString title() const { return m_title; }
+ const QString & title() const { return m_title; }
void setTitle( QString title ) { m_title = title; }
- const QString description() const { return m_description; }
+ const QString & description() const { return m_description; }
void setDescription( QString description ) { m_description = description; }
- const QString author() const { return m_author; }
+ const QString & author() const { return m_author; }
void setAuthor( QString author ) { m_author = author; }
- const QUrl webpage() const { return m_webpage; }
- void setWebpage( QUrl webpage ) { m_webpage = webpage; }
+ const QString & userId() const { return m_userId; }
+ void setUserId( QString userId ) { m_userId = userId; }
- void loadStreamUrl() {
- if (m_streamUrl.isEmpty())
- this->scrapeStreamUrl();
- else emit gotStreamUrl(m_streamUrl);
- }
+ const QUrl & webpage() const { return m_webpage; }
+ void setWebpage(QUrl webpage);
- QList<QUrl> thumbnailUrls() const { return m_thumbnailUrls; }
- void addThumbnailUrl(QUrl url) {
- m_thumbnailUrls << url;
- }
+ void loadThumbnail();
+ const QPixmap & thumbnail() const { return m_thumbnail; }
- void preloadThumbnail();
- const QImage thumbnail() const;
+ const QString & thumbnailUrl() { return m_thumbnailUrl; }
+ void setThumbnailUrl(QString url) { m_thumbnailUrl = url; }
+
+ void loadMediumThumbnail();
+ const QString & mediumThumbnailUrl() { return m_mediumThumbnailUrl; }
+ void setMediumThumbnailUrl(QString url) { m_mediumThumbnailUrl = url; }
int duration() const { return m_duration; }
void setDuration( int duration ) { m_duration = duration; }
+ QString formattedDuration() const;
int viewCount() const { return m_viewCount; }
void setViewCount( int viewCount ) { m_viewCount = viewCount; }
- const QDateTime published() const { return m_published; }
+ const QDateTime & published() const { return m_published; }
void setPublished( QDateTime published ) { m_published = published; }
-public slots:
- void setThumbnail(QByteArray bytes);
+ int getDefinitionCode() const { return definitionCode; }
+
+ void loadStreamUrl();
+ const QUrl & getStreamUrl() { return m_streamUrl; }
+
+ void setId(QString id) { videoId = id; }
+ const QString & id() const { return videoId; }
+
+ void setLicense(License license) { m_license = license; }
+ License license() const { return m_license; }
signals:
void gotThumbnail();
+ void gotMediumThumbnail(QByteArray bytes);
void gotStreamUrl(QUrl streamUrl);
- void errorStreamUrl();
+ void errorStreamUrl(QString message);
private slots:
+ void setThumbnail(QByteArray bytes);
void gotVideoInfo(QByteArray);
+ void errorVideoInfo(QNetworkReply*);
+ void scrapeWebPage(QByteArray);
+ void gotHeadHeaders(QNetworkReply*);
+ void parseJsPlayer(QByteArray);
private:
- void scrapeStreamUrl();
+ void getVideoInfo();
+ void findVideoUrl(int definitionCode);
+ void foundVideoUrl(QString videoToken, int definitionCode);
+ void parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage = false);
+ void captureFunction(const QString &name, const QString &js);
+ void captureObject(const QString &name, const QString &js);
+ QString decryptSignature(const QString &s);
QString m_title;
QString m_description;
QString m_author;
- // QUrl m_authorUrl;
+ QString m_userId;
QUrl m_webpage;
QUrl m_streamUrl;
- QImage m_thumbnail;
- QList<QUrl> m_thumbnailUrls;
- // QList<QImage> m_thumbnails;
+ QPixmap m_thumbnail;
+ QString m_thumbnailUrl;
+ QString m_mediumThumbnailUrl;
int m_duration;
QDateTime m_published;
int m_viewCount;
-
- // The YouTube video id
- // This is needed by the gotVideoInfo callback
+ License m_license;
QString videoId;
+ QString videoToken;
+ int definitionCode;
+
+ // current index for the elTypes list
+ // needed to iterate on elTypes
+ int elIndex;
+ bool ageGate;
+
+ bool loadingStreamUrl;
+ bool loadingThumbnail;
+
+ QString fmtUrlMap;
+ QString sigFuncName;
+ QHash<QString, QString> sigFunctions;
+ QHash<QString, QString> sigObjects;
};
// This is required in order to use QPointer<Video> as a QVariant