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