diff --git a/README.md b/README.md index 6ba778a..b5ebdc2 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,10 @@ The sample below contains explanations and some example values as well. // Reference: https://en.wikipedia.org/wiki/Unicode_equivalence "normalizationForm": "C", + // The full path or else (if the program name is available in your terminal) name + // of yt-dlp on your system. + "downloaderCommand": "yt-dlp", + // The full command you use to update your local yt-dlp installation. // This is a sample entry. "downloaderUpdateCommand": "pip install --upgrade yt-dlp", @@ -215,10 +219,10 @@ If you run into any issues, feel free to create an issue on GitHub. Please provi However, do keep in mind that this is ultimately a hobby project for myself, so I cannot guarantee every issue will be fixed. -## History +## Development History The first incarnation of this application was written in C#. However, after picking up [F#](https://fsharp.org/) out of curiosity about it and functional programming (FP) in 2024 and successfully using it to create other tools (mainly [Audio Tag Tools](https://github.com/codeconscious/audio-tag-tools/)) in an FP style, I become curious about F#'s OOP capabilities as well. -As an experiment, I rewrote this application in OOP-style F#, using LLMs solely for the rough initial conversion (which greatly reduced the overall time and labor necessary at the cost of requiring a *lot* of manual cleanup). Ultimately, I was surprised how much I preferred the F# code over the C#, so I decided to keep this tool in F#. +As an experiment, I rewrote this application in OOP-style F# using LLMs, which greatly reduced the overall time and labor necessary at the cost of requiring a *lot* of manual cleanup. Ultimately, I was surprised how much I preferred the F# code over the C#, so I decided to keep this tool in F#. Due to this background, the code is not particularly idiomatic F#, but it is certainly perfectly viable in its current blended-style form. That said, I'll probably tweak it over time to gradually to introduce more idiomatic F# code. diff --git a/src/CCVTAC.Main/Downloading/Downloader.fs b/src/CCVTAC.Main/Downloading/Downloader.fs index 239a111..96e9936 100644 --- a/src/CCVTAC.Main/Downloading/Downloader.fs +++ b/src/CCVTAC.Main/Downloading/Downloader.fs @@ -13,9 +13,6 @@ open System module Downloader = - [] - let private programName = "yt-dlp" - let generateDownloadArgs audioFormat userSettings (mediaType: MediaType option) additionalArgs : string = let writeJsonArg = "--write-info-json" let trimFileNamesArg = "--trim-filenames 250" @@ -83,7 +80,7 @@ module Downloader = let attemptAudioFormat format errors = let args = generateDownloadArgs (Some format) userSettings (Some mediaType) (Some [url]) - let commandWithArgs = $"{programName} {args}" + let commandWithArgs = $"{userSettings.DownloaderCommand} {args}" let downloadSettings = ToolSettings.create commandWithArgs userSettings.WorkingDirectory let downloadResult = runTool printer downloadSettings [1] @@ -125,7 +122,7 @@ module Downloader = | None -> Ok "No supplementary metadata link found." | Some url' -> let args = generateDownloadArgs None userSettings None (Some [url']) - let commandWithArgs = $"{programName} {args}" + let commandWithArgs = $"{userSettings.DownloaderCommand} {args}" let downloadSettings = ToolSettings.create commandWithArgs userSettings.WorkingDirectory let metadataDownloadResult = runTool printer downloadSettings [1] diff --git a/src/CCVTAC.Main/Settings/Settings.fs b/src/CCVTAC.Main/Settings/Settings.fs index 5327b2d..1c2d383 100644 --- a/src/CCVTAC.Main/Settings/Settings.fs +++ b/src/CCVTAC.Main/Settings/Settings.fs @@ -1,6 +1,5 @@ namespace CCVTAC.Main.Settings -open CCVTAC.Main open CCFSharpUtils.Text open Spectre.Console open FSharpPlus @@ -47,6 +46,7 @@ module Settings = [] TagDetectionPatterns: TagDetectionPatterns [] RenamePatterns: RenamePattern list [] NormalizationForm : string + [] DownloaderCommand : string [] DownloaderUpdateCommand : string [] DownloaderAdditionalOptions : string option } @@ -75,6 +75,7 @@ module Settings = } RenamePatterns = [] NormalizationForm = "C" // Recommended for compatibility between Linux and macOS. + DownloaderCommand = String.Empty DownloaderUpdateCommand = String.Empty DownloaderAdditionalOptions = None } @@ -99,6 +100,8 @@ module Settings = ("Working directory", settings.WorkingDirectory) ("Move-to directory", settings.MoveToDirectory) ("History log file", settings.HistoryFile) + ("Downloader command", settings.DownloaderCommand) + ("Downloader update command", settings.DownloaderUpdateCommand) ("Split video chapters", onOrOff settings.SplitChapters) ("Embed images", onOrOff settings.EmbedImages) ("Quiet mode", onOrOff settings.QuietMode)