Added a already exists url option in Creds.priv.cs

This commit is contained in:
Mike Nolan 2024-10-19 03:43:06 -05:00
parent 3e04d02707
commit 7611dee5d2
3 changed files with 24 additions and 2 deletions

View File

@ -6,4 +6,8 @@ public static partial class Creds
public static string Password => _password; public static string Password => _password;
public static string DirectoryOnServer => _dir; public static string DirectoryOnServer => _dir;
public static int Port => _port;
public static string AlreadyExistsUrl=> _alreadyExists;
} }

View File

@ -8,13 +8,28 @@ using System.Diagnostics.CodeAnalysis;
using YoutubeExplode.Playlists; using YoutubeExplode.Playlists;
using YoutubeExplode.Channels; using YoutubeExplode.Channels;
YoutubeClient ytc=new YoutubeClient(); HttpClient http=new HttpClient();
YoutubeClient ytc=new YoutubeClient(http);
ConcurrentStack<VideoId> videoIds=new ConcurrentStack<VideoId>(); ConcurrentStack<VideoId> videoIds=new ConcurrentStack<VideoId>();
bool isRunning=true; bool isRunning=true;
async Task AddVideo(VideoId id) 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); await client.ConnectAsync(default);
using(var res=client.CreateCommand($"echo {DirectoryOnServer}/*-{id.Value}.mp4")) using(var res=client.CreateCommand($"echo {DirectoryOnServer}/*-{id.Value}.mp4"))
{ {

View File

@ -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 _username = "YOUR_SSH_USERNAME";
static string _password = "YOUR_SSH_PASSWORD"; static string _password = "YOUR_SSH_PASSWORD";
static string _dir = "YOUR_SSH_PATH"; 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
} }
``` ```