]> git.sur5r.net Git - minitube/blob - src/video.h
2702d7ae3f814e1e7635a4cdfbf1fbd3e2bf21be
[minitube] / src / video.h
1 #ifndef VIDEO_H
2 #define VIDEO_H
3
4 #include <QtGui>
5 #include <QtNetwork>
6
7 class Video : public QObject {
8
9     Q_OBJECT
10
11 public:
12     Video();
13
14     const QString title() const { return m_title; }
15     void setTitle( QString title ) { m_title = title; }
16
17     const QString description() const { return m_description; }
18     void setDescription( QString description ) { m_description = description; }
19
20     const QString author() const { return m_author; }
21     void setAuthor( QString author ) { m_author = author; }
22
23     const QUrl webpage() const { return m_webpage; }
24     void setWebpage( QUrl webpage ) { m_webpage = webpage; }
25
26     QList<QUrl> thumbnailUrls() const { return m_thumbnailUrls; }
27     void addThumbnailUrl(QUrl url) {
28         m_thumbnailUrls << url;
29     }
30
31     void preloadThumbnail();
32     const QImage thumbnail() const;
33
34     int duration() const { return m_duration; }
35     void setDuration( int duration ) { m_duration = duration; }
36
37     int viewCount() const { return m_viewCount; }
38     void setViewCount( int viewCount ) { m_viewCount = viewCount; }
39
40     const QDateTime published() const { return m_published; }
41     void setPublished( QDateTime published ) { m_published = published; }
42
43     bool getDefinitionCode() const { return definitionCode; }
44
45     void loadStreamUrl();
46     QUrl getStreamUrl() { return m_streamUrl; }
47
48 public slots:
49     void setThumbnail(QByteArray bytes);
50
51 signals:
52     void gotThumbnail();
53     void gotStreamUrl(QUrl streamUrl);
54     void errorStreamUrl(QString message);
55
56 private slots:
57     void gotVideoInfo(QByteArray);
58     void errorVideoInfo(QNetworkReply*);
59     void scrapeWebPage(QByteArray);
60     void gotHeadHeaders(QNetworkReply*);
61
62 private:
63     void getVideoInfo();
64     void findVideoUrl(int definitionCode);
65     void foundVideoUrl(QString videoToken, int definitionCode);
66
67     QString m_title;
68     QString m_description;
69     QString m_author;
70     QUrl m_webpage;
71     QUrl m_streamUrl;
72     QImage m_thumbnail;
73     QList<QUrl> m_thumbnailUrls;
74     int m_duration;
75     QDateTime m_published;
76     int m_viewCount;
77
78     // The YouTube video id
79     // This is needed by the gotVideoInfo callback
80     QString videoId;
81
82     QString videoToken;
83     int definitionCode;
84
85     // current index for the elTypes list
86     // needed to iterate on elTypes
87     int elIndex;
88 };
89
90 // This is required in order to use QPointer<Video> as a QVariant
91 // as used by the Model/View playlist
92 typedef QPointer<Video> VideoPointer;
93 Q_DECLARE_METATYPE(VideoPointer)
94
95 #endif // VIDEO_H