Exemplo n.º 1
0
        private string DecryptWithCustomParser(string jsContent, string s)
        {
            try
            {
                // Try to get the functions out of the java script
                JavaScriptParser javaScriptParser = new JavaScriptParser(jsContent);
                FunctionData     functionData     = javaScriptParser.Parse();

                StringBuilder stringBuilder = new StringBuilder();

                foreach (var functionBody in functionData.Bodies)
                {
                    stringBuilder.Append(functionBody);
                }

                ScriptEngine engine = new ScriptEngine();

                engine.Global["window"]    = engine.Global;
                engine.Global["document"]  = engine.Global;
                engine.Global["navigator"] = engine.Global;

                engine.Execute(stringBuilder.ToString());

                return(engine.CallGlobalFunction(functionData.StartFunctionName, s).ToString());
            }
            catch (Exception ex)
            {
                Log.Info("Signature decryption with custom parser failed: {0}", ex.Message);
            }
            return(string.Empty);
        }
Exemplo n.º 2
0
        protected override Task <DialogTurnResult> OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            // map state into json
            dynamic payload = new JObject();

            payload.state              = new JObject();
            payload.state.user         = JObject.FromObject(dc.State.User);
            payload.state.conversation = JObject.FromObject(dc.State.Conversation);
            payload.state.dialog       = JObject.FromObject(dc.State.Dialog);
            payload.state.turn         = JObject.FromObject(dc.State.Turn);

            // payload.property = (this.Property != null) ? dc.GetValue<object>(this.Property) : null;
            string payloadJson  = JsonConvert.SerializeObject(payload);
            var    responseJson = scriptEngine.CallGlobalFunction <string>("callStep", payloadJson);

            if (!String.IsNullOrEmpty(responseJson))
            {
                dynamic response = JsonConvert.DeserializeObject(responseJson);
                payload.state.User         = response.state.user;
                payload.state.Conversation = response.state.conversation;
                payload.state.Dialog       = response.state.dialog;
                payload.state.Turn         = response.state.turn;
                return(dc.EndDialogAsync((object)response.result, cancellationToken: cancellationToken));
            }
            return(dc.EndDialogAsync(cancellationToken: cancellationToken));
        }
        public void Process(BundleContext context, BundleResponse response)
        {
            var coffeeScriptPath =
                Path.Combine(
                    HttpRuntime.AppDomainAppPath,
                    "Scripts",
                    "coffee-script.js");

            if (!File.Exists(coffeeScriptPath))
            {
                throw new FileNotFoundException(
                    "Could not find coffee-script.js beneath the ~/Scripts directory.");
            }

            var coffeeScriptCompiler =
                File.ReadAllText(coffeeScriptPath, Encoding.UTF8);

            var engine = new ScriptEngine();
            engine.Execute(coffeeScriptCompiler);

            // Initializes a wrapper function for the CoffeeScript compiler.
            var wrapperFunction =
                string.Format(
                    "var compile = function (src) {{ return CoffeeScript.compile(src, {{ bare: {0} }}); }};",
                    _bare.ToString(CultureInfo.InvariantCulture).ToLower());
            
            engine.Execute(wrapperFunction);
            
            var js = engine.CallGlobalFunction("compile", response.Content);
                
            response.ContentType = ContentTypes.JavaScript;
            response.Content = js.ToString();
        }
        public string Execute(string scriptValue)
        {
            var jsContext = new ScriptEngine();

            jsContext.Evaluate("function __result__() {" + scriptValue + "}");
            return(jsContext.CallGlobalFunction("__result__").ToString());
        }
Exemplo n.º 5
0
        public override string GetVideoUrl(string url)
        {
            if (!url.Contains("embed-"))
            {
                url = url.Replace("play.to/", "play.to/embed-");
            }
            if (!url.EndsWith(".html"))
            {
                url += ".html";
            }

            string data = GetWebData <string>(url);
            Regex  rgx  = new Regex(@">eval(?<js>.*?)</script>", RegexOptions.Singleline);
            Match  m    = rgx.Match(data);

            if (m.Success)
            {
                ScriptEngine engine = new ScriptEngine();
                string       js     = m.Groups["js"].Value;
                engine.Execute("var player = " + js + ";");
                engine.Execute("function getPlayer() { return player; };");
                data = engine.CallGlobalFunction("getPlayer").ToString();
                rgx  = new Regex(@"file:""(?<url>http[^""]*?.mp4)""");
                m    = rgx.Match(data);
                if (m.Success)
                {
                    return(m.Groups["url"].Value);
                }
            }
            return("");
        }
