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
|
|
|
|
public 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
|
|
|
|
|
|
|
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-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
|
|
|
|
// If the URL is already the full one, it won't really do anything but will catch shortened ones
|
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
|
|
|
}
|
|
|
|
}
|