Beispiel #1
0
 private void AppendTextBox(string str)
 {
     this.Dispatcher.Invoke(() =>
     {
         TextBox_Result.AppendText($"[{DateTime.Now:T}] {str}\r\n");
         TextBox_Result.ScrollToEnd();
     });
 }
Beispiel #2
0
        private void Button_Go_Click(object sender, RoutedEventArgs e)
        {
            TextBox_Result.Text = "";
            string input = TextBox_Input.Text.Trim();

            results.Clear();
            int dfn = 4;

            if (Radio_0.IsChecked == true)
            {
                dfn = 0;
            }
            if (Radio_1.IsChecked == true)
            {
                dfn = 1;
            }
            if (Radio_2.IsChecked == true)
            {
                dfn = 2;
            }
            if (Radio_3.IsChecked == true)
            {
                dfn = 3;
            }
            if (Radio_4.IsChecked == true)
            {
                dfn = 4;
            }
            ThreadPool.QueueUserWorkItem((object state) =>
            {
                try
                {
                    if (input.Contains("/page/")) //批量
                    {
                        this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            string pid       = GetVidFromUrl(input.Split('\n')[0]);
                            string webSource = GetWebSource(
                                $"https://apis.web.pptv.com/show/videoList?from=web&version=1.0.0&format=jsonp&pid={pid}&cat_id=2&vt=22&tdsourcetag=s_pctim_aiomsg",
                                "Cookie:PUID=bf2a0e4f2cf24517c294-a68a65ed8c50;ppi=302c393939;"
                                ).Replace("{", "\r\n{");
                            //MessageBox.Show(webSource);
                            Regex regex             = new Regex("\"url\":\"(.*)\",\"capture.*isTrailer\":(.*),\"olt\"");
                            MatchCollection matches = regex.Matches(webSource);
                            if (matches.Count == 0)
                            {
                                return;
                            }
                            Button_Go.IsEnabled = false;
                            TextBox_Input.Text  = "";
                            StringBuilder sb    = new StringBuilder();
                            foreach (Match match in matches)
                            {
                                if (match.Groups[2].Value == "false")
                                {
                                    sb.Append(match.Groups[1].Value.Replace("\\/", "/") + "\r\n");
                                }
                            }
                            TextBox_Input.Text  = sb.ToString().Trim();
                            Button_Go.IsEnabled = true;
                        }));
                        return;
                    }

                    foreach (var item in input.Split('\n'))
                    {
                        this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            Button_Go.IsEnabled = false;
                            Button_Go.Content   = "解析中";
                        }));
                        string vid = GetVidFromUrl(item);
                        if (vid == "")
                        {
                            continue;
                        }
                        string api       = $"https://play.api.pptv.com/boxplay.api?platform=launcher&type=tv.android&id={vid}";
                        string webSource = new WebClient()
                        {
                            Encoding = Encoding.UTF8
                        }.DownloadString(api);
                        string fname   = "";
                        string rid     = "";
                        string sh      = "";
                        string key     = "";
                        Regex fnameRex = new Regex("nm=\"(.*)\".vip", RegexOptions.Compiled);
                        fname          = fnameRex.Match(webSource).Groups[1].Value;
                        Regex fileRex  = new Regex("<dt ft=\"" + dfn + "\"[\\s\\S]*<\\/dt>", RegexOptions.Compiled);
                        webSource      = fileRex.Match(webSource).Value;
                        fileRex        = new Regex("rid=\"(.*mp4)", RegexOptions.Compiled);
                        rid            = fileRex.Match(webSource).Groups[1].Value;
                        fileRex        = new Regex("sh>(.*)<", RegexOptions.Compiled);
                        sh             = fileRex.Match(webSource).Groups[1].Value;
                        fileRex        = new Regex("<key.*>(.*)</key>");
                        key            = fileRex.Match(webSource).Groups[1].Value;
                        if (sh == "" || rid == "" || key == "")
                        {
                            continue;
                        }
                        string videourl = $"https://{sh}/w/{rid}?platform=launcher&type=tv.android&k={key}";
                        results.Add(fname, videourl);
                        this.Dispatcher.BeginInvoke(new Action(() => TextBox_Result.AppendText(videourl + "\r\n")));
                    }
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Button_Go.IsEnabled = true;
                        Button_Go.Content   = "开始解析";
                        TextBox_Result.Text = TextBox_Result.Text.Trim();
                    }));
                }
                catch (Exception)
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Button_Go.IsEnabled = true;
                        Button_Go.Content   = "开始解析";
                        TextBox_Result.Text = TextBox_Result.Text.Trim();
                        MessageBox.Show("遇到了错误");
                    }));
                }
            }, null);
        }
Beispiel #3
0
 private void AppendTextBox(string str)
 {
     TextBox_Result.AppendText($"[{DateTime.Now:T}] {str}\r\n");
     TextBox_Result.ScrollToEnd();
 }