Skip to content

Commit

Permalink
Dev Commit | New fixes!
Browse files Browse the repository at this point in the history
[Fixes|Changes]
- Fixed where app crashing(Requested registry access is not allowed)
  due to the app trying to change the registry without privilage.
  (It only changes the "ACP" in the registry to UTF-8 format. Nothing malicious)
- Fixed where in Video Type or Audio Type It Double download.
- Fixed where fonts doesn't actually renders even though its embedded to the resource.

[New]
- Added "Convert" type to convert videos/audios to another format like mp4/mp3/webm etc..
  • Loading branch information
IchimakiKasura committed Apr 8, 2022
1 parent 6dc2856 commit d3b6a2c
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 58 deletions.
18 changes: 14 additions & 4 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@ void App_Startup(object s, StartupEventArgs e)
{
ContextMenuAdjust();

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Nls\CodePage", true);
key.SetValue("ACP", "65001", RegistryValueKind.String);
try
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Nls\CodePage", true);
key.SetValue("ACP", "65001", RegistryValueKind.String);
}
catch
{
MessageBox.Show("For best experience, Run the application in Administrator\n if you're not Ok seeings blank titles in the console because its not\nrendered in UTF-8 format", "Note", MessageBoxButton.OK, MessageBoxImage.Warning);
};
}

void App_Exit(object s, ExitEventArgs e)
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Nls\CodePage", true);
key.SetValue("ACP", "1252", RegistryValueKind.String);
try
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Nls\CodePage", true);
key.SetValue("ACP", "1252", RegistryValueKind.String);
} catch { }
}

// Fixes the drop menus going from right to left because i don't know what happened.
Expand Down
Binary file added Fonts/NotoSansJP-Medium.otf
Binary file not shown.
Binary file removed Fonts/NotoSansJP-Regular.otf
Binary file not shown.
12 changes: 11 additions & 1 deletion Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,32 @@ public partial class MainWindow
{
public static MainWindow MW;


// Version
readonly string Version = "Build Version:\nDevelopment Build";


// ydl.bin location
public readonly static string YDL_link = $"{Directory.GetCurrentDirectory()}\\LauncherDL_Data\\ydl.bin";


// ffmpeg location
private static string Ffmpeg = $"{Directory.GetCurrentDirectory()}\\LauncherDL_Data";


// For the renaming process
private List<string> ext = new() { "mp4", "mkv", "webm", "mp3", "m4a", "3gp", "flv" };


// Types
public List<string> VideoType = new() { "mp4", "mkv", "webm", "flv", "auto" };
public List<string> AudioType = new() { "mp3", "webm", "m4a", "mp4", "auto"};


//Convert
public List<string> ConvertType = new() { "mp4", "mp3", "flv", "webm", "m4a", "mkv", "avi", "wmv", "wma", "ogg", "aac"};


// Hidden button / Update notes
readonly string HiddenButtonText = "LauncherDL Development Build\n\n" +
"OMG this is so E P I C!!\n\n" +
Expand All @@ -55,16 +62,20 @@ public partial class MainWindow
"Fixed font family\n\n" +
"Created by Kasura.";


// config
public LauncherDefaultConfig Config = new();


// Download / Update / File Format
private Process Proc;


// Window focus animations
private DoubleAnimation Opac;
private ColorAnimation Anim;


// Temporary variables
private string TemporaryEncodedName = string.Empty;
private List<string> TemporaryFormatNames = new();
Expand All @@ -77,7 +88,6 @@ public partial class MainWindow
private bool IsDownloading = false;
private MemoryStream DocumentTemp;


// Window Flashing
[DllImport("user32.dll", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.Bool)]
Expand Down
8 changes: 6 additions & 2 deletions Launcher DL v6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
<Description>Downloads any audio or video</Description>
<DebugType>embedded</DebugType>
<Product>LauncherDL</Product>
<PublisherName>Ichimaki Kasura</PublisherName>
<PackageId>LauncherDL</PackageId>
<Authors>Ichimaki Kasura</Authors>
<Company>Ichimaki Kasura</Company>
<Copyright>Copyright © 2022</Copyright>
<AssemblyName>uVad</AssemblyName>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -31,11 +33,12 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Fonts\NotoSansJP-Regular.otf" />
<None Remove="Fonts\NotoSansJP-Light.otf" />
<None Remove="Fonts\NotoSansJP-Medium.otf" />
</ItemGroup>

<ItemGroup>
<Resource Include="Fonts\NotoSansJP-Regular.otf" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -132,6 +135,7 @@
</ItemGroup>

<ItemGroup>
<Resource Include="Fonts\NotoSansJP-Medium.otf" />
<Resource Include="Images\Icon.ico" />
<Resource Include="Images\akira.png" />
<Resource Include="Images\asutorufo.jpeg" />
Expand Down
30 changes: 17 additions & 13 deletions Lib/Console Output/ConsoleOutputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
public partial class MainWindow
{
string AudioOnly;
int TotalDuration;
public void FileFormatOutput(object s, DataReceivedEventArgs e)
{
string StringData = e.Data;
if (!string.IsNullOrEmpty(e.Data))
{
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
ProgressBarShow();

TaskBarThingy.ProgressValue = Window_ProgressBar.Value / 100;

Expand Down Expand Up @@ -116,17 +115,14 @@ public void FileFormatOutput(object s, DataReceivedEventArgs e)
}
}
});
}
}