Exemplo n.º 6
0
        public override string GetVideoUrl(string url)
        {

            string url2 = url;
            if (url.ToLower().Contains("view.php"))
            {
                url2 = url.Replace("view.php", "iframe.php");
            }
            else if (!url.ToLower().Contains("iframe.php"))
            {
                int p = url.IndexOf('?');
                url2 = url.Insert(p, "iframe.php");
            }
            string webData = WebCache.Instance.GetWebData(url2);
            Match m = Regex.Match(webData, @"eval\((?<js>.*)?\)$", RegexOptions.Multiline);
            if (!m.Success)
                return string.Empty;
            string js = "var p = ";
            js += m.Groups["js"].Value;
            js += "; ";
            js += "function packed(){return p;};";
            ScriptEngine engine = new ScriptEngine();
            engine.Execute(js);
            string data = engine.CallGlobalFunction("packed").ToString();
            m = Regex.Match(data, @"""(?<url>http[^""]*)");
            if (!m.Success)
                return String.Empty;
            SetSub(webData);
            return m.Groups["url"].Value;
        }
Exemplo n.º 7
0
        public void CallJavaScriptFunction1()
        {
            var engine = new ScriptEngine();

            engine.Evaluate("function test(a, b) { return a + b }");
            Assert.AreEqual(11, engine.CallGlobalFunction <int>("test", 5, 6));
        }
Exemplo n.º 8
0
        public override string GetVideoUrl(string url)
        {
            if(!url.Contains("embed-"))
            {
                url = url.Replace("play.to/", "play.to/embed-");
            }
            if (!url.EndsWith(".html"))
            {
                url += ".html";
            }

            string data = GetWebData<string>(url);
            Regex rgx = new Regex(@">eval(?<js>.*?)</script>", RegexOptions.Singleline);
            Match m = rgx.Match(data);
            if (m.Success)
            {
                ScriptEngine engine = new ScriptEngine();
                string js = m.Groups["js"].Value;
                engine.Execute("var player = " + js + ";");
                engine.Execute("function getPlayer() { return player; };");
                data = engine.CallGlobalFunction("getPlayer").ToString();
                rgx = new Regex(@"file:""(?<url>http[^""]*?.mp4)""");
                m = rgx.Match(data);
                if (m.Success)
                {
                    return m.Groups["url"].Value;
                }
            }
            return "";
        }
Exemplo n.º 9
0
        public override string GetVideoUrl(string url)
        {
            url = url.Replace("/f/", "/embed/");
            string data = GetWebData <string>(url);

            if (data.Contains("<h3>We’re Sorry!</h3>"))
            {
                throw new OnlineVideosException("The video maybe got deleted by the owner or was removed due a copyright violation.");
            }
            sub = "";
            Regex rgx = new Regex(@"<span[^>]+id=""[^""]+""[^>]*>(?<encoded>[0-9A-Za-z]+)</span>.*?(?<aascript>゚.*?\('_'\);)(?<script>.*?)゚", RegexOptions.Singleline);
            Match m   = rgx.Match(data);

            if (m.Success)
            {
                string script = "var id = \"" + m.Groups["encoded"].Value;
                script += "\";\r\n";
                script += OnlineVideos.Sites.Properties.Resources.OpenloadDecode;
                script += "\r\n";
                script += Sites.Utils.HelperUtils.AaDecode(m.Groups["aascript"].Value);
                script += m.Groups["script"].Value;
                ScriptEngine engine = new ScriptEngine();
                engine.Execute(script);
                string decoded = engine.CallGlobalFunction("getUrl").ToString();
                return(decoded);
            }
            return("");
        }
