| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2012 Ricardo Villalba <[email protected]>
|
|---|
| 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 "simplehttp.h"
|
|---|
| 23 | #include <QMap>
|
|---|
| 24 |
|
|---|
| 25 | class RetrieveYoutubeUrl : public SimpleHttp
|
|---|
| 26 | {
|
|---|
| 27 | Q_OBJECT
|
|---|
| 28 |
|
|---|
| 29 | public:
|
|---|
| 30 | enum Quality { FLV_240p = 5, MP4_360p = 18, MP4_720p = 22, FLV_360p = 34,
|
|---|
| 31 | FLV_480p = 35, MP4_1080p = 37, WEBM_360p = 43,
|
|---|
| 32 | WEBM_480p = 44, WEBM_720p = 45, WEBM_1080p = 46 };
|
|---|
| 33 |
|
|---|
| 34 | RetrieveYoutubeUrl( QObject* parent = 0 );
|
|---|
| 35 | ~RetrieveYoutubeUrl();
|
|---|
| 36 |
|
|---|
| 37 | void fetchPage(const QString & url);
|
|---|
| 38 |
|
|---|
| 39 | void setPreferredQuality(Quality q) { preferred_quality = q; }
|
|---|
| 40 | Quality preferredQuality() { return preferred_quality; }
|
|---|
| 41 |
|
|---|
| 42 | static QString findPreferredUrl(const QMap<int, QString>& urlMap, Quality q);
|
|---|
| 43 | QString findPreferredUrl();
|
|---|
| 44 |
|
|---|
| 45 | QString urlTitle() { return url_title; }
|
|---|
| 46 | QString latestPreferredUrl() { return latest_preferred_url; }
|
|---|
| 47 | QString origUrl() { return orig_url; }
|
|---|
| 48 |
|
|---|
| 49 | signals:
|
|---|
| 50 | void gotUrls(const QMap<int, QString>&);
|
|---|
| 51 | void gotPreferredUrl(const QString &);
|
|---|
| 52 | void gotEmptyList();
|
|---|
| 53 |
|
|---|
| 54 | protected slots:
|
|---|
| 55 | void parse(QByteArray text);
|
|---|
| 56 |
|
|---|
| 57 | protected:
|
|---|
| 58 | QString sanitizeForUnicodePoint(QString string);
|
|---|
| 59 | void htmlDecode(QString& string);
|
|---|
| 60 |
|
|---|
| 61 | QMap<int, QString> urlMap;
|
|---|
| 62 | QString url_title;
|
|---|
| 63 | QString orig_url;
|
|---|
| 64 | QString latest_preferred_url;
|
|---|
| 65 |
|
|---|
| 66 | Quality preferred_quality;
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | #endif
|
|---|