抖音无水印小视频解析工具DouYinDownLoader v1.0

抖音小视频解析工具DouYinDownLoader v1.0支持解析抖音无水印视频链接并直接下载

软件简介

抖音无水印小视频解析工具DouYinDownLoader v1.0

软件名称 DouYinDownLoader
软件版本 v1.0
软件类别 下载工具
适用平台 Windows
最近更新 2020.04.23

使用说明

支持分享的短链接和长链接

C#源代码

  1. using System;  
  2. using System.ComponentModel;  
  3. using System.IO;  
  4. using System.Net;  
  5. using System.Net.Http;  
  6. using System.Text.RegularExpressions;  
  7. using System.Windows.Forms;  
  8. using Newtonsoft.Json;  
  9.    
  10. namespace DouYinDownLoader  
  11. {  
  12.     public partial class Form1 : Form  
  13.     {  
  14.         private static HttpClient httpClient;  
  15.    
  16.         public Form1()  
  17.         {  
  18.             InitializeComponent();  
  19.    
  20.             HttpClientHandler handler = new HttpClientHandler();  
  21.             handler.UseCookies = false;  
  22.             httpClient = new HttpClient(handler);  
  23.             httpClient.DefaultRequestHeaders.Add("User-Agent""Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1");  
  24.         }  
  25.    
  26.         private async void button1_ClickAsync(object sender, EventArgs e)  
  27.         {  
  28.             var url = textBox1.Text.Trim();  
  29.             if (string.IsNullOrEmpty(url))  
  30.             {  
  31.                 MessageBox.Show("网址不能为空");  
  32.                 return;  
  33.             }  
  34.             var html = await httpClient.GetStringAsync(url);  
  35.             var match = Regex.Match(html, "itemId: \"(\\d+)\"");  
  36.             if (match.Success)  
  37.             {  
  38.                 var itemId = match.Groups[1].ToString();  
  39.                 var json = await httpClient.GetStringAsync($"https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={itemId}");  
  40.                 var jsonObj = JsonConvert.DeserializeObject<dynamic>(json);  
  41.                 if (jsonObj.status_code == 0)  
  42.                 {  
  43.                     var videoUrl = jsonObj.item_list[0].video.play_addr.url_list[0].ToString();  
  44.                     var videoName = jsonObj.item_list[0].desc;  
  45.                     var saveDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "videos");  
  46.                     var saveFile = Path.Combine(saveDir, $"{videoName}.mp4");  
  47.                     if (!Directory.Exists(saveDir))  
  48.                     {  
  49.                         Directory.CreateDirectory(saveDir);  
  50.                     }  
  51.                     if (!File.Exists(saveFile))  
  52.                     {  
  53.                         var downLoader = new WebClient();  
  54.                         downLoader.Headers.Add("User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1");  
  55.                         downLoader.DownloadFileAsync(new Uri(videoUrl), saveFile);  
  56.                         downLoader.DownloadFileCompleted += DownLoader_DownloadFileCompleted;  
  57.                         downLoader.DownloadProgressChanged += DownLoader_DownloadProgressChanged;  
  58.                     }  
  59.                     else  
  60.                     {  
  61.                         label1.Text = "文件已存在,无需重复下载!";  
  62.                     }  
  63.                 }  
  64.                 else  
  65.                 {  
  66.                     MessageBox.Show("解析失败!");  
  67.                 }  
  68.             }  
  69.             else  
  70.             {  
  71.                 MessageBox.Show("未找到视频!");  
  72.             }  
  73.         }  
  74.    
  75.         private void DownLoader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)  
  76.         {  
  77.             label1.Text = $"下载中 {e.TotalBytesToReceive / 1024}kb - {e.BytesReceived / 1024}kb";  
  78.             progressBar1.Value = e.ProgressPercentage;  
  79.         }  
  80.    
  81.         private void DownLoader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)  
  82.         {  
  83.             label1.Text = "下载完成";  
  84.         }  
  85.     }  
  86. }  

附件下载

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
搜索