From 7611dee5d239d6c7e13d5c52958ecb4d7bc63b91 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Sat, 19 Oct 2024 03:43:06 -0500 Subject: [PATCH] Added a already exists url option in Creds.priv.cs --- Creds.cs | 4 ++++ Program.cs | 19 +++++++++++++++++-- README.md | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Creds.cs b/Creds.cs index a304aa0..14bfbed 100644 --- a/Creds.cs +++ b/Creds.cs @@ -6,4 +6,8 @@ public static partial class Creds public static string Password => _password; public static string DirectoryOnServer => _dir; + + public static int Port => _port; + + public static string AlreadyExistsUrl=> _alreadyExists; } \ No newline at end of file diff --git a/Program.cs b/Program.cs index 440bb06..1db4f02 100644 --- a/Program.cs +++ b/Program.cs @@ -8,13 +8,28 @@ using System.Diagnostics.CodeAnalysis; using YoutubeExplode.Playlists; using YoutubeExplode.Channels; -YoutubeClient ytc=new YoutubeClient(); +HttpClient http=new HttpClient(); +YoutubeClient ytc=new YoutubeClient(http); ConcurrentStack videoIds=new ConcurrentStack(); bool isRunning=true; async Task AddVideo(VideoId id) { - using(SshClient client = new SshClient(IP,Username,Password)){ + if(!string.IsNullOrWhiteSpace(AlreadyExistsUrl)) + { + try{ + if(await http.GetStringAsync($"{AlreadyExistsUrl}{id.Value}") == "true") + { + Console.WriteLine($"{AlreadyExistsUrl}{id.Value} returned true skipping: https://www.youtube.com/watch?v={id.Value}"); + return; + } + }catch(Exception) + { + + } + } + + using(SshClient client = new SshClient(IP,Port,Username,Password)){ await client.ConnectAsync(default); using(var res=client.CreateCommand($"echo {DirectoryOnServer}/*-{id.Value}.mp4")) { diff --git a/README.md b/README.md index 108323f..ab7988b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ To Configure you must add a file called Creds.priv.cs with the following content static string _username = "YOUR_SSH_USERNAME"; static string _password = "YOUR_SSH_PASSWORD"; static string _dir = "YOUR_SSH_PATH"; + static int _port = 22; + + static string _alreadyExists=""; //must be http(s) url such as https://tytdarchive.site.tesses.net/have.php?v= that the response must return "true" if it already exists or "false" if not } ```