Fixing some warnings and removing extraneous required args.

This commit is contained in:
matt
2024-03-30 12:49:34 +01:00
parent fd461a2629
commit 9293351b77
2 changed files with 10 additions and 11 deletions

View File

@@ -5,19 +5,19 @@ namespace SBT_Downloader
[TabCompletion]
public class MyArgs
{
[ArgRequired(PromptIfMissing = false), ArgShortcut("-a")]
public string Author { get; set; }
[ArgShortcut("-a")]
public string? Author { get; set; }
[ArgRequired(PromptIfMissing = true), ArgShortcut("-h")]
public string Har { get; set; }
[ArgRequired(PromptIfMissing = false), ArgShortcut("-n")]
public string Narrator { get; set; }
[ArgShortcut("-n")]
public string? Narrator { get; set; }
[ArgRequired(PromptIfMissing = true), ArgShortcut("-t")]
public string Title { get; set; }
[ArgShortcut("-t")]
public string? Title { get; set; }
[ArgShortcut("-s")]
public string Series { get; set; }
public string? Series { get; set; }
}
}

View File

@@ -1,7 +1,6 @@
using PowerArgs;
using Newtonsoft.Json.Linq;
using System.Net;
using System;
namespace SBT_Downloader
{
@@ -12,7 +11,7 @@ namespace SBT_Downloader
Console.WriteLine("Welcome to the Sound Booth Theater Personal Archiving Tool!");
try
{
var parsed = Args.Parse<MyArgs>(args);
MyArgs parsed = Args.Parse<MyArgs>(args);
Console.WriteLine("Downloading book now...");
(List<string> mp3Urls, List<string> chapters) = ParseHar(parsed.Har);
DownloadMp3s(mp3Urls, chapters, parsed);
@@ -30,7 +29,7 @@ namespace SBT_Downloader
{
string harContents = LoadHar(har);
JObject harObject = JObject.Parse(harContents);
List<JToken?> requestObjects = ParseRequests(harObject);
List<JToken> requestObjects = ParseRequests(harObject);
List<string> mp3Urls = ParseUrls(requestObjects);
List<string> chapters = ParseChapters(mp3Urls);
return (mp3Urls, chapters);
@@ -107,7 +106,7 @@ namespace SBT_Downloader
var file = TagLib.File.Create($"{chapterNumber} {chapterName}.mp3");
file.Tag.Album = arguments.Title.IsNullOrEmpty() ? string.Empty : arguments.Title;
List<string> artistsList = new List<string>();
List<string> artistsList = new();
if (!arguments.Author.IsNullOrEmpty()) artistsList.Add(arguments.Author);
if (!arguments.Narrator.IsNullOrEmpty()) artistsList.Add(arguments.Narrator);
file.Tag.AlbumArtists = artistsList.ToArray();