Exemplo n.º 10
0
        public IEnumerator SetupTKK()
        {
            string         error          = null;
            DownloadResult downloadResult = null;

            _cookieContainer = new CookieContainer();

            var client = GetClient();

            try
            {
                ApplyHeaders(client.Headers);
                downloadResult = client.GetDownloadResult(new Uri(HttpsTranslateUserSite));
            }
            catch (Exception e)
            {
                error = e.ToString();
            }

            if (downloadResult != null)
            {
                yield return(downloadResult);

                error = downloadResult.Error;
                if (downloadResult.Succeeded)
                {
                    try
                    {
                        var html = downloadResult.Result;

                        const string lookup         = "TKK=eval('";
                        var          lookupIndex    = html.IndexOf(lookup) + lookup.Length;
                        var          openClamIndex  = html.IndexOf('{', lookupIndex);
                        var          closeClamIndex = html.IndexOf('}', openClamIndex);
                        var          functionIndex  = html.IndexOf("function", lookupIndex);
                        var          script         = html.Substring(functionIndex, closeClamIndex - functionIndex + 1);
                        var          decodedScript  = script.Replace("\\x3d", "=").Replace("\\x27", "'").Replace("function", "function FuncName");

                        // https://github.com/paulbartrum/jurassic/wiki/Safely-executing-user-provided-scripts
                        ScriptEngine engine = new ScriptEngine();
                        engine.Evaluate(decodedScript);
                        var result = engine.CallGlobalFunction <string>("FuncName");

                        var parts = result.Split('.');
                        m = long.Parse(parts[0]);
                        s = long.Parse(parts[1]);
                    }
                    catch (Exception e)
                    {
                        error = e.ToString();
                    }
                }
            }

            if (error != null)
            {
                Logger.Current.Error("An error occurred while setting up GoogleTranslate Cookie/TKK." + Environment.NewLine + error);
            }
        }
Exemplo n.º 11
0
 // Update is called once per frame
 void Update()
 {
     engine.SetGlobalValue("time", Time.time);
     //Execute the contents of the script every frame if Running is ticked.
     engine.CallGlobalFunction("Update");
     if (running)
     {
     }
 }
