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 {
35 const QString & title() const { return m_title; }
36 void setTitle( QString title ) { m_title = title; }
38 const QString & description() const { return m_description; }
39 void setDescription( QString description ) { m_description = description; }
41 const QString & author() const { return m_author; }
42 void setAuthor( QString author ) { m_author = author; }
44 const QString & userId() const { return m_userId; }
45 void setUserId( QString userId ) { m_userId = userId; }
47 const QUrl & webpage() const { return m_webpage; }
48 void setWebpage(QUrl webpage);
51 const QPixmap & thumbnail() const { return m_thumbnail; }
53 const QString & thumbnailUrl() { return m_thumbnailUrl; }
54 void setThumbnailUrl(QString url) { m_thumbnailUrl = url; }
56 void loadMediumThumbnail();
57 const QString & mediumThumbnailUrl() { return m_mediumThumbnailUrl; }
58 void setMediumThumbnailUrl(QString url) { m_mediumThumbnailUrl = url; }
60 int duration() const { return m_duration; }
61 void setDuration( int duration ) { m_duration = duration; }
62 QString formattedDuration() const;
64 int viewCount() const { return m_viewCount; }
65 void setViewCount( int viewCount ) { m_viewCount = viewCount; }
67 const QDateTime & published() const { return m_published; }
68 void setPublished( QDateTime published ) { m_published = published; }
70 int getDefinitionCode() const { return definitionCode; }
73 const QUrl & getStreamUrl() { return m_streamUrl; }
75 void setId(QString id) { videoId = id; }
76 const QString & id() const { return videoId; }
80 void gotMediumThumbnail(QByteArray bytes);
81 void gotStreamUrl(QUrl streamUrl);
82 void errorStreamUrl(QString message);
85 void setThumbnail(QByteArray bytes);
86 void gotVideoInfo(QByteArray);
87 void errorVideoInfo(QNetworkReply*);
88 void scrapeWebPage(QByteArray);
89 void gotHeadHeaders(QNetworkReply*);
93 void findVideoUrl(int definitionCode);
94 void foundVideoUrl(QString videoToken, int definitionCode);
95 void parseFmtUrlMap(QString fmtUrlMap, bool fromWebPage = false);
98 QString m_description;
104 QString m_thumbnailUrl;
105 QString m_mediumThumbnailUrl;
107 QDateTime m_published;
114 // current index for the elTypes list
115 // needed to iterate on elTypes
118 bool loadingStreamUrl;
121 // This is required in order to use QPointer<Video> as a QVariant
122 // as used by the Model/View playlist
123 typedef QPointer<Video> VideoPointer;
124 Q_DECLARE_METATYPE(VideoPointer)