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/>.
27 class Video : public QObject {
40 const QString & title() const { return m_title; }
41 void setTitle( QString title ) { m_title = title; }
43 const QString & description() const { return m_description; }
44 void setDescription( QString description ) { m_description = description; }
46 const QString & author() const { return m_author; }
47 void setAuthor( QString author ) { m_author = author; }
49 const QString & userId() const { return m_userId; }
50 void setUserId( QString userId ) { m_userId = userId; }
52 const QUrl & webpage() const { return m_webpage; }
53 void setWebpage(QUrl webpage);
56 const QPixmap & thumbnail() const { return m_thumbnail; }
58 const QString & thumbnailUrl() { return m_thumbnailUrl; }
59 void setThumbnailUrl(QString url) { m_thumbnailUrl = url; }
61 void loadMediumThumbnail();
62 const QString & mediumThumbnailUrl() { return m_mediumThumbnailUrl; }
63 void setMediumThumbnailUrl(QString url) { m_mediumThumbnailUrl = url; }
65 int duration() const { return m_duration; }
66 void setDuration( int duration ) { m_duration = duration; }
67 QString formattedDuration() const;
69 int viewCount() const { return m_viewCount; }
70 void setViewCount( int viewCount ) { m_viewCount = viewCount; }
72 const QDateTime & published() const { return m_published; }
73 void setPublished( QDateTime published ) { m_published = published; }
75 int getDefinitionCode() const { return definitionCode; }
78 const QUrl & getStreamUrl() { return m_streamUrl; }
80 void setId(QString id) { videoId = id; }
81 const QString & id() const { return videoId; }
83 void setLicense(License license) { m_license = license; }
84 License license() const { return m_license; }
88 void gotMediumThumbnail(QByteArray bytes);
89 void gotStreamUrl(QUrl streamUrl);
90 void errorStreamUrl(QString message);
93 void setThumbnail(QByteArray bytes);
94 void gotVideoInfo(QByteArray);
95 void errorVideoInfo(QNetworkReply*);
96 void scrapeWebPage(QByteArray);
97 void gotHeadHeaders(QNetworkReply*);
98 void parseJsPlayer(QByteArray);
102 void findVideoUrl(int definitionCode);
103 void foundVideoUrl(QString videoToken, int definitionCode);
104 void parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage = false);
105 void captureFunction(const QString &name, const QString &js);
106 void captureObject(const QString &name, const QString &js);
107 QString decryptSignature(const QString &s);
110 QString m_description;
116 QString m_thumbnailUrl;
117 QString m_mediumThumbnailUrl;
119 QDateTime m_published;
126 // current index for the elTypes list
127 // needed to iterate on elTypes
131 bool loadingStreamUrl;
132 bool loadingThumbnail;
136 QHash<QString, QString> sigFunctions;
137 QHash<QString, QString> sigObjects;
140 // This is required in order to use QPointer<Video> as a QVariant
141 // as used by the Model/View playlist
142 typedef QPointer<Video> VideoPointer;
143 Q_DECLARE_METATYPE(VideoPointer)