Ignore:
Timestamp:
May 16, 2014, 9:51:55 AM (11 years ago)
Author:
Silvan Scherrer
Message:

SMPlayer: update trunk to latest 0.8.7

Location:
smplayer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/youtube/ytsig.cpp

    r156 r165  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
     2    Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    2121#ifdef YT_USE_SCRIPT
    2222#include <QtScript>
    23 #endif
    2423
    25 #ifdef YT_USE_SCRIPT
    26 QString YTSig::aclara(const QString & text) {
     24QString YTSig::aclara(const QString & text, const QString & player, const QString & function_name) {
    2725        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());
    2927
    3028        if (script.isEmpty()) script = default_script;
     
    3634
    3735        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();
    4058
    4159        //qDebug() << res;
     
    6179        f.close();
    6280
     81        parsed_ts = "";
     82
    6383        if (!bytes.isEmpty()) {
    6484                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
    6593        }
    6694}
     
    6997QString YTSig::script_file;
    7098
    71 // Algorithms from youtube-dl (http://rg3.github.io/youtube-dl/)
    72 
    7399QString YTSig::default_script;
    74100
     101#else // YT_USE_SCRIPT
     102
     103#ifdef YTSIG_STATIC
     104#include "ytsig_priv.cpp"
    75105#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) {
     106QString YTSig::aclara(const QString & text, const QString & player, const QString & function_name) {
    86107        QString res;
    87108
    88109        int dot = text.indexOf('.');
    89110        qDebug("YTSig::aclara (2): length: %d (%d.%d)", text.size(), dot, text.size()-dot-1);
    90 
    91 #if 0
    92         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 #endif
    100111
    101112        /*
     
    106117        return res;
    107118}
     119#endif
    108120
    109 #endif
     121#endif // YT_USE_SCRIPT
     122
     123void YTSig::check(QString & u) {
     124        if (!parsed_ts.isEmpty()) {
     125                u.append(QString("&%1").arg(parsed_ts));
     126        }
     127}
     128
     129QString YTSig::parsed_ts;
Note: See TracChangeset for help on using the changeset viewer.