Compare commits
No commits in common. "ae4c436a1a9042d6fcba99c56ad9916653439b01" and "be8f1caf35cc8816e70b0af9987d9a428894b08e" have entirely different histories.
ae4c436a1a
...
be8f1caf35
@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
|
||||||
name: build-app
|
name: build-app
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
19
Program.cs
19
Program.cs
@ -60,27 +60,12 @@ namespace TeleTok
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var chatId = message.Chat.Id;
|
var chatId = message.Chat.Id;
|
||||||
var messageText = update.Message.Text;
|
|
||||||
|
|
||||||
string videoPath;
|
bool isUri = Uri.IsWellFormedUriString(message.ToString(), UriKind.RelativeOrAbsolute);
|
||||||
|
|
||||||
// Checks if the text contains a valid URL
|
|
||||||
bool isUri = Uri.IsWellFormedUriString(messageText, UriKind.RelativeOrAbsolute);
|
|
||||||
|
|
||||||
// Passes the url along to the video downloader if it is valid AND a tiktok link
|
|
||||||
if (isUri)
|
if (isUri)
|
||||||
{
|
{
|
||||||
if(messageText.Contains("tiktok.com"))
|
Regex isTikTok = new Regex(@"(?x)(http(s)?:\/\/)?(?:www|m)\.(?:tiktok.com)\/(?:v|embed|trending)(?:\/)?(?:\?shareId=)?(?P<id>[\da-z]+)", RegexOptions.Singleline);
|
||||||
{
|
|
||||||
videoPath = VidDownload.TikTokUrl(messageText);
|
|
||||||
|
|
||||||
Message ttVideo = await botClient.SendVideoAsync(
|
|
||||||
chatId: chatId,
|
|
||||||
videoPath: videoPath,
|
|
||||||
supportsStreaming: true,
|
|
||||||
cancellationToken: cancellationToken
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Received a '{messageText}' message in chat {chatId}.");
|
Console.WriteLine($"Received a '{messageText}' message in chat {chatId}.");
|
||||||
|
@ -5,41 +5,6 @@ namespace TeleTok
|
|||||||
{
|
{
|
||||||
public class VidDownload
|
public class VidDownload
|
||||||
{
|
{
|
||||||
static void TikTokURL(string videourl)
|
|
||||||
{
|
|
||||||
string url = videourl;
|
|
||||||
|
|
||||||
if(url.Contains("vm.tiktok.com"))
|
|
||||||
{
|
|
||||||
url = UnshortenUrl(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
var proc = new Process
|
|
||||||
{
|
|
||||||
// Function downloads tiktok urls passed from the listener
|
|
||||||
StartInfo = new ProcessStartInfo
|
|
||||||
{
|
|
||||||
FileName = "/bin/bash",
|
|
||||||
Arguments = "-c \"tiktok-scraper --filepath /app/videos -d " + videourl + "\"",
|
|
||||||
UseShellExecute = false,
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
CreateNoWindow = true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
proc.Start();
|
|
||||||
proc.WaitForExit();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user