Compare commits

..

4 Commits

Author SHA1 Message Date
Chris Plaatjes
2261e753d5 Implemented timestamp logging
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-15 12:20:23 -05:00
Chris Plaatjes
88dd3b5908 Added better link processing and logging 2023-02-15 12:20:07 -05:00
Chris Plaatjes
f8f94b4afc Added better link processing 2023-02-15 12:19:40 -05:00
Chris Plaatjes
309d7c0cd3 Added better log messaging 2023-02-15 12:17:08 -05:00
3 changed files with 32 additions and 4 deletions

View File

@ -22,5 +22,12 @@ namespace TeleTok
listener.RunListener();
}
public static void LogMessage(string text)
{
DateTime now =DateTime.Now;
Console.WriteLine("[" + now.ToString() + "] " + text);
}
}
}

View File

@ -77,7 +77,7 @@ namespace TeleTok
_ => exception.ToString()
};
Console.WriteLine(ErrorMessage);
TeleTok.LogMessage(ErrorMessage);
return Task.CompletedTask;
}
}

View File

@ -12,15 +12,16 @@ namespace TeleTok
string url = videourl;
string proxyUrl;
DateTime now =DateTime.Now;
TeleTok.LogMessage("Video for " + videourl + " processing..");
if(url.Contains("vm.tiktok.com"))
{
url = UnshortenUrl(url);
}
proxyUrl = TeleTok.ptInstance + "/download?url=" + url;
Console.WriteLine("[" + now.ToString() + "] " + "Video for " + url + " has been sent..");
proxyUrl = CreateDownloadLink(url);
TeleTok.LogMessage("");
return proxyUrl;
}
@ -35,5 +36,25 @@ namespace TeleTok
return realUrl;
}
//Breaks apart the URL and extracts the User and Video ID to be processed into a working download link
static string CreateDownloadLink(string videourl)
{
Uri segmentedUri = new Uri(videourl);
segmentedUri = new Uri(segmentedUri.AbsoluteUri.Replace(segmentedUri.Query, string.Empty));
string videoUser = segmentedUri.Segments[1];
videoUser = videoUser.Replace(@"/", "");
string videoID = segmentedUri.Segments[3];
string fixedUrl = "https://www.tiktok.com/" + videoUser + "/video/" + videoID + @"&id=" + videoID + @"&user=" + videoUser.Remove(0);
string proxyLink = TeleTok.ptInstance + "/download?url=" + fixedUrl;
TeleTok.LogMessage("Input User ID is: " + videoUser);
TeleTok.LogMessage("Input video ID is: " + videoID);
return proxyLink;
}
}
}