Exemplo n.º 12
0
        private static bool ConditionMetForChangeVisually <T>(PropertyInfo prop, T model, PropertyInfo[] modelProps)
        {
            var engine = new ScriptEngine();
            var src    = GetJavaScript();

            engine.Evaluate(src);

            List <string> toValues;
            List <string> whenOtherPropertyNameValues;
            List <string> ifValues;
            List <string> valueValues;
            List <string> conditionPassesIfNullValues;
            List <string> valueTypeToCompareValues;
            List <string> valueFormatValues;

            ChangeVisuallyAttribute.GetValuesForClient(prop, out toValues, out whenOtherPropertyNameValues, out ifValues, out valueValues, out conditionPassesIfNullValues, out valueTypeToCompareValues, out valueFormatValues);

            //check if we have any conditions.. if we do loop through them and return true as soon as one is found to pass
            if (toValues.Any())
            {
                for (var i = 0; i < toValues.Count; i++)
                {
                    //get the "other property" value
                    string otherPropValue = null;
                    var    otherProp      =
                        modelProps.FirstOrDefault(_ => string.Equals(_.Name, whenOtherPropertyNameValues[i]));
                    if (otherProp != null)
                    {
                        var val = otherProp.GetValue(model, null);
                        if (val != null)
                        {
                            otherPropValue = Json.Encode(val);
                        }
                    }

                    var ifOperator            = ifValues[i];
                    var expectedValue         = valueValues[i];
                    var actualValue           = otherPropValue;
                    var conditionPassesIfNull = conditionPassesIfNullValues[i];
                    var valueTypeToCompare    = valueTypeToCompareValues[i];
                    var valueFormat           = valueFormatValues[i];

                    //Call the JavaScript function to evaluate
                    var res = engine.CallGlobalFunction <bool>("ConditionMetForChangeVisually", ifOperator, expectedValue,
                                                               actualValue, conditionPassesIfNull, valueTypeToCompare,
                                                               valueFormat);
                    if (res)
                    {
                        //we found one where the condition was met
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 13
0
 void ExcuteScript()
 {
     if (!scriptExcuted)
     {
         engine.Execute(code);
         scriptExcuted = true;
         return;
     }
     engine.CallGlobalFunction("update");
 }
Exemplo n.º 14
0
        /// <summary>
        /// 将页面上的脚本转换成时间
        /// </summary>
        /// <param name="postTime">格式是:1409710649 </param>
        /// <returns></returns>
        static string GetPostTime(string postTime)
        {
            string timeSpan = string.Empty;
            var    JSEngine = new ScriptEngine();

            JSEngine.Evaluate("function vrTimeHandle552(time){ if (time) {var type = [\"1分钟前\", \"分钟前\", \"小时前\", \"天前\", \"周前\", \"个月前\", \"年前\"];"
                              + " var secs = (new Date().getTime())/1000 - time; if(secs < 60){ return type[0]; }else if(secs < 3600){	return Math.floor(secs/60) + type[1]; }else if(secs < 24*3600){"
                              + " return Math.floor(secs/3600) + type[2]; }else if(secs < 24*3600 *7){	return Math.floor(secs/(24*3600)) + type[3]; }else if(secs < 24*3600*31){"
                              + " return Math.round(secs/(24*3600*7)) + type[4]; }else if(secs < 24*3600*365){	return Math.round(secs/(24*3600*31)) + type[5];	}else if(secs >= 24*3600*365){"
                              + " return Math.round(secs/(24*3600*365)) + type[6]; }else {	return ''; } } else { return ''; }}");
            timeSpan = JSEngine.CallGlobalFunction <string>("vrTimeHandle552", int.Parse(postTime));
            return(timeSpan);
        }
Exemplo n.º 15
0
 public string Compile(string coffeeScriptSource, IFile sourceFile)
 {
     lock (ScriptEngine) // ScriptEngine is NOT thread-safe, so we MUST lock.
     {
         try
         {
             return(ScriptEngine.CallGlobalFunction <string>("compile", coffeeScriptSource));
         }
         catch (Exception ex)
         {
             throw new CoffeeScriptCompileException(ex.Message + " in " + sourceFile.FullPath, sourceFile.FullPath, ex);
         }
     }
 }
Exemplo n.º 16
0
        public void ProcessEvents()
        {
            while (EventQueue.Count > 0)
            {
                Event e = EventQueue.Dequeue();

                if (e.Name == "Debug")
                {
                    e.Element.Get("x").Value = "0";
                }

                Engine.CallGlobalFunction(e.Name);
            }
        }
Exemplo n.º 17
0
    public static object invoke(string functionName, params object[] arguments)
    {
        TextAsset scriptLocationAsset = Resources.Load("shared_dir_location") as TextAsset;

        string sharedDir  = scriptLocationAsset.text;
        string codeString = File.ReadAllText(string.Format("{0}/scripts/{1}.js", sharedDir, functionName));

        ScriptEngine engine = new ScriptEngine();

        engine.SetGlobalFunction("print", new System.Action <string>(Debug.Log));
        engine.Execute(codeString);

        return(engine.CallGlobalFunction(functionName, arguments));
    }
Exemplo n.º 18
0
    void Start()
    {
        TextAsset script = Resources.Load("JavascriptTest") as TextAsset;

        engine.Execute(script.text);
        engine.SetGlobalValue("robotState", new Math2(engine, vida, transform));

        //	Debug.Log(engine.Evaluate<double>("math2.log10(1000)"));



        engine.CallGlobalFunction("start");
        transform.position = RobotSate.trans.position;
    }
Exemplo n.º 19
0
 private string CallBeautify(string strParams)
 {
     try
     {
         string       path         = Server.MapPath("~/Scripts/Studio/beautify.js");
         ScriptEngine scriptEngine = new ScriptEngine();
         scriptEngine.ExecuteFile(path);
         return(scriptEngine.CallGlobalFunction <string>("js_beautify", new object[1]
         {
             strParams
         }));
     }
     catch (Exception)
     {
         return(strParams);
     }
 }
 public string Compile(string coffeeScriptSource, IFile sourceFile)
 {
     Trace.Source.TraceInformation("Compiling {0}", sourceFile.FullPath);
     lock (ScriptEngine) // ScriptEngine is NOT thread-safe, so we MUST lock.
     {
         try
         {
             Trace.Source.TraceInformation("Compiled {0}", sourceFile.FullPath);
             return(ScriptEngine.CallGlobalFunction <string>("compile", coffeeScriptSource));
         }
         catch (Exception ex)
         {
             var message = ex.Message + " in " + sourceFile.FullPath;
             Trace.Source.TraceEvent(TraceEventType.Critical, 0, message);
             throw new CoffeeScriptCompileException(message, sourceFile.FullPath, ex);
         }
     }
 }
Exemplo n.º 21
0
 public CompileResult Compile(string coffeeScriptSource, CompileContext context)
 {
     Trace.Source.TraceInformation("Compiling {0}", context.SourceFilePath);
     lock (ScriptEngine) // ScriptEngine is NOT thread-safe, so we MUST lock.
     {
         try
         {
             Trace.Source.TraceInformation("Compiled {0}", context.SourceFilePath);
             var javascript = ScriptEngine.CallGlobalFunction <string>("compile", coffeeScriptSource);
             return(new CompileResult(javascript, Enumerable.Empty <string>()));
         }
         catch (Exception ex)
         {
             var message = ex.Message + " in " + context.SourceFilePath;
             Trace.Source.TraceEvent(TraceEventType.Critical, 0, message);
             throw new CoffeeScriptCompileException(message, context.SourceFilePath, ex);
         }
     }
 }
Exemplo n.º 22
0
        public object Evaluate(IEnumerable <object> arguments, Marshaler marshaler)
        {
            ScriptEngine engine = engineFactory.GetScriptEngine();

            EnsureCompiled(engine);

            // call the function
            object[] wrappedArgs = arguments.Select(marshaler.Wrap).ToArray();
            object   result;

            try
            {
                result = engine.CallGlobalFunction(functionName, wrappedArgs);
            }
            catch (Jurassic.JavaScriptException err)
            {
                throw new ScriptFunctionEvaluationException(expression, err);
            }
            return(marshaler.Unwrap(result));
        }
Exemplo n.º 23
0
        public override string GetVideoUrl(string url)
        {
            string url2 = url;

            if (url.ToLower().Contains("view.php"))
            {
                url2 = url.Replace("view.php", "iframe.php");
            }
            else if (!url.ToLower().Contains("iframe.php"))
            {
                int p = url.IndexOf('?');
                url2 = url.Insert(p, "iframe.php");
            }
            string webData = WebCache.Instance.GetWebData(url2);
            Match  m       = Regex.Match(webData, @"eval\((?<js>.*)?\)$", RegexOptions.Multiline);

            if (!m.Success)
            {
                return(string.Empty);
            }
            string js = "var p = ";

            js += m.Groups["js"].Value;
            js += "; ";
            js += "function packed(){return p;};";
            ScriptEngine engine = new ScriptEngine();

            engine.Execute(js);
            string data = engine.CallGlobalFunction("packed").ToString();

            m = Regex.Match(data, @"""(?<url>http[^""]*)");
            if (!m.Success)
            {
                return(String.Empty);
            }
            SetSub(webData);
            return(m.Groups["url"].Value);
        }
Exemplo n.º 24
0
        public override Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            // map state into json
            dynamic payload = new JObject();

            payload.state = dc.GetState().GetMemorySnapshot();

            // payload.property = (this.Property != null) ? dc.GetValue<object>(this.Property) : null;
            string payloadJson  = JsonConvert.SerializeObject(payload);
            var    responseJson = scriptEngine.CallGlobalFunction <string>("callAction", payloadJson);

            if (!string.IsNullOrEmpty(responseJson))
            {
                dynamic response = JsonConvert.DeserializeObject(responseJson);
                dc.GetState().SetValue(ScopePath.USER, response.state.user);
                dc.GetState().SetValue(ScopePath.CONVERSATION, response.state.conversation);
                dc.GetState().SetValue(ScopePath.DIALOG, response.state.dialog);
                dc.GetState().SetValue(ScopePath.TURN, response.state.turn);
                return(dc.EndDialogAsync((object)response.result, cancellationToken: cancellationToken));
            }

            return(dc.EndDialogAsync(cancellationToken: cancellationToken));
        }
Exemplo n.º 25
0
 public string Execute(string scriptValue)
 {
     _jsContext.Evaluate("function __result__() {" + scriptValue + "}");
     return(_jsContext.CallGlobalFunction("__result__").ToString());
 }
Exemplo n.º 26
0
 public string Execute(string scriptValue)
 {
     var jsContext = new ScriptEngine();
     jsContext.Evaluate("function __result__() {" + scriptValue + "}");
     return jsContext.CallGlobalFunction("__result__").ToString();
 }
Exemplo n.º 27
0
        private string DecryptWithCustomParser(string jsContent, string s)
        {
            try
            {
                // Try to get the functions out of the java script
                JavaScriptParser javaScriptParser = new JavaScriptParser(jsContent);
                FunctionData functionData = javaScriptParser.Parse();

                StringBuilder stringBuilder = new StringBuilder();

                foreach (var functionBody in functionData.Bodies)
                {
                    stringBuilder.Append(functionBody);
                }

                ScriptEngine engine = new ScriptEngine();

                engine.Global["window"] = engine.Global;
                engine.Global["document"] = engine.Global;
                engine.Global["navigator"] = engine.Global;

                engine.Execute(stringBuilder.ToString());

                return engine.CallGlobalFunction(functionData.StartFunctionName, s).ToString();
            }
            catch (Exception ex)
            {
                Log.Info("Signature decryption with custom parser failed: {0}", ex.Message);
            }
            return string.Empty;
        }
Exemplo n.º 28
0
        public CompileResult Compile(string source, CompileContext context)
        {
            var javascript = scriptEngine.CallGlobalFunction <string>("compile", source);

            return(new CompileResult(javascript, Enumerable.Empty <string>()));
        }
Exemplo n.º 29
0
 /// <summary>
 /// 将页面上的脚本转换成时间
 /// </summary>
 /// <param name="postTime">格式是:1409710649 </param>
 /// <returns></returns>
 static string GetPostTime(string postTime)
 {
     string timeSpan = string.Empty;
     var JSEngine = new ScriptEngine();
     JSEngine.Evaluate("function vrTimeHandle552(time){ if (time) {var type = [\"1分钟前\", \"分钟前\", \"小时前\", \"天前\", \"周前\", \"个月前\", \"年前\"];"
         +" var secs = (new Date().getTime())/1000 - time; if(secs < 60){ return type[0]; }else if(secs < 3600){	return Math.floor(secs/60) + type[1]; }else if(secs < 24*3600){"
         +" return Math.floor(secs/3600) + type[2]; }else if(secs < 24*3600 *7){	return Math.floor(secs/(24*3600)) + type[3]; }else if(secs < 24*3600*31){"
         +" return Math.round(secs/(24*3600*7)) + type[4]; }else if(secs < 24*3600*365){	return Math.round(secs/(24*3600*31)) + type[5];	}else if(secs >= 24*3600*365){"
         +" return Math.round(secs/(24*3600*365)) + type[6]; }else {	return ''; } } else { return ''; }}");           
     timeSpan = JSEngine.CallGlobalFunction<string>("vrTimeHandle552", int.Parse(postTime));
     return timeSpan;
 }
Exemplo n.º 30
0
 public string GetCompiledCode(string source)
 {
     return(_engine.CallGlobalFunction <string>("buildTmplFn", source));
 }
Exemplo n.º 31
0
 public string Compile(string func, string code)
 {
     return(_engine.CallGlobalFunction <string>(func, code));
 }
Exemplo n.º 32
0
 public string Compile(string source, IFile sourceFile)
 {
     return(scriptEngine.CallGlobalFunction <string>("compile", source));
 }
Exemplo n.º 33
0
 public TResult CallGlobalFunction <TResult>(string functionName, params object[] argumentValues)
 {
     return(engine.CallGlobalFunction <TResult>(functionName, argumentValues));
 }
Exemplo n.º 34
0
        public override string GetVideoUrl(VideoInfo video)
        {
            string       data   = GetWebData(video.VideoUrl);
            Match        m2     = Regex.Match(data, "<script>(?<script>\\s*func.*?)</script>", RegexOptions.Singleline);
            ScriptEngine engine = new ScriptEngine();

            engine.Global["window"]    = engine.Global;
            engine.Global["document"]  = engine.Global;
            engine.Global["navigator"] = engine.Global;

            engine.Execute(m2.Groups["script"].Value);



            Regex r = new Regex(@"<tr class=""linkTr"">.*?""serverLink\sserverLink[^\s]*\sid=""(?<id>[^""]*)"".*?""linkQuality[^>]*>(?<q>[^<]*)<.*?linkHiddenFormat[^>]*>(?<f>[^<]*)<.*?linkHiddenCode[^>]*>(?<c>[^<]*)<.*?</tr", RegexOptions.Singleline);

            Dictionary <string, string> d       = new Dictionary <string, string>();
            List <Hoster.HosterBase>    hosters = Hoster.HosterFactory.GetAllHosters();

            foreach (Match m in r.Matches(data))
            {
                string id = m.Groups["id"].Value.Replace("serverLink", "");
                if (!string.IsNullOrEmpty(id))
                {
                    string c = engine.CallGlobalFunction("dec_" + id, m.Groups["c"].Value).ToString();
                    string u = m.Groups["f"].Value.Replace("%s", c);

                    if (u.StartsWith("//"))
                    {
                        u = "http:" + u;
                    }
                    Hoster.HosterBase hoster = hosters.FirstOrDefault(h => u.ToLowerInvariant().Contains(h.GetHosterUrl().ToLowerInvariant()));
                    if (hoster != null)
                    {
                        string format = hoster.GetHosterUrl() + " [" + m.Groups["q"].Value + "] " + "({0})";
                        int    count  = 1;
                        while (d.ContainsKey(string.Format(format, count)))
                        {
                            count++;
                        }
                        d.Add(string.Format(format, count), u);
                    }
                    else
                    {
                        Log.Debug("Skipped hoster:" + m.Groups["f"].Value);
                    }
                }
                else
                {
                    Log.Debug("Skipped decription and hoster for: " + m.Groups["f"].Value);
                }
            }
            d = d.OrderBy((p) =>
            {
                return(p.Key);
            }).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            video.PlaybackOptions = d;
            if (d.Count == 0)
            {
                return("");
            }
            if ((video as LosMoviesVideoInfo).TrackingInfo == null)
            {
                (video as LosMoviesVideoInfo).TrackingInfo = new TrackingInfo();
            }
            var ti = (video as LosMoviesVideoInfo).TrackingInfo;

            if (string.IsNullOrEmpty(ti.ID_IMDB))
            {
                ti.VideoKind = VideoKind.Movie;
                ti.Title     = video.Title;
                ti.Year      = GetRelesaseYear(data);
                ti.ID_IMDB   = GetImdbId(data);
            }
            sh.SetSubtitleText(video, GetTrackingInfo, false);
            string latestOption = (video is LosMoviesVideoInfo) ? (video as LosMoviesVideoInfo).LatestOption : "";

            if (string.IsNullOrEmpty(latestOption))
            {
                return(d.First().Value);
            }
            if (d.ContainsKey(latestOption))
            {
                return(d[latestOption]);
            }
            return(d.First().Value);
        }
 string Rewrite(string source)
 {
     return(ScriptEngine.CallGlobalFunction <string>("rewriteTemplate", source));
 }
Exemplo n.º 36
0
        public static string get_bda(string os_type)
        {
            var    rnd = new Random();
            JArray bda = new JArray();

            JObject api_type = new JObject();

            api_type.Add(new JProperty("key", "api_type"));
            api_type.Add(new JProperty("value", "js"));

            JObject p = new JObject();

            p.Add(new JProperty("key", "p"));
            p.Add(new JProperty("value", 1));

            object[] fp = BdaGen.fp();

            JObject f = new JObject();

            f.Add(new JProperty("key", "f"));
            f.Add(new JProperty("value", fp[0]));

            JObject n = new JObject();

            n.Add(new JProperty("key", "n"));
            n.Add(new JProperty("value", "B64TIME"));

            JObject wh = new JObject();

            wh.Add(new JProperty("key", "wh"));

            // chrome
            // wh.Add(new JProperty("value", BdaGen.fp()[0] + "|" + "5d76839801bc5904a4f12f1731a7b6d1"));

            // firefox
            // wh.Add(new JProperty("value", BdaGen.fp()[0] + "|" + "5d76839801bc5904a4f12f1731a7b6d1"));

            // chrome dev (android)
            wh.Add(new JProperty("value", $"{BdaGen.fp()[0]}|{(os_type == "Android" ? "5d76839801bc5904a4f12f1731a7b6d1" : "72627afbfd19a741c7da1732218301ac")}"));


            string fonts =
                "Arial,Arial Black,Arial Narrow,Calibri,Cambria,Cambria Math,Comic Sans MS,Consolas,Courier,Courier New,Georgia,Helvetica,Impact,Lucida Console,Lucida Sans Unicode,Microsoft Sans Serif,MS Gothic,MS PGothic,MS Sans Serif,MS Serif,Palatino Linotype,Segoe Print,Segoe Script,Segoe UI,Segoe UI Light,Segoe UI Semibold,Segoe UI Symbol,Tahoma,Times,Times New Roman,Trebuchet MS,Verdana,Wingdings";

            string mobileFonts =
                "Arial,Courier,Courier New,Georgia,Helvetica,Monaco,Palatino,Tahoma,Times,Times New Roman,Verdana";

            string plugins       = "Chrome PDF Plugin,Chrome PDF Viewer,Native Client";
            string mobilePlugins = "";

            JArray fe_data = new JArray();

            fe_data.Add("DNT:unknown");
            fe_data.Add("L:en-US");
            fe_data.Add("D:24");
            fe_data.Add(os_type == "Android" ? "PR:1.2000000476837158" : "PR:1");
            fe_data.Add(os_type == "Android" ? "S:1067,600" : "S:1920,1080");
            fe_data.Add(os_type == "Android" ? "AS:1067,600" : "AS:1920,1040");
            fe_data.Add("TO:-60");
            fe_data.Add("SS:true");
            fe_data.Add("LS:true");
            fe_data.Add($"IDB:{(os_type == "Android" ? "false" : "true")}");
            fe_data.Add("B:false");
            fe_data.Add($"ODB:{(os_type == "Android" ? "false" : "true")}");
            fe_data.Add("CPUC:unknown");
            fe_data.Add(os_type == "Android" ? "PK:Linux armv7l" : "PK:Win32");

            // todo change this
            fe_data.Add("CFP:" + fp[1]);

            fe_data.Add("FR:false");
            fe_data.Add("FOS:false");
            fe_data.Add("FB:false");
            fe_data.Add($"JSF:{(os_type == "Android" ? mobileFonts : fonts)}");
            fe_data.Add(os_type == "Android" ? ("P:" + mobilePlugins) : ("P:" + plugins));
            fe_data.Add(os_type == "Android" ? "T:5,true,true" : "T:0,false,false");
            //fe_data.Add("H:" + rnd.Next(2, 7));
            fe_data.Add("H:4");
            fe_data.Add("SWF:false");

            JObject fe = new JObject();

            fe.Add(new JProperty("key", "fe"));
            fe.Add(new JProperty("value", fe_data));

            string pure_fe = String.Empty;

            foreach (var fvalue in fe_data)
            {
                pure_fe = pure_fe + fvalue + ", ";
            }

            pure_fe = pure_fe.Substring(0, pure_fe.Length - 2);
            var hash = engine.CallGlobalFunction <string>("x64hash128", pure_fe, 38);

            JObject ife = new JObject();

            ife.Add(new JProperty("key", "ife_hash"));
            ife.Add(new JProperty("value", hash));

            JObject cs = new JObject();

            cs.Add(new JProperty("value", 1));
            cs.Add(new JProperty("key", "cs"));

            JObject jsbd_data = new JObject();

            jsbd_data.Add(new JProperty("HL", rnd.Next(2, 14)));
            jsbd_data.Add(new JProperty("NCE", true));
            jsbd_data.Add(new JProperty("DT", "Roblox"));
            jsbd_data.Add(new JProperty("NWD", "undefined"));

            if (os_type == "Android")
            {
                jsbd_data.Add(new JProperty("DMTO", 1));
                jsbd_data.Add(new JProperty("DOTO", 1));
            }
            else
            {
                jsbd_data.Add(new JProperty("DA", null));
                jsbd_data.Add(new JProperty("DR", null));
                jsbd_data.Add(new JProperty("DMT", rnd.Next(28, 38)));
                jsbd_data.Add(new JProperty("DO", null));
                jsbd_data.Add(new JProperty("DOT", rnd.Next(31, 45)));
            }


            JObject jsbd = new JObject();

            jsbd.Add(new JProperty("key", "jsbd"));
            jsbd.Add(new JProperty("value", jsbd_data.ToString(Formatting.None)));

            bda.Add(api_type);
            bda.Add(p);
            bda.Add(f);
            bda.Add(n);
            bda.Add(wh);
            bda.Add(fe);
            bda.Add(ife);
            bda.Add(cs);
            bda.Add(jsbd);

            return(bda.ToString(Formatting.None));
        }