source: smplayer/trunk/src/youtube/retrieveyoutubeurl.h@ 165

Last change on this file since 165 was 165, checked in by Silvan Scherrer, 11 years ago

SMPlayer: update trunk to latest 0.8.7

File size: 2.8 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#ifndef _RETRIEVEYOUTUBEURL_
20#define _RETRIEVEYOUTUBEURL_
21
22#include <QNetworkAccessManager>
23#include <QNetworkReply>
24#include <QMap>
25
26#define YT_GET_VIDEOINFO
27
28class RetrieveYoutubeUrl : public QObject
29{
30 Q_OBJECT
31
32public:
33 enum Quality { FLV_240p = 5, MP4_360p = 18, MP4_720p = 22, FLV_360p = 34,
34 FLV_480p = 35, MP4_1080p = 37, WEBM_360p = 43,
35 WEBM_480p = 44, WEBM_720p = 45, WEBM_1080p = 46 };
36
37 RetrieveYoutubeUrl( QObject* parent = 0 );
38 ~RetrieveYoutubeUrl();
39
40 void fetchPage(const QString & url);
41 void close();
42
43 static void setUserAgent(const QString & s) { user_agent = s; };
44 static QString userAgent() { return user_agent; };
45
46 void setPreferredQuality(Quality q) { preferred_quality = q; }
47 Quality preferredQuality() { return preferred_quality; }
48
49 static QString findPreferredUrl(const QMap<int, QString>& urlMap, Quality q);
50 QString findPreferredUrl();
51
52 QString urlTitle() { return url_title; }
53 QString latestPreferredUrl() { return latest_preferred_url; }
54 QString origUrl() { return orig_url; }
55
56 bool isUrlSupported(const QString & url);
57 QString fullUrl(const QString & url);
58
59signals:
60 void gotUrls(const QMap<int, QString>&);
61 void gotPreferredUrl(const QString &);
62 void gotEmptyList();
63
64 void connecting(QString host);
65 void errorOcurred(int error_number, QString error_str);
66
67 void signatureNotFound(const QString & title);
68
69protected slots:
70 void gotResponse();
71 void parse(QByteArray text);
72#ifdef YT_GET_VIDEOINFO
73 void gotVideoInfoResponse();
74 void parseVideoInfo(QByteArray text);
75 void fetchVideoInfoPage();
76#endif
77
78protected:
79 static QString sanitizeForUnicodePoint(QString string);
80 static void htmlDecode(QString& string);
81 QString getVideoID(QString video_url);
82
83 QMap<int, QString> urlMap;
84 QString url_title;
85 QString orig_url;
86 QString latest_preferred_url;
87
88 Quality preferred_quality;
89 static QString user_agent;
90
91#ifdef YT_GET_VIDEOINFO
92 QString video_id;
93#endif
94
95private:
96 QNetworkAccessManager* manager;
97 QNetworkReply* reply;
98};
99
100#endif
Note: See TracBrowser for help on using the repository browser.