Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Commit

Permalink
Fix my stupidity, and also #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Skid committed Sep 6, 2018
1 parent d96e19b commit 8f99a86
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Crunchyroll-Downloader/AboutWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Label Grid.Row="0" x:Name="label_1" Content="This tool is under the AGPLv3 license." HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Foreground="White" Height="26" Width="207"/>
<Label Grid.Row="1" x:Name="label_2" Content="All informations on github." HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Foreground="White" Height="26" Width="151"/>
<Label Grid.Row="2" x:Name="label_3" Content="https://github.com/skid9000/Crunchyroll-Downloader" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Foreground="White" Height="26" Width="295"/>
<Label Grid.Row="3" x:Name="label_4" Content="Version : v1.2.7" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Foreground="White" Height="26" Width="295"/>
<Label Grid.Row="3" x:Name="label_4" Content="Version : v1.2.7c" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Foreground="White" Height="26" Width="295"/>
<Button Grid.Row="4" x:Name="button" Content="Update Youtube-DL" HorizontalAlignment="Left" Margin="10,15,0,0" VerticalAlignment="Top" Height="34" Width="372" Click="button_Click"/>
</Grid>
</Window>
114 changes: 58 additions & 56 deletions Crunchyroll-Downloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public class Program
public string Format { get; set; }
public string SavePath { get; set; }
public string Quality { get; set; }
public string MkvStatus { get; set; }
public string DlStatus { get; set; }
public string MkvStatus { get; set; }
public string DlStatus { get; set; }

/// <summary>
/// Downloadings a file.
/// </summary>
public void Downloading()
/// <summary>
/// Downloadings a file.
/// </summary>
public void Downloading()
{
var dl_status = new Program();
var process = new Process();
Expand All @@ -28,59 +28,61 @@ public void Downloading()
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
// process.StartInfo.RedirectStandardOutput = true;

if (MkvStatus == "1")
{
if (STState == "1")
{
if (Quality == "best")
process.StartInfo.Arguments = $"--write-sub --sub-lang {Langue} --sub-format {Format} -f best --no-part -o \"{SavePath}\" --recode-video mkv --embed-subs --postprocessor-args \"-disposition:s:0 default\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
else
process.StartInfo.Arguments = $"--write-sub --sub-lang {Langue} --sub-format {Format} -f \"best[height={Quality}]\" --no-part -o \"{SavePath}\" --recode-video mkv --embed-subs --postprocessor-args \"-disposition:s:0 default\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
}
else
{
if (Quality == "best")
process.StartInfo.Arguments = $"-f best --no-part -o \"{SavePath}\" --recode-video mkv --embed-subs --postprocessor-args \"-disposition:s:0 default\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
else
process.StartInfo.Arguments = $"-f \"best[height={Quality}]\" --no-part -o \"{SavePath}\" --recode-video mkv --embed-subs --postprocessor-args \"-disposition:s:0 default\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
}
}
else
{
if (STState == "1")
{
if (Quality == "best")
process.StartInfo.Arguments = $"--write-sub --sub-lang {Langue} --sub-format {Format} -f best --no-part -o \"{SavePath}\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
else
process.StartInfo.Arguments = $"--write-sub --sub-lang {Langue} --sub-format {Format} -f \"best[height={Quality}]\" --no-part -o \"{SavePath}\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
}
else
{
if (Quality == "best")
process.StartInfo.Arguments = $"-f best --no-part -o \"{SavePath}\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
else
process.StartInfo.Arguments = $"-f \"best[height={Quality}]\" --no-part -o \"{SavePath}\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
}
}
SavePath = SavePath + @"\%(title)s.%(ext)s";

if (MkvStatus == "1")
{
if (STState == "1")
{
if (Quality == "best")
process.StartInfo.Arguments = $"--write-sub --sub-lang {Langue} --sub-format {Format} -f best --no-part -o \"{SavePath}\" --recode-video mkv --embed-subs --postprocessor-args \"-disposition:s:0 default\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
else
process.StartInfo.Arguments = $"--write-sub --sub-lang {Langue} --sub-format {Format} -f \"best[height={Quality}]\" --no-part -o \"{SavePath}\" --recode-video mkv --embed-subs --postprocessor-args \"-disposition:s:0 default\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
}
else
{
if (Quality == "best")
process.StartInfo.Arguments = $"-f best --no-part -o \"{SavePath}\" --recode-video mkv --embed-subs --postprocessor-args \"-disposition:s:0 default\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
else
process.StartInfo.Arguments = $"-f \"best[height={Quality}]\" --no-part -o \"{SavePath}\" --recode-video mkv --embed-subs --postprocessor-args \"-disposition:s:0 default\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
}
}
else
{
if (STState == "1")
{
if (Quality == "best")
process.StartInfo.Arguments = $"--write-sub --sub-lang {Langue} --sub-format {Format} -f best --no-part -o \"{SavePath}\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
else
process.StartInfo.Arguments = $"--write-sub --sub-lang {Langue} --sub-format {Format} -f \"best[height={Quality}]\" --no-part -o \"{SavePath}\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
}
else
{
if (Quality == "best")
process.StartInfo.Arguments = $"-f best --no-part -o \"{SavePath}\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
else
process.StartInfo.Arguments = $"-f \"best[height={Quality}]\" --no-part -o \"{SavePath}\" --cookies C:\\ProgramData\\Crunchy-DL\\cookies.txt {Url}";
}
}


var viewerThread = new Thread(() =>
{
var download_window = new DownloadWindow();
download_window.Show();
download_window.Activate();
download_window.Closed += (s, e) =>
Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Normal);
Dispatcher.Run();
});
viewerThread.SetApartmentState(ApartmentState.STA); // needs to be STA or throws exception
viewerThread.Start();
var viewerThread = new Thread(() =>
{
var download_window = new DownloadWindow();
download_window.Show();
download_window.Activate();
download_window.Closed += (s, e) =>
Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Normal);
Dispatcher.Run();
});
viewerThread.SetApartmentState(ApartmentState.STA); // needs to be STA or throws exception
viewerThread.Start();

process.Start();
process.WaitForExit();// Waits here for the process to exit.
viewerThread.Abort();
MessageBox.Show("Download finished !", "Success !", MessageBoxButton.OK, MessageBoxImage.Information);
process.Start();
process.WaitForExit();// Waits here for the process to exit.
viewerThread.Abort();
MessageBox.Show("Download finished !", "Success !", MessageBoxButton.OK, MessageBoxImage.Information);

}
}
}
}

0 comments on commit 8f99a86

Please sign in to comment.