3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Minitube. If not, see <http://www.gnu.org/licenses/>.
25 #if QT_VERSION >= 0x050000
30 class Video : public QObject {
43 const QString & title() const { return m_title; }
44 void setTitle( QString title ) { m_title = title; }
46 const QString & description() const { return m_description; }
47 void setDescription( QString description ) { m_description = description; }
49 const QString & author() const { return m_author; }
50 void setAuthor( QString author ) { m_author = author; }
52 const QString & userId() const { return m_userId; }
53 void setUserId( QString userId ) { m_userId = userId; }
55 const QUrl & webpage() const { return m_webpage; }
56 void setWebpage(QUrl webpage);
59 const QPixmap & thumbnail() const { return m_thumbnail; }
61 const QString & thumbnailUrl() { return m_thumbnailUrl; }
62 void setThumbnailUrl(QString url) { m_thumbnailUrl = url; }
64 void loadMediumThumbnail();
65 const QString & mediumThumbnailUrl() { return m_mediumThumbnailUrl; }
66 void setMediumThumbnailUrl(QString url) { m_mediumThumbnailUrl = url; }
68 int duration() const { return m_duration; }
69 void setDuration( int duration ) { m_duration = duration; }
70 QString formattedDuration() const;
72 int viewCount() const { return m_viewCount; }
73 void setViewCount( int viewCount ) { m_viewCount = viewCount; }
75 const QDateTime & published() const { return m_published; }
76 void setPublished( QDateTime published ) { m_published = published; }
78 int getDefinitionCode() const { return definitionCode; }
81 const QUrl & getStreamUrl() { return m_streamUrl; }
83 void setId(QString id) { videoId = id; }
84 const QString & id() const { return videoId; }
86 void setLicense(License license) { m_license = license; }
87 License license() const { return m_license; }
91 void gotMediumThumbnail(QByteArray bytes);
92 void gotStreamUrl(QUrl streamUrl);
93 void errorStreamUrl(QString message);
96 void setThumbnail(QByteArray bytes);
97 void gotVideoInfo(QByteArray);
98 void errorVideoInfo(QNetworkReply*);
99 void scrapeWebPage(QByteArray);
100 void parseJsPlayer(QByteArray bytes);
101 void parseDashManifest(QByteArray bytes);
105 void foundVideoUrl(QString videoToken, int definitionCode);
106 void parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage = false);
107 void captureFunction(const QString &name, const QString &js);
108 void captureObject(const QString &name, const QString &js);
109 QString decryptSignature(const QString &s);
112 QString m_description;
118 QString m_thumbnailUrl;
119 QString m_mediumThumbnailUrl;
121 QDateTime m_published;
128 // current index for the elTypes list
129 // needed to iterate on elTypes
133 bool loadingStreamUrl;
134 bool loadingThumbnail;
138 QHash<QString, QString> sigFunctions;
139 QHash<QString, QString> sigObjects;
141 QString dashManifestUrl;
144 // This is required in order to use QPointer<Video> as a QVariant
145 // as used by the Model/View playlist
146 typedef QPointer<Video> VideoPointer;
147 Q_DECLARE_METATYPE(VideoPointer)