TeleTok/VidDownload.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2023-02-13 19:18:49 -05:00
using System;
using System.Diagnostics;
2023-02-14 12:04:24 -05:00
using System.Net;
2023-02-13 19:18:49 -05:00
namespace TeleTok
{
public class VidDownload
{
2023-02-14 12:04:24 -05:00
// Takes the scraped TikTok URL and appends it to the proxy downloader link then returns it
2023-02-14 13:59:20 -05:00
public static string TikTokURL(string videourl)
2023-02-14 00:35:28 -05:00
{
string url = videourl;
2023-02-14 12:04:24 -05:00
string proxyUrl;
2023-02-14 00:35:28 -05:00
2023-02-15 10:05:14 -05:00
DateTime now =DateTime.Now;
2023-02-14 00:35:28 -05:00
if(url.Contains("vm.tiktok.com"))
{
url = UnshortenUrl(url);
}
2023-02-14 12:04:24 -05:00
proxyUrl = TeleTok.ptInstance + "/download?url=" + url;
2023-02-15 10:05:14 -05:00
Console.WriteLine("[" + now.ToString() + "] " + "Video for " + url + " has been sent..");
2023-02-14 00:35:28 -05:00
2023-02-14 12:04:24 -05:00
return proxyUrl;
2023-02-14 00:35:28 -05:00
}
2023-02-14 12:04:24 -05:00
// Runs the URL through a web request then returns the full url
2023-02-14 00:35:28 -05:00
static string UnshortenUrl(string videourl)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(videourl);
req.AllowAutoRedirect = false;
var resp = req.GetResponse();
string realUrl = resp.Headers["Location"];
return realUrl;
}
2023-02-13 19:18:49 -05:00
}
}