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] [TabCompletion]
public class MyArgs public class MyArgs
{ {
[ArgRequired(PromptIfMissing = false), ArgShortcut("-a")] [ArgShortcut("-a")]
public string Author { get; set; } public string? Author { get; set; }
[ArgRequired(PromptIfMissing = true), ArgShortcut("-h")] [ArgRequired(PromptIfMissing = true), ArgShortcut("-h")]
public string Har { get; set; } public string Har { get; set; }
[ArgRequired(PromptIfMissing = false), ArgShortcut("-n")] [ArgShortcut("-n")]
public string Narrator { get; set; } public string? Narrator { get; set; }
[ArgRequired(PromptIfMissing = true), ArgShortcut("-t")] [ArgShortcut("-t")]
public string Title { get; set; } public string? Title { get; set; }
[ArgShortcut("-s")] [ArgShortcut("-s")]
public string Series { get; set; } public string? Series { get; set; }
} }
} }

View File

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