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