本帖最后由 dpc520 于 2022-10-25 22:36 编辑
皮皮虾无水印解析源码
微视无水印解析源码
皮皮搞笑无水印解析
快手无水印解析 支持背景音乐
西瓜视频无水印解析源码
已经封装好类库了 简单粗暴 直接拿去使用
拒绝白嫖 给个免费评分来点动力!!!
调用:
[C#] 纯文本查看 复制代码 Dy d = new Dy(); string[] array = d.GetAll ("1.58 DUY:/ 复制打开抖音,看看【翼装飞行_张树鹏的作品】低空跳伞穿越天门山云海# 翼装飞行张树鹏 # 极限跳伞... https://v.douyin.com/MNGx5Mr/");
//0视频标题 1发布时间 2封面 3视频链接 4音乐链接 5作者名称 6=“mp4”
//长度为7 并且 6号元素为mp4 表示为视频 为null为报异常 其他就是图片集
//也可以单独调用 d.GetMuiscUrl();
类库:
[C#] 纯文本查看 复制代码 using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace WeChat
{
public class Dy
{
public JObject Json;
//公共JS
public void GetLowerUrl(ref string url)
{
url = url.Substring(url.IndexOf("https://v.douyin.com"), 29);
//分割出短链接
}
public void GetId(ref string url)
{
HttpWebRequest Beg = (HttpWebRequest)WebRequest.Create(url);
Beg.AllowAutoRedirect = false;
WebResponse Response = Beg.GetResponse();
string str = Response.Headers["Location"];
url = str.Substring(str.IndexOf("video/") + 6, 19);
Response.Dispose();
// 得到视频ID 需要传递短链接
}
public void GetJson(ref string id)
{
//得到JSON字符串
string data = string.Empty;
HttpWebRequest Beg = (HttpWebRequest)WebRequest.Create("https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids="+id);
using( HttpWebResponse Ret =(HttpWebResponse)Beg.GetResponse ())
{
using (StreamReader ReadData = new StreamReader( Ret.GetResponseStream(), Encoding.UTF8))
id= ReadData.ReadToEnd();
}
}
public void FormatJson(string json)
{
JObject Ob = JObject.Parse(json);
JArray Convert = (JArray)Ob["item_list"];
Json =JObject.Parse( Convert[0].ToString());
//去转换
}
public string GetMuiscUrl()
{
//string[] muisc =
// { Json["music"]["play_url"]["uri"].ToString(), //0音乐链接
// Json["music"]["title"].ToString(), //1音乐标题
// };
//0音乐链接 1音乐标题
return Json["music"]["play_url"]["uri"].ToString();
//得到音乐链接
}
public string GetTitle()
{
string title = Json["desc"].ToString();
title= title.Replace("#","@");
return title;
//得到视频标题
}
public string GetCreateTime()
{
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
startTime = startTime.AddSeconds(Convert.ToInt64(Json["create_time"]));
string dateTime = $"{startTime.Year}年{startTime.Month}月{startTime.Day}日 {startTime.Hour}:{startTime.Minute}:{startTime.Second}";
//得到发布的时间
return dateTime;
}
public string GetVideoUrl()
{
string url = Json["video"]["play_addr"]["uri"].ToString();
return "https://aweme.snssdk.com/aweme/v1/play/?video_id="+url;
}
//得到源视频链接
public string GetCover()
//封面
{
return Json["video"]["dynamic_cover"]["url_list"][0].ToString();
}
public string[] GetImageUrl()
{
//StringBuilder Sb = new StringBuilder(5000);
JArray ImgUrl = (JArray)Json["images"];
string[] Image = new string[ImgUrl.Count];
int index = 1;//校正图片索引
for (int i = 0; i < ImgUrl.Count; i++)
{
JArray url = (JArray)ImgUrl[i]["url_list"];
Image[i]= url[3].ToString();
// Sb.Append($"<a href=\"{url[3]}\">图片{index++}</a>\n");
}
return Image;
}//图片集处理
public string[] GetAll(string txt)
{
//string str =string.Empty;
string[] Data;
GetLowerUrl(ref txt);//返回短链接
GetId(ref txt);//通过短链接 得到视频ID
GetJson(ref txt); //通过id 获得json
FormatJson(txt);
if (txt.Contains("\"images\":null,")) //表示为视频
{
Data = new string[7];
// Data[0] = GetTitle(); GetCreateTime(); GetCover(); GetVideoUrl(); GetMuiscUrl(); GetHostName() ;
//0视频标题 1发布时间 2封面 3视频链接 4音乐链接 5作者名称
Data[0] = GetTitle();
Data[1]= GetCreateTime();
Data[2] = GetCover();
Data[3]= GetVideoUrl();
Data[4]=GetMuiscUrl();
Data[5]= GetHostName();
Data[6] = "mp4";
// str = $"{Data[5]}:\n{Data[0]}\n\n<a href=\"{Data[3]}\">无水印视频</a> <a href=\"{Data[4]}\">完整版音乐</a>";
}
else
{
Data = GetImageUrl();
// if (str.Length > 1660) str = "解析成功,但因图片过多腾讯限制数量,请前往网页版";
// str = str.Length < 1660 ? $"{GetHostName()}:\n{GetTitle()}\n\n" + GetImageUrl() : "解析成功,但因图片过多腾讯限制数量,请前往网页版";
// str =;
}
return Data;
}
public string GetHostName()
{
return Json["author"]["nickname"].ToString();
}
}
}
|