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

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

SMPlayer: update trunk to 0.8.6

File size: 2.5 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 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
26class RetrieveYoutubeUrl : public QObject
27{
28 Q_OBJECT
29
30public:
31 enum Quality { FLV_240p = 5, MP4_360p = 18, MP4_720p = 22, FLV_360p = 34,
32 FLV_480p = 35, MP4_1080p = 37, WEBM_360p = 43,
33 WEBM_480p = 44, WEBM_720p = 45, WEBM_1080p = 46 };
34
35 RetrieveYoutubeUrl( QObject* parent = 0 );
36 ~RetrieveYoutubeUrl();
37
38 void fetchPage(const QString & url);
39 void close();
40
41 void setUserAgent(const QString & s) { user_agent = s; };
42 QString userAgent() { return user_agent; };
43
44 void setPreferredQuality(Quality q) { preferred_quality = q; }
45 Quality preferredQuality() { return preferred_quality; }
46
47 static QString findPreferredUrl(const QMap<int, QString>& urlMap, Quality q);
48 QString findPreferredUrl();
49
50 QString urlTitle() { return url_title; }
51 QString latestPreferredUrl() { return latest_preferred_url; }
52 QString origUrl() { return orig_url; }
53
54signals:
55 void gotUrls(const QMap<int, QString>&);
56 void gotPreferredUrl(const QString &);
57 void gotEmptyList();
58
59 void connecting(QString host);
60 void errorOcurred(int error_number, QString error_str);
61
62 void signatureNotFound(const QString & title);
63
64protected slots:
65 void gotResponse(QNetworkReply* reply);
66 void parse(QByteArray text);
67
68protected:
69 static QString sanitizeForUnicodePoint(QString string);
70 static void htmlDecode(QString& string);
71
72 QMap<int, QString> urlMap;
73 QString url_title;
74 QString orig_url;
75 QString latest_preferred_url;
76
77 Quality preferred_quality;
78 QString user_agent;
79
80private:
81 QNetworkAccessManager* manager;
82 QNetworkReply* reply;
83};
84
85#endif
Note: See TracBrowser for help on using the repository browser.