public void DownloadOutput(object s, DataReceivedEventArgs e)
{
string StringData = e.Data;
if (!string.IsNullOrEmpty(StringData))
{
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
ProgressBarShow();

TaskBarThingy.ProgressValue = Window_ProgressBar.Value / 100;

Expand All @@ -149,14 +145,12 @@ public void DownloadOutput(object s, DataReceivedEventArgs e)
Output_text.AddFormattedText("<#83fa57>[PROCESSING] <>Processing / Converting フォマっと...");
}
});
}
}

public void UpdateOutput(object s, DataReceivedEventArgs e)
{
string StringData = e.Data;
if (!string.IsNullOrEmpty(StringData))
{
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
if (StringData.Contains("yt-dlp is up to date"))
Expand All @@ -173,28 +167,38 @@ public void UpdateOutput(object s, DataReceivedEventArgs e)
Output_text.AddFormattedText($"<Pink>[YEY] Updated!");

});
}

}

public void ConvertOutput(object s, DataReceivedEventArgs e)
{
// frame= 7290 fps=263 q=-1.0 Lsize= 22360kB time=00:04:03.05 bitrate= 753.6kbits/s speed=8.78x
string StringData = e.Data;
if (!string.IsNullOrEmpty(e.Data))
{
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
TaskBarThingy.ProgressValue = Window_ProgressBar.Value / 100;

string TotalTime = LauncherDL_Regex.C_Total.Match(StringData).Groups["TotalTime"].Value.Trim();
string CurrentTime = LauncherDL_Regex.C_Current.Match(StringData).Groups["CurrentTime"].Value.Trim();
int CurrentTimeInt;

if(!string.IsNullOrEmpty(TotalTime))
TotalDuration = (int)TimeSpan.Parse(TotalTime).TotalSeconds;

Console.WriteLine(StringData);
if(!string.IsNullOrEmpty(CurrentTime))
{
CurrentTimeInt = (int)TimeSpan.Parse(CurrentTime).TotalSeconds;
Window_ProgressBar.Value = (double)((decimal)CurrentTimeInt/(decimal)TotalDuration)*100;
}

});
}
}

public void ErrorOutput(object s, DataReceivedEventArgs e)
{
string StringData = e.Data;
if (!string.IsNullOrEmpty(StringData))
{
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
if (StringData.Contains("ERROR") || StringData.Contains("Traceback"))
Expand All @@ -205,7 +209,7 @@ public void ErrorOutput(object s, DataReceivedEventArgs e)
ProcessEnds(false);
}
});
}

}

}
3 changes: 2 additions & 1 deletion Lib/Core/StartUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private async void Initialize()
Button_Update.Click += Update;
Closing += Window_Close;
KeyDown += Window_PreviewKeyDown;
Open_File.Click += OpenFile;

Input_Format.SelectionChanged += delegate
{
Expand All @@ -44,9 +45,9 @@ private async void Initialize()
Keyboard.ClearFocus();
};


#region Open Folder thing
Open_Folder.Click += delegate { OpenFolder(Config.DefaultOutput); };

OpenDir_Audio.Click += delegate { OpenFolder($"{Config.DefaultOutput}\\Audio"); };
OpenDir_Video.Click += delegate { OpenFolder($"{Config.DefaultOutput}\\Video"); };
OpenDir_Convert.Click += delegate { OpenFolder($"{Config.DefaultOutput}\\Converted"); };
Expand Down
69 changes: 64 additions & 5 deletions Lib/MainWindow/ButtonHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public partial class MainWindow
{
public async void FileFormat(object s, RoutedEventArgs e)
{

DebugOutput.Button_Clicked("format");

Input_Format.Items.Clear();
Expand All @@ -26,7 +27,7 @@ public async void FileFormat(object s, RoutedEventArgs e)
}

OutputComments.FileFormatOutputComments();

ProgressBarShow();
await StartProcess(YTDL_FileFormat());
}

Expand Down Expand Up @@ -73,14 +74,72 @@ public async void Download(object s, RoutedEventArgs e)
}

OutputComments.DownloadOutputComments();

ProgressBarShow();
await StartProcess(YTDL_Download());
}

