I have a C# program I’m working on where I want to have a predefined dictionary list of playlist names (key) and a corresponding YouTube playlist link (value), which I iterate through to feed to yt-dlp.exe to generate a full list of each playlists’ video information.
I can get the process to start, but it always throws an error partway through on what seems like a URL parsing issue. I tried taking it out of the iteration loop but it’s still happening. The related code (with error logging logic) so far:
var operatingDir = @"C:Userspath-to-dir-goes-here";
var videoPlaylists = new Dictionary<string, string>();
videoPlaylists["alpha"] = "https://www.youtube.com/playlist?list=PLrhpb4TQr-uKzxOB1C_9x-Ysrj2WRMZN_";
videoPlaylists["bravo"] = "https://www.youtube.com/playlist?list=PLcLtbK8Nf64InyudI1rnYwwRbCr08yup_";
videoPlaylists["charlie"] = "https://www.youtube.com/playlist?list=PLS9Gv3hDYt_Uh_bI6m2S20siUfPUk1I1b";
var playbackIndex = new Dictionary<string, double>();
string ytDlpPath = operatingDir + "yt-dlp.exe";
string ytDlpArgs = "";
ProcessStartInfo runYtDlp = new ProcessStartInfo();
runYtDlp.FileName = @ytDlpPath;
ytDlpArgs = "--skip-download --ignore-errors --flat-playlist --playlist-random --force-overwrites --print "https://www.youtube.com/embed/%(id)s?controls=0&autoplay=1&cc_load_policy=1&cc_lang_pref=en %(title)s %(duration)s" "" + videoPlaylists["alpha"] + "" > "" + operatingDir + "alpha" + ".txt"";
runYtDlp.Arguments = ytDlpArgs;
Process process = new Process();
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo = runYtDlp;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process = Process.Start(runYtDlp);
process.WaitForExit();
Console.ReadKey();
yt-dlp always gets about 80 lines into writing to the file when this error hits:
ERROR: [generic] '>' is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:>" ) to search YouTube
ERROR: Unable to handle request: Unsupported url scheme: "c" (requests, urllib, websockets, curl_cffi)
I don’t think it’s yt-dlp itself because when I input the arguments directly in the command line it runs fine. Am I formatting my argument string wrong or something?