]> git.sur5r.net Git - minitube/blob - src/video.h
New upstream version 3.9.1
[minitube] / src / video.h
1 /* $BEGIN_LICENSE
2
3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
5
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.
10
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.
15
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/>.
18
19 $END_LICENSE */
20
21 #ifndef VIDEO_H
22 #define VIDEO_H
23
24 #include <QtCore>
25 #include <QtGui>
26
27 #include "ytthumb.h"
28
29 class YTVideo;
30 class YTJSVideo;
31 class VariantPromise;
32
33 class Video : public QObject {
34     Q_OBJECT
35
36 public:
37     Video();
38     ~Video();
39     Video *clone();
40
41     enum License { LicenseYouTube = 1, LicenseCC };
42     Q_ENUM(License)
43
44     const QString &getTitle() const { return title; }
45     void setTitle(const QString &value) { title = value; }
46
47     const QString &getDescription() const { return description; }
48     void setDescription(const QString &value) { description = value; }
49
50     const QString &getChannelTitle() const { return channelTitle; }
51     void setChannelTitle(const QString &value) { channelTitle = value; }
52
53     const QString &getChannelId() const { return channelId; }
54     void setChannelId(const QString &value) { channelId = value; }
55
56     const QString &getWebpage();
57     void setWebpage(const QString &value);
58
59     int getDuration() const { return duration; }
60     void setDuration(int value);
61     const QString &getFormattedDuration() const { return formattedDuration; }
62
63     int getViewCount() const { return viewCount; }
64     void setViewCount(int value);
65     const QString &getFormattedViewCount() const { return formattedViewCount; }
66
67     const QDateTime &getPublished() const { return published; }
68     void setPublished(const QDateTime &value);
69     const QString &getFormattedPublished() const { return formattedPublished; }
70
71     int getDefinitionCode() const { return definitionCode; }
72
73     void loadStreamUrl();
74     const QString &getStreamUrl() { return streamUrl; }
75     bool isLoadingStreamUrl() const;
76     void abortLoadStreamUrl();
77
78     const QString &getId() const { return id; }
79     void setId(const QString &value) { id = value; }
80
81     License getLicense() const { return license; }
82     void setLicense(License value) { license = value; }
83
84     const auto &getThumbs() const { return thumbs; }
85     void addThumb(int width, int height, QString url);
86     VariantPromise &loadThumb(QSize size, qreal pixelRatio);
87
88 signals:
89     void gotStreamUrl(const QString &videoUrl, const QString &audioUrl);
90     void errorStreamUrl(const QString &message);
91     void changed();
92
93 private slots:
94     void streamUrlLoaded(const QString &streamUrl, const QString &audioUrl);
95
96 private:
97     void loadStreamUrlJS();
98     void loadStreamUrlYT();
99
100     QString title;
101     QString description;
102     QString channelTitle;
103     QString channelId;
104     QString webpage;
105     QString streamUrl;
106     int duration;
107     QString formattedDuration;
108
109     QDateTime published;
110     QString formattedPublished;
111     int viewCount;
112     QString formattedViewCount;
113     License license;
114     QString id;
115     int definitionCode;
116
117     YTVideo *ytVideo;
118     YTJSVideo *ytjsVideo;
119
120     QVector<YTThumb> thumbs;
121     bool thumbsNeedSorting = false;
122 };
123
124 // This is required in order to use QPointer<Video> as a QVariant
125 // as used by the Model/View playlist
126 typedef QPointer<Video> VideoPointer;
127 Q_DECLARE_METATYPE(VideoPointer)
128
129 #endif // VIDEO_H