Exemple #1
0
        string Run(string str)
        {
            string flv = "";
            try
            {
                JavaScriptObject obj2 = (JavaScriptObject)JavaScriptConvert.DeserializeObject(str);
                JavaScriptArray array = (JavaScriptArray)obj2["data"];
                Dictionary<string, object> dictionary = (Dictionary<string, object>)array[0];
                string flvdata = "";
                string key1 = "";
                string key2 = "";
                string str6 = "";
                int seed = 0;
                Dictionary<string, object> segs = null;
                foreach (KeyValuePair<string, object> pair in dictionary)
                {
                    if (pair.Key == "streamfileids")
                    {
                        flvdata = ((Dictionary<string, object>)pair.Value)["flv"].ToString();
                    }
                    else
                    {
                        if (pair.Key == "key1")
                        {
                            key1 = pair.Value.ToString();
                            continue;
                        }
                        if (pair.Key == "key2")
                        {
                            key2 = pair.Value.ToString();
                            continue;
                        }
                        if (pair.Key == "seed")
                        {
                            seed = Convert.ToInt32(pair.Value);
                            continue;
                        }
                        if (pair.Key == "segs")
                        {
                            segs = (Dictionary<string, object>)pair.Value;
                        }
                    }
                }
                object flv_segs = null;
                foreach (KeyValuePair<string, object> pair2 in segs)
                {
                    if (pair2.Key == "flv")
                    {
                        flv_segs = pair2.Value;
                        break;
                    }
                }
                List<object> flv_list = (List<object>)flv_segs;
                List<string> key_list = new List<string>();
                int times = 0;
                foreach (object obj4 in flv_list)
                {
                    Dictionary<string, object> dictionary3 = (Dictionary<string, object>)obj4;
                    foreach (KeyValuePair<string, object> pair3 in dictionary3)
                    {
                        if (pair3.Key == "seconds")
                        {
                            times += int.Parse((string)pair3.Value);
                        }
                        if (pair3.Key == "k")
                        {
                            key_list.Add(pair3.Value as string);
                        }
                    }
                }
                //  totalSecond = times.ToString();
                int count = flv_list.Count;
                string str7 = Convert.ToString((long)(Convert.ToInt32(key1, 0x10) ^ ((long)0xa55aa5a5L)), 0x10).Substring(8, 8);
                for (int i = 0; i < 8; i++)
                {
                    if (str7.StartsWith("0"))
                    {
                        str7 = str7.Substring(1, str7.Length - 1);
                    }
                }
                string text1 = key2 + str7;
                int num5 = new Random().Next(0x2328);
                DateTime now = DateTime.Now;
                DateTime time = new DateTime(0x7b2, 1, 1);
                TimeSpan span = (TimeSpan)(DateTime.Now - time);
                long num6 = Convert.ToInt64((double)((span.TotalMilliseconds * 1000.0) / 1000.0));
                int milliseconds = span.Milliseconds;
                str6 = num6.ToString() + ((0x3e8 + milliseconds)).ToString() + (num5 + 0x3e8);
                RandomProxy rand = new RandomProxy(seed);
                StringBuilder builder = new StringBuilder();

                //只下载第一个分段
                for (int j = 0; j < count; j++)
                {
                    string str8 = "";
                    if (j < 0x10)
                    {
                        str8 = "0";
                    }
                    str8 = str8 + ConvertHex(j.ToString());
                    string str9 = this.getFileId(flvdata, j, rand);
                    builder.AppendFormat("http://f.youku.com/player/getFlvPath/sid/{0}_{1}/st/flv/fileid/{2}?K={3}#||#", new object[] { str6, str8, str9, key_list[j] });
                }
                flv = builder.ToString().Substring(0, builder.Length - 4);
            }
            catch
            {
                flv = "无法完成JSON ==> JavaScriptConvert.DeserializeObject的转换,可能目标网站编码已经改变";
            }
            return flv;
        }
Exemple #2
0
 public string getFileId(string flvdata, int segindex, RandomProxy rand)
 {
     string str = rand.cg_fun(flvdata);
     string str2 = rand.cg_fun(flvdata).Substring(0, 8);
     string str3 = segindex.ToString("X2");
     if (str3.Length == 1)
     {
         str3 = "0" + str3;
     }
     str3 = str3.ToUpper();
     string str4 = str.Substring(10, str.Length - 10);
     return (str2 + str3 + str4);
 }