Skip to content

Commit

Permalink
added experimental music playlist support
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuFlosoYT committed Feb 21, 2024
1 parent bb003fa commit acc0adf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
32 changes: 28 additions & 4 deletions FastWebDownloader/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using YoutubeDLSharp;
using YoutubeDLSharp.Metadata;
using System.Diagnostics;
using YoutubeDLSharp.Options;

namespace FastWebDownloader
Expand All @@ -20,7 +21,7 @@ public static void ReadFile()

list.RemoveAt(0);


Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("Are you downloading music? (y/n) (invalid inputs will be considered as 'n'): ");
char responseMusic = Console.ReadKey().KeyChar;
Expand All @@ -46,8 +47,23 @@ public static void ReadFile()

}

/* NOT YET IMPLEMENTED
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("Converting all audio files to the correct format");
Console.ForegroundColor = ConsoleColor.White;
//convert opus to mp3
string path = Path.Combine(Directory.GetCurrentDirectory(), "downloads");
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = $"cd {path} || for %f in (*.opus) do ffmpeg -i \"%f\" \"%~nf.mp3\" || del *.opus";
process.Start();
process.WaitForExit();
*/

Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("Do you want to wipe config.yaml? (y/n) (invalid inputs will be considered as 'n'): ");
Expand Down Expand Up @@ -95,11 +111,18 @@ public static async Task Download(string url, bool IsMusic)
RestrictFilenames = true
};

var optionsMusic = new OptionSet()
{
NoContinue = true,
RestrictFilenames = true,
};

if (IsMusic)
{
var resMusic = await ytdl.RunAudioDownload(
url,
AudioConversionFormat.Mp3
AudioConversionFormat.Mp3,
overrideOptions: optionsMusic
);
}
else
Expand Down Expand Up @@ -130,7 +153,7 @@ public static async Task DownloadPlaylist(string url, bool IsMusic)

var options = new OptionSet()
{
Exec = "for %f in (*.mp3 *.wav *.flac *.ogg) do ffmpeg -i \"%f\" \"%~nf.mp3\""
RestrictFilenames = true
};


Expand All @@ -144,7 +167,8 @@ public static async Task DownloadPlaylist(string url, bool IsMusic)
else
{
var res = await ytdl.RunVideoPlaylistDownload(
url
url,
overrideOptions: options
);
}

Expand Down
5 changes: 2 additions & 3 deletions FastWebDownloader/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ public static void MainMenu()
Console.WriteLine("3. Exit");
Console.ForegroundColor = ConsoleColor.White;


string input = Console.ReadLine();
if (int.TryParse(input, out int choice))
char response = Console.ReadKey().KeyChar;
if (int.TryParse(response.ToString(), out int choice))
{
if (choice < 1 || choice > 3)
{
Expand Down

0 comments on commit acc0adf

Please sign in to comment.