Changeset 176 for smplayer/trunk/src/youtube/retrieveyoutubeurl.h
- Timestamp:
- May 3, 2016, 5:25:45 PM (9 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 175
- Property svn:mergeinfo changed
-
smplayer/trunk/src/youtube/retrieveyoutubeurl.h
r170 r176 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 3Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 17 17 */ 18 18 19 #ifndef _RETRIEVEYOUTUBEURL_20 #define _RETRIEVEYOUTUBEURL_19 #ifndef RETRIEVEYOUTUBEURL_H 20 #define RETRIEVEYOUTUBEURL_H 21 21 22 22 #include <QNetworkAccessManager> 23 #include <QNetworkReply>24 23 #include <QMap> 24 #include "loadpage.h" 25 26 #ifdef YT_USE_SIG 27 #include "sig.h" 28 #endif 29 30 class QSettings; 25 31 26 32 #define YT_GET_VIDEOINFO 27 33 //#define YT_DASH_SUPPORT 34 #define YT_LIVE_STREAM 35 36 #ifdef YT_GET_VIDEOINFO 37 #define YT_DISCARD_HTTPS 38 #endif 39 40 typedef QMap<int,QString> UrlMap; 28 41 29 42 class RetrieveYoutubeUrl : public QObject … … 44 57 ~RetrieveYoutubeUrl(); 45 58 46 void fetchPage(const QString & url);47 void close();48 49 static void setUserAgent(const QString & s) { user_agent = s; };50 static QString userAgent() { return user_agent; };51 52 59 void setPreferredQuality(Quality q) { preferred_quality = q; } 53 60 Quality preferredQuality() { return preferred_quality; } 54 61 55 static QString findPreferredUrl(const QMap<int, QString>& urlMap, Quality q); 56 QString findPreferredUrl(); 62 void setUserAgent(const QString & s) { LoadPage::setDefaultUserAgent(s); }; 63 QString userAgent() { return LoadPage::defaultUserAgent(); }; 64 65 void fetchPage(const QString & url); 66 67 #ifdef YT_USE_SIG 68 void setSettings(QSettings * settings); 69 #endif 57 70 58 71 #ifdef YT_DASH_SUPPORT 59 static QString findBestAudio(const QMap<int, QString>& urlMap);72 static int findBestAudio(const QMap<int, QString>& url_map); // Returns the itag 60 73 #endif 61 74 62 75 QString urlTitle() { return url_title; } 76 QString origUrl() { return yt_url; } 77 63 78 QString latestPreferredUrl() { return latest_preferred_url; } 64 QString origUrl() { return orig_url; }65 79 66 80 bool isUrlSupported(const QString & url); 67 81 QString fullUrl(const QString & url); 68 82 69 static void setUseHttpsMain(bool b) { use_https_main = b; }; 70 static void setUseHttpsVi(bool b) { use_https_vi = b; }; 71 static bool useHttpsMain() { return use_https_main; }; 72 static bool useHttpsVi() { return use_https_vi; }; 83 void setUseHttpsMain(bool b) { use_https_main = b; }; 84 void setUseHttpsVi(bool b) { use_https_vi = b; }; 85 bool useHttpsMain() { return use_https_main; }; 86 bool useHttpsVi() { return use_https_vi; }; 87 88 static int findPreferredUrl(const UrlMap & url_map, Quality q); // Returns the itag 89 static QString extensionForItag(int itag); 90 91 void close() { /* FIXME: do something */ }; 73 92 74 93 signals: 75 94 void gotUrls(const QMap<int, QString>&); 76 void gotPreferredUrl(const QString &); 95 //void gotPreferredUrl(const QString &); 96 void gotPreferredUrl(const QString & url, int itag); 77 97 void gotEmptyList(); 98 void connecting(QString host); 99 void errorOcurred(int error_number, QString error_str); 100 void signatureNotFound(const QString & title); 101 void noSslSupport(); 102 103 protected slots: 104 void videoPageLoaded(QByteArray page); 78 105 #ifdef YT_GET_VIDEOINFO 79 void gotVideoInfo(const QMap<int, QString>&, QString, QString); 106 void videoInfoPageLoaded(QByteArray page); 107 #endif 108 #ifdef YT_USE_SIG 109 void playerPageLoaded(QByteArray page); 110 #endif 111 #ifdef YT_LIVE_STREAM 112 void streamPageLoaded(QByteArray page); 80 113 #endif 81 114 82 void connecting(QString host); 83 void errorOcurred(int error_number, QString error_str); 115 void processVideoPage(); 84 116 85 void signatureNotFound(const QString & title); 86 87 protected slots: 88 void gotResponse(); 89 void parse(QByteArray text); 117 protected: 118 void fetchVideoPage(const QString & url); 90 119 #ifdef YT_GET_VIDEOINFO 91 void gotVideoInfoResponse(); 92 void parseVideoInfo(QByteArray text); 93 void fetchVideoInfoPage(QString url = QString::null); 120 void fetchVideoInfoPage(const QString & url); 121 #endif 122 #ifdef YT_USE_SIG 123 void fetchPlayerPage(const QString & player_name); 124 #endif 125 #ifdef YT_LIVE_STREAM 126 void fetchStreamPage(const QString & url); 94 127 #endif 95 128 96 protected: 129 QString getVideoID(QString video_url); 130 UrlMap extractURLs(QString fmtArray, bool allow_https, bool use_player); 131 132 void finish(const UrlMap & url_map); 133 134 #ifdef YT_USE_SCRIPT 135 QString aclara(const QString & text, const QString & player = ""); 136 #endif 137 97 138 static QString sanitizeForUnicodePoint(QString string); 98 static void htmlDecode(QString& string);99 QString getVideoID(QString video_url);100 101 QMap<int, QString> urlMap;102 QString url_title;103 QString orig_url;104 QString latest_preferred_url;105 106 Quality preferred_quality;107 static QString user_agent;108 static bool use_https_main;109 static bool use_https_vi;110 111 #ifdef YT_GET_VIDEOINFO112 QString video_id;113 #endif114 139 115 140 private: 116 141 QNetworkAccessManager* manager; 117 QNetworkReply* reply; 142 LoadPage * dl_video_page; 143 144 #ifdef YT_GET_VIDEOINFO 145 LoadPage * dl_video_info_page; 146 #endif 147 148 #ifdef YT_USE_SIG 149 LoadPage * dl_player_page; 150 Sig sig; 151 QSettings * set; 152 #else 153 QString html5_player; 154 #endif 155 156 #ifdef YT_LIVE_STREAM 157 LoadPage * dl_stream_page; 158 #endif 159 160 QString video_page; 161 QString url_title; 162 163 Quality preferred_quality; 164 bool use_https_main; 165 bool use_https_vi; 166 167 QString yt_url; 168 QString video_id; 169 170 QString latest_preferred_url; 171 172 bool failed_to_decrypt_signature; 118 173 }; 119 174 120 175 #endif 176
Note:
See TracChangeset
for help on using the changeset viewer.