filepickup tasks (untested)
This commit is contained in:
parent
90f50b9e2b
commit
b49516451f
91
Program.cs
91
Program.cs
@ -24,6 +24,7 @@ namespace placeholdervo
|
||||
|
||||
private static ConcurrentQueue<string> scriptFragmentFiles = new ConcurrentQueue<string>();
|
||||
private static ConcurrentQueue<string> titleCardLines = new ConcurrentQueue<string>();
|
||||
private static ConcurrentDictionary<string, string> filePickups = new ConcurrentDictionary<string, string>();
|
||||
private static CancellationToken scriptFileCancellationToken;
|
||||
|
||||
//from when I cut it up into separate files
|
||||
@ -71,50 +72,48 @@ namespace placeholdervo
|
||||
// }
|
||||
// }
|
||||
|
||||
// private static async void filePickup()
|
||||
// {
|
||||
// while(true)
|
||||
// {
|
||||
// while(!scriptFragmentVoiceFiles.IsEmpty)
|
||||
// {
|
||||
// var files = Directory.GetFiles(conf.sync_dropoff);
|
||||
// Console.WriteLine($"files listed: {string.Join(", ", files)}");
|
||||
// Console.WriteLine($"hoping for: {string.Join(", ", scriptFragmentVoiceFiles.Keys)}");
|
||||
// // Console.WriteLine($"sanity check: first listed file: {Path.GetFileName(files.FirstOrDefault())}");
|
||||
// // Console.WriteLine($"sanity check: first key: {scriptFragmentVoiceFiles.Keys.FirstOrDefault()}");
|
||||
// // Console.WriteLine($"sanity check: first value: {scriptFragmentVoiceFiles[scriptFragmentVoiceFiles.Keys.FirstOrDefault()]}");
|
||||
// var audioFile = files.FirstOrDefault(f => scriptFragmentVoiceFiles.ContainsKey(Path.GetFileName(f)));
|
||||
// if(!string.IsNullOrWhiteSpace(audioFile))
|
||||
// {
|
||||
// Console.WriteLine($"found {audioFile}");
|
||||
// try
|
||||
// {
|
||||
// var bareAudioFile = Path.GetFileName(audioFile);
|
||||
// var destFile = scriptFragmentVoiceFiles[bareAudioFile];
|
||||
// destFile = Path.GetFileNameWithoutExtension(destFile) + ".wav";
|
||||
// destFile = Path.Combine(workingDir, destFile);
|
||||
// File.Move(audioFile, destFile);
|
||||
|
||||
// if(!scriptFragmentVoiceFiles.Remove(bareAudioFile, out string throwaway))
|
||||
// {
|
||||
// Console.WriteLine($"failed to remove {bareAudioFile}");
|
||||
// }
|
||||
// }
|
||||
// catch(Exception e)
|
||||
// {
|
||||
// Console.Error.WriteLine(e.Message);
|
||||
// }
|
||||
// }
|
||||
// System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
|
||||
// }
|
||||
// if(scriptFileCancellationToken.IsCancellationRequested)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
///<summary>mostly just to give myself the reminder about paths</summary>
|
||||
///<param name="src">the *complete path* of the awaited file. you might want conf.sync_dropoff</param>
|
||||
///<param name="dest">the *complete path* to move the file to.</param>
|
||||
private static async void awaitFile(string src, string dest)
|
||||
{
|
||||
filePickups[src] = dest;
|
||||
}
|
||||
private static async void filePickup()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
foreach(var srcKey in filePickups.Keys)
|
||||
{
|
||||
// var files = Directory.GetFiles(conf.sync_dropoff);
|
||||
// Console.WriteLine($"files listed: {string.Join(", ", files)}");
|
||||
// Console.WriteLine($"hoping for: {string.Join(", ", filePickups.Keys)}");
|
||||
// Console.WriteLine($"sanity check: first listed file: {Path.GetFileName(files.FirstOrDefault())}");
|
||||
// Console.WriteLine($"sanity check: first key: {scriptFragmentVoiceFiles.Keys.FirstOrDefault()}");
|
||||
// Console.WriteLine($"sanity check: first value: {scriptFragmentVoiceFiles[scriptFragmentVoiceFiles.Keys.FirstOrDefault()]}");
|
||||
if(File.Exists(srcKey))
|
||||
{
|
||||
Console.WriteLine($"found {srcKey}");
|
||||
string dest;
|
||||
if (filePickups.TryRemove(srcKey, out dest))
|
||||
{
|
||||
File.Move(srcKey, dest);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine($"Failed to remove {srcKey} from filepickups. Unrecoverable, I think.");
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(scriptFileCancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
// }
|
||||
// }
|
||||
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
@ -264,9 +263,9 @@ namespace placeholdervo
|
||||
}
|
||||
|
||||
// execute them all
|
||||
// Task.Run(OfflineStuff); //e.g., generate title cards and credits
|
||||
// Task.Run(ApiCalls); //e.g. generate voice
|
||||
// await Task.Run(FilePickups);
|
||||
//Task.Run(OfflineStuff);
|
||||
//Task.Run(ApiCalls);
|
||||
var fpTask = Task.Run(filePickup);
|
||||
|
||||
// cancelSource.Cancel();
|
||||
// Console.WriteLine("http client \"cancelled\".");
|
||||
|
Loading…
Reference in New Issue
Block a user