-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed UI Changed Program needs admin permission to check if ffmpeg is installed Removed unused using statements Removed Crypt.cs since its useless for this project
- Loading branch information
1 parent
2396209
commit af5b2ee
Showing
6 changed files
with
172 additions
and
132 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Net; | ||
using System.IO.Compression; | ||
using System.IO; | ||
using System.Threading; | ||
|
||
namespace ListRipper | ||
{ | ||
class FFMPEGManager | ||
{ | ||
private static bool isDownloaded = false; | ||
|
||
public static Task setupFFMPEG() | ||
{ | ||
|
||
bool hasAgreed = false; | ||
Console.Clear(); | ||
FLSharp.PrintColor("FFMPEG has not been installed.", "yellow"); | ||
FLSharp.PrintColor("Do you want to get it set up? (not having FFMPEG setup will result in the Program not working properly)", "yellow"); | ||
FLSharp.PrintColor("Y | N", "yellow"); | ||
Console.WriteLine(""); | ||
string selection = Console.ReadLine(); | ||
switch(selection.ToLower()) | ||
{ | ||
case "y": | ||
hasAgreed = true; | ||
break; | ||
case "yes": | ||
hasAgreed = true; | ||
break; | ||
case "n": | ||
return Task.CompletedTask; | ||
case "no": | ||
return Task.CompletedTask; | ||
default: | ||
setupFFMPEG(); | ||
break; | ||
|
||
} | ||
if(!hasAgreed) | ||
{ | ||
setupFFMPEG(); | ||
} | ||
Logging.LogSystem("Downloading FFMPEG, this might take a while."); | ||
WebClient client = new WebClient(); | ||
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgress); | ||
Uri url = new Uri("https://github.com/FabioGaming/PlayListRipper/releases/download/v1.1/ffmpeg.zip"); | ||
|
||
try | ||
{ | ||
client.DownloadFileAsync(url, $"C:/Users/{Environment.UserName}/ffmpeg.zip"); | ||
} | ||
catch | ||
{ | ||
Logging.LogError("Something went wrong while trying to Download ffmpeg."); | ||
Task.Delay(3000); | ||
return Task.CompletedTask; | ||
} | ||
while(!isDownloaded) {} | ||
|
||
Logging.LogSuccess("Downloaded FFMPEG!"); | ||
Logging.LogSystem("Creating Folder..."); | ||
try | ||
{ | ||
Directory.CreateDirectory("C:/ffmpeg/"); | ||
Logging.LogSuccess("Created Folder: C:/ffmpeg/"); | ||
}catch | ||
{ | ||
Logging.LogError("Something went wrong."); | ||
Thread.Sleep(3000); | ||
return Task.CompletedTask; | ||
} | ||
Logging.LogSystem("Extracting..."); | ||
try | ||
{ | ||
ZipFile.ExtractToDirectory($"C:/Users/{Environment.UserName}/ffmpeg.zip", "C:/ffmpeg/"); | ||
Logging.LogSuccess("Extracted ffmpeg into: C:/ffmpeg/"); | ||
} catch | ||
{ | ||
Logging.LogError("Something went wrong."); | ||
Thread.Sleep(3000); | ||
return Task.CompletedTask; | ||
} | ||
Logging.LogSystem("Cleaning up..."); | ||
try | ||
{ | ||
File.Delete($"C:/Users/{Environment.UserName}/ffmpeg.zip"); | ||
Logging.LogSuccess("Cleaned up data."); | ||
}catch | ||
{ | ||
Logging.LogError("Something went wrong."); | ||
Thread.Sleep(3000); | ||
return Task.CompletedTask; | ||
} | ||
Logging.LogSystem("Adding ffmpeg to system variables..."); | ||
try | ||
{ | ||
var name = "PATH"; | ||
var scope = EnvironmentVariableTarget.Machine; | ||
var oldValues = Environment.GetEnvironmentVariable(name, scope); | ||
var newValues = oldValues + @";C:\ffmpeg"; | ||
Environment.SetEnvironmentVariable(name, newValues, scope); | ||
Logging.LogSuccess("Added ffmpeg."); | ||
|
||
} catch(Exception e) | ||
{ | ||
Console.WriteLine(e); | ||
Logging.LogError("Something went wrong."); | ||
Thread.Sleep(3000); | ||
return Task.CompletedTask; | ||
} | ||
Console.WriteLine(""); | ||
Logging.LogSuccess("FFMPEG has been successfully downloaded and installed to the system."); | ||
FLSharp.PrintColor("Press any key to continue.", "yellow"); | ||
Console.ReadKey(); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
|
||
private static void DownloadProgress(object sender, DownloadProgressChangedEventArgs e) | ||
{ | ||
string progress = null; | ||
string progressmessage = null; | ||
|
||
for (int i = 0; i != e.ProgressPercentage; i++) { | ||
progress = progress + "="; | ||
progressmessage = $"[{progress}".PadRight(100) + "]"; | ||
|
||
} | ||
Console.Write("\r{0}", $"Downloading: {e.ProgressPercentage}% | {progressmessage}"); | ||
if(e.ProgressPercentage == 100) { isDownloaded = true; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"profiles": { | ||
"ListRipper": { | ||
"commandName": "Project", | ||
"sqlDebugging": false | ||
} | ||
} | ||
} |