复制粘贴直接调用简单粗暴
[C#] 纯文本查看 复制代码 Ppx p = new Ppx("https://h5.pipix.com/s/MmdstMo/");
// p.GetAuthorHeadImage(); 得到作者头像
//p.GetTitle(); 得到视频标题
Console.WriteLine(p.GetMp4());
//得到原视频
封装好的类
[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
namespace Ppx_Jx
{
public class Ppx
{
JObject Json;
//json
public Ppx(string url)
{
GetLong(ref url);//长链接
GetMp4Id(ref url);//视频ID
GetData(url); //得到json
}
public void GetLong(ref string url)
{
var Beg = (HttpWebRequest)WebRequest.Create(url);
Beg.AllowAutoRedirect = false;
using (HttpWebResponse Ret = (HttpWebResponse)Beg.GetResponse())
url = Ret.Headers["location"];
}
//得到长链接
public void GetMp4Id(ref string url)
{
url = url.Substring(26, 19);
//得到视频ID
}
public string GetData(string mp4Id)
{
var Beg = (HttpWebRequest)WebRequest.Create($"https://ib-hl.snssdk.com/bds/cell/detail/?version_code=4.2.7&app_name=super&device_id=1988391945639406&channel=App%20Store&resolution=1170*2532&aid=1319&last_channel=App%20Store&last_update_version_code=42691&recommend_disable=0&update_version_code=42780&ac=WIFI&os_version=15.5&device_platform=iphone&iid=805274026772804&device_type=iPhone%2012&cell_id={mp4Id}&cell_type=1&api_version=1");
var Ret = (HttpWebResponse)Beg.GetResponse();
var Read = new StreamReader(Ret.GetResponseStream(), Encoding.UTF8);
string json = Read.ReadToEnd();
//序列化
Json = JObject.Parse(json);
Read.Dispose();
Ret.Dispose();
return json;
//得到JSON
}
public string GetCreateTime()
{
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
return startTime.AddSeconds(Convert.ToInt64(Json["data"]["data"]["display_time"])).ToString("yyy-MM-dd hh:mm:ss");
//得到发布时间
}
public string GetMp4()
{
return Json["data"]["data"]["item"]["video"]["video_high"]["url_list"][0]["url"].ToString();
}//得到原视频
public string GetTitle()
{
return Json["data"]["data"]["item"]["content"].ToString();
}//视频标题
public string GetHeightCover()
{
return "https://p9-ppx.byteimg.com/img/" + Json["data"]["data"]["item"]["cover"]["uri"].ToString() + "~1280x720.jpg";
//得到高清封面图 720
}
public string GetAouthorName()
{
return Json["data"]["data"]["item"]["author"]["name"].ToString();
//名称
}
public string GetAuthorHeadImage()
{
return "https://p3-ppx.byteimg.com/img/" + Json["data"]["data"]["item"]["author"]["avatar"]["uri"].ToString()+ "~tplv-ppx-avatar:200:200:q100.jpg";
//作者头像 jpg类型
}
}
}
|