// This is kinda messy
public async void ConvertFile(object s, RoutedEventArgs e)
{
Console.WriteLine(":O");
}
{
if(string.IsNullOrEmpty(Input_Link.Text))
{
Output_text.AddFormattedText("<Red>[ERROR] <>No file selected!");
return;
}

if(string.IsNullOrEmpty(Input_Name.Text))
{
Output_text.AddFormattedText("<Red>[ERROR] <>Name is Required!");
return;
}

ProgressBarShow();
IsDownloading = true;
Window_Components(true);

if(!Directory.Exists($"{Config.DefaultOutput}\\Convert"))
Directory.CreateDirectory($"{Config.DefaultOutput}\\Convert");

string Command = $"-i \"{Input_Link.Text}\" -q 0 \"{Config.DefaultOutput}\\Convert\\{Input_Name.Text}.{Input_Format.Text}\"";


Proc = new();
Proc.StartInfo = new($"{Ffmpeg}\\ffmpeg.exe", Command)
{
UseShellExecute = false,
RedirectStandardError = true,
CreateNoWindow = false
};

Output_text.AddFormattedText("<#83fa57>[PROCESSING] <>Please wait until the conversion is finished.");

Proc.EnableRaisingEvents = true;
Proc.ErrorDataReceived += ConvertOutput;
Proc.Start();
Proc.BeginErrorReadLine();
await Proc.WaitForExitAsync();

Output_text.AddFormattedText($"<Pink>[YEY] <>File converted: \"{Config.DefaultOutput}\\Convert\\{Input_Name.Text}.{Input_Format.Text}\"");

if (IsActive) TaskBarThingy.ProgressValue = 0;
Window_ProgressBar.Value = 0;

WindowFlash();
ProgressBarHide();
Window_Components(false);
IsDownloading = false;
}

public void OpenFile(object s, RoutedEventArgs e)
{
OpenFileDialog openFile = new();
openFile.Filter = "All Media Files|*.wav;*.aac;*.wma;*.wmv;*.avi;*.mpg;*.mpeg;*.m1v;*.mp2;*.mp3;*.mpa;*.mpe;*.m3u;*.mp4;*.mov;*.3g2;*.3gp2;*.3gp;*.3gpp;*.m4a;*.cda;*.aif;*.aifc;*.aiff;*.mid;*.midi;*.rmi;*.mkv;*.WAV;*.AAC;*.WMA;*.WMV;*.AVI;*.MPG;*.MPEG;*.M1V;*.MP2;*.MP3;*.MPA;*.MPE;*.M3U;*.MP4;*.MOV;*.3G2;*.3GP2;*.3GP;*.3GPP;*.M4A;*.CDA;*.AIF;*.AIFC;*.AIFF;*.MID;*.MIDI;*.RMI;*.MKV;*.flv;*.FLV";;
if (openFile.ShowDialog() == true)
{
Output_text.AddFormattedText($"<Yellow>[INFO] <>Selected file: \"{Path.GetFileName(openFile.FileName)}\"");
Input_Link.Text = openFile.FileName;
}
}

public async void Update(object s, RoutedEventArgs e)
{
Expand Down
8 changes: 8 additions & 0 deletions Lib/MainWindow/ComboBoxType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void InputType(object s, SelectionChangedEventArgs e)
switch(Input_Type.SelectedIndex)
{
case 0:
Title = "Launcher DL - Custom";
Input_Format.IsReadOnly = false;
Input_Format.IsEditable = true;
Input_Format.Items.Clear();
Expand All @@ -59,18 +60,21 @@ public void InputType(object s, SelectionChangedEventArgs e)
break;

case 1:
Title = "Launcher DL - Video";
InputFormatShortCut();
SelectedFormat("Video");
Input_Format.SelectedIndex = 0;
break;

case 2:
Title = "Launcher DL - Audio";
InputFormatShortCut();
SelectedFormat("Audio");
Input_Format.SelectedIndex = 0;
break;

case 3:
Title = "Launcher DL - Convert";
InputFormatShortCut();
SelectedFormat("Convert");
Input_Link.HorizontalAlignment =
Expand All @@ -79,6 +83,7 @@ public void InputType(object s, SelectionChangedEventArgs e)
Text_Link.Width = 360;
Input_Link.Uid = System_Language_Handler.DefaultInputLinkUIDTwo;
Text_Link.Content = System_Language_Handler.DefaultLinkContentTwo;
Input_Name.Uid = System_Language_Handler.DefaultNameInputTwo;
Open_File.Visibility = Visibility.Visible;
Button_Download.Click -= Download;
Button_Download.Click += ConvertFile;
Expand All @@ -94,11 +99,14 @@ public void InputType(object s, SelectionChangedEventArgs e)
Text_Link.Width = 65;
Input_Link.Uid = System_Language_Handler.DefaultInputLinkUID;
Text_Link.Content = System_Language_Handler.DefaultLinkContent;
Input_Name.Uid = System_Language_Handler.DefaultNameInput;
Open_File.Visibility = Visibility.Hidden;
Button_Download.Click -= ConvertFile;
Button_Download.Click -= Download;
Button_Download.Click += Download;
}

if (Config.ShowSystemOutput) Output_text.AddFormattedText($"<#a85192%14>[SYSTEM] <Gray%14>Changed TYPE to \"{((ComboBoxItem)Input_Type.SelectedItem).Content.ToString()}\"");
TaskBarThingy.Description = Title;
}
}
Loading

0 comments on commit d3b6a2c

Please sign in to comment.