Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.
7 changes: 2 additions & 5 deletions src/CCVTAC.Main/Downloading/Downloader.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ open System

module Downloader =

[<Literal>]
let private programName = "yt-dlp"

let generateDownloadArgs audioFormat userSettings (mediaType: MediaType option) additionalArgs : string =
let writeJsonArg = "--write-info-json"
let trimFileNamesArg = "--trim-filenames 250"
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]

Expand Down
5 changes: 4 additions & 1 deletion src/CCVTAC.Main/Settings/Settings.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace CCVTAC.Main.Settings

open CCVTAC.Main
open CCFSharpUtils.Text
open Spectre.Console
open FSharpPlus
Expand Down Expand Up @@ -47,6 +46,7 @@ module Settings =
[<JsonPropertyName("tagDetectionPatterns")>] TagDetectionPatterns: TagDetectionPatterns
[<JsonPropertyName("renamePatterns")>] RenamePatterns: RenamePattern list
[<JsonPropertyName("normalizationForm")>] NormalizationForm : string
[<JsonPropertyName("downloaderCommand")>] DownloaderCommand : string
[<JsonPropertyName("downloaderUpdateCommand")>] DownloaderUpdateCommand : string
[<JsonPropertyName("downloaderAdditionalOptions")>] DownloaderAdditionalOptions : string option
}
Expand Down Expand Up @@ -75,6 +75,7 @@ module Settings =
}
RenamePatterns = []
NormalizationForm = "C" // Recommended for compatibility between Linux and macOS.
DownloaderCommand = String.Empty
DownloaderUpdateCommand = String.Empty
DownloaderAdditionalOptions = None
}
Expand All @@ -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)
Expand Down