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 VideoDefinition;
32 class Video : public QObject {
45 const QString & title() const { return m_title; }
46 void setTitle(const QString &title) { m_title = title; }
48 const QString & description() const { return m_description; }
49 void setDescription(const QString &description) { m_description = description; }
51 const QString & channelTitle() const { return m_channelTitle; }
52 void setChannelTitle(const QString &value) { m_channelTitle = value; }
54 const QString & channelId() const { return m_channelId; }
55 void setChannelId(const QString &value ) { m_channelId = value; }
57 const QString & webpage();
58 void setWebpage(const QString &value);
61 const QPixmap & thumbnail() const { return m_thumbnail; }
63 const QString & thumbnailUrl() { return m_thumbnailUrl; }
64 void setThumbnailUrl(const QString &url) { m_thumbnailUrl = url; }
66 void loadMediumThumbnail();
67 const QString & mediumThumbnailUrl() { return m_mediumThumbnailUrl; }
68 void setMediumThumbnailUrl(const QString &url) { m_mediumThumbnailUrl = url; }
70 int duration() const { return m_duration; }
71 void setDuration( int duration ) { m_duration = duration; }
72 QString formattedDuration() const;
74 int viewCount() const { return m_viewCount; }
75 void setViewCount( int viewCount ) { m_viewCount = viewCount; }
77 const QDateTime & published() const { return m_published; }
78 void setPublished(const QDateTime &published ) { m_published = published; }
80 int getDefinitionCode() const { return definitionCode; }
83 const QUrl & getStreamUrl() { return m_streamUrl; }
85 void setId(QString id) { videoId = id; }
86 const QString & id() const { return videoId; }
88 void setLicense(License license) { m_license = license; }
89 License license() const { return m_license; }
93 void gotMediumThumbnail(QByteArray bytes);
94 void gotStreamUrl(QUrl streamUrl);
95 void errorStreamUrl(QString message);
98 void setThumbnail(QByteArray bytes);
99 void gotVideoInfo(QByteArray);
100 void errorVideoInfo(QNetworkReply*);
101 void scrapeWebPage(QByteArray);
102 void parseJsPlayer(QByteArray bytes);
103 void parseDashManifest(QByteArray bytes);
107 void parseFmtUrlMap(const QString &fmtUrlMap, bool fromWebPage = false);
108 void captureFunction(const QString &name, const QString &js);
109 void captureObject(const QString &name, const QString &js);
110 QString decryptSignature(const QString &s);
111 void saveDefinitionForUrl(const QString& url, const VideoDefinition& definition);
114 QString m_description;
115 QString m_channelTitle;
120 QString m_thumbnailUrl;
121 QString m_mediumThumbnailUrl;
123 QDateTime m_published;
130 // current index for the elTypes list
131 // needed to iterate on elTypes
135 bool loadingStreamUrl;
136 bool loadingThumbnail;
140 QHash<QString, QString> sigFunctions;
141 QHash<QString, QString> sigObjects;
143 QString dashManifestUrl;
146 // This is required in order to use QPointer<Video> as a QVariant
147 // as used by the Model/View playlist
148 typedef QPointer<Video> VideoPointer;
149 Q_DECLARE_METATYPE(VideoPointer)