Skip to content

Commit

Permalink
added playlist support
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuFlosoYT committed Feb 22, 2024
1 parent acc0adf commit b8d3a73
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 27 deletions.
1 change: 1 addition & 0 deletions FastWebDownloader/Boot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace FastWebDownloader
public class FWD
{
public static string path = Path.Combine(Directory.GetCurrentDirectory(), "config.yaml");
public static string downloadsPath = Path.Combine(Directory.GetCurrentDirectory(), "downloads");
public static string YtDlppath = Path.Combine(Directory.GetCurrentDirectory(), "yt-dlp.exe");
public static string FFmpegpath = Path.Combine(Directory.GetCurrentDirectory(), "ffmpeg.exe");

Expand Down
62 changes: 45 additions & 17 deletions FastWebDownloader/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Diagnostics;
using YoutubeDLSharp.Options;


namespace FastWebDownloader
{
public class Downloader
Expand Down Expand Up @@ -47,22 +48,45 @@ public static void ReadFile()

}

/* NOT YET IMPLEMENTED

Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("Converting all audio files to the correct format");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine("Deleting temporal files...");
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();
//foreach file in a directory remove spaces from the file name
foreach (string filePath in Directory.EnumerateFiles(FWD.downloadsPath))
{
string fileName = Path.GetFileNameWithoutExtension(filePath);
string fileExtension = Path.GetExtension(filePath);

//In the string the is a "[" and "]", delete everything between them and the brackets
if (fileName.Contains("[") && fileName.Contains("]"))
{
int start = fileName.IndexOf('[');
int end = fileName.IndexOf(']');
fileName = fileName.Remove(start, end - start + 1);
}

//Delete any non alphanumeric characters
fileName = System.Text.RegularExpressions.Regex.Replace(fileName, "[^a-zA-Z0-9_]+", "", System.Text.RegularExpressions.RegexOptions.Compiled);

//If string has 2 or more consecutive underscores, remove one
fileName = System.Text.RegularExpressions.Regex.Replace(fileName, "(_{2,})", "_", System.Text.RegularExpressions.RegexOptions.Compiled);

//If the file name is the same as the new file name, skip it
try
{
File.Move(filePath, Path.Combine(FWD.downloadsPath, fileName + fileExtension));
}
catch (IOException)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Error renaming {fileName}");
Console.ForegroundColor = ConsoleColor.White;
}
}

*/

Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Yellow;
Expand All @@ -80,8 +104,6 @@ public static void ReadFile()
}




public static async Task Download(string url, bool IsMusic)
{
var ytdl = new YoutubeDL();
Expand All @@ -100,7 +122,7 @@ public static async Task Download(string url, bool IsMusic)
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write($" {title} ");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write($" to ");
Console.Write($"to ");
Console.ForegroundColor = ConsoleColor.Magenta;
Console.Write($"{ytdl.OutputFolder}");
Console.WriteLine();
Expand All @@ -115,13 +137,13 @@ public static async Task Download(string url, bool IsMusic)
{
NoContinue = true,
RestrictFilenames = true,
AudioFormat = AudioConversionFormat.Mp3
};

if (IsMusic)
{
var resMusic = await ytdl.RunAudioDownload(
url,
AudioConversionFormat.Mp3,
url,
overrideOptions: optionsMusic
);
}
Expand Down Expand Up @@ -156,12 +178,18 @@ public static async Task DownloadPlaylist(string url, bool IsMusic)
RestrictFilenames = true
};

var optionsMusic = new OptionSet()
{
RestrictFilenames = true,
AudioFormat = AudioConversionFormat.Mp3
};


if (IsMusic)
{
var res = await ytdl.RunAudioPlaylistDownload(
url,
overrideOptions: options
overrideOptions: optionsMusic
);
}
else
Expand Down
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ An easy way to bulk download videos

## Tutorial

https://youtu.be/O5OVfGqE_po
Not yet available :(

## Features

- Easily and Silently bulk install programs
- UltraSilent bulk install mode
- Easily download videos from the web
- Portable configuration file

## Screenshots

Expand All @@ -27,17 +27,15 @@ No instalation needed.

## Usage

1. Launch FBI to create "config.yaml" file
2. Select option 1 to check available programs on the database
3. Copy the codenames and paste them on "config.yaml"
4. Select how you want to install
1. (Via the FBI UI) Select option 2 on the main menu to install
2. (UltraSilent) (FastWebDownloader.exe /S) via cmd
1. Launch FWD to create "config.yaml" file
2. Copy YouTube URLs and paste them on "config.yaml"
3. Select if you want them to be downloaded as audio or video
4. Wait for the downloads to finish


## Contributing

Contributions expanding the database are always welcomed! To contribute open a new issue with the database tag.
Contributions are always welcomed! To contribute open a new issue and fork the proyect.
[FBI database](https://pastebin.com/XkgNYRTL)

## Reposting
Expand Down

0 comments on commit b8d3a73

Please sign in to comment.