Changeset 165 for smplayer/trunk/src/youtube/ytsig.cpp
- Timestamp:
- May 16, 2014, 9:51:55 AM (11 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 163
- Property svn:mergeinfo changed
-
smplayer/trunk/src/youtube/ytsig.cpp
r156 r165 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 3Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 21 21 #ifdef YT_USE_SCRIPT 22 22 #include <QtScript> 23 #endif24 23 25 #ifdef YT_USE_SCRIPT 26 QString YTSig::aclara(const QString & text) { 24 QString YTSig::aclara(const QString & text, const QString & player, const QString & function_name) { 27 25 int dot = text.indexOf('.'); 28 qDebug("YTSig::aclara: length: %d (%d.%d) ", text.size(), dot, text.size()-dot-1);26 qDebug("YTSig::aclara: length: %d (%d.%d) p: %d", text.size(), dot, text.size()-dot-1, !player.isEmpty()); 29 27 30 28 if (script.isEmpty()) script = default_script; … … 36 34 37 35 engine.evaluate(script); 38 QScriptValue aclarar = engine.globalObject().property("aclara"); 39 QString res = aclarar.call(QScriptValue(), QScriptValueList() << text).toString(); 36 37 QScriptValueList args; 38 QString fname; 39 40 if (!function_name.isEmpty()) { 41 fname = function_name; 42 args << text; 43 } 44 else 45 if (player.isEmpty()) { 46 fname = "aclara"; 47 args << text; 48 } 49 else { 50 fname = "aclara_p"; 51 args << text << player; 52 } 53 54 //qDebug("YTSig::aclara: function_name: %s", function_name.toLatin1().constData()); 55 56 QScriptValue aclarar = engine.globalObject().property(fname); 57 QString res = aclarar.call(QScriptValue(), args).toString(); 40 58 41 59 //qDebug() << res; … … 61 79 f.close(); 62 80 81 parsed_ts = ""; 82 63 83 if (!bytes.isEmpty()) { 64 84 script = bytes; 85 86 QRegExp rx("D: ([\\d,a-z,A-Z-]+)"); 87 if (rx.indexIn(bytes)) { 88 QByteArray d = rx.cap(1).toLatin1(); 89 qDebug("YTSig::reloadScriptFile: d: %s", d.constData()); 90 parsed_ts = QByteArray::fromBase64(d); 91 } 92 65 93 } 66 94 } … … 69 97 QString YTSig::script_file; 70 98 71 // Algorithms from youtube-dl (http://rg3.github.io/youtube-dl/)72 73 99 QString YTSig::default_script; 74 100 101 #else // YT_USE_SCRIPT 102 103 #ifdef YTSIG_STATIC 104 #include "ytsig_priv.cpp" 75 105 #else 76 77 QString YTSig::rev(const QString & orig) { 78 QString r; 79 for (int n = orig.size()-1; n >= 0; n--) { 80 r.append(orig.at(n)); 81 } 82 return r; 83 } 84 85 QString YTSig::aclara(const QString & text) { 106 QString YTSig::aclara(const QString & text, const QString & player, const QString & function_name) { 86 107 QString res; 87 108 88 109 int dot = text.indexOf('.'); 89 110 qDebug("YTSig::aclara (2): length: %d (%d.%d)", text.size(), dot, text.size()-dot-1); 90 91 #if 092 if (text.size() == xx) {93 res = <your code>;94 }95 else {96 qDebug("YTSig::aclara: signature length not supported: %d: %s", text.size(), text.toLatin1().constData());97 return res;98 }99 #endif100 111 101 112 /* … … 106 117 return res; 107 118 } 119 #endif 108 120 109 #endif 121 #endif // YT_USE_SCRIPT 122 123 void YTSig::check(QString & u) { 124 if (!parsed_ts.isEmpty()) { 125 u.append(QString("&%1").arg(parsed_ts)); 126 } 127 } 128 129 QString YTSig::parsed_ts;
Note:
See TracChangeset
for help on using the changeset viewer.