Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonthehuman05 committed Jul 8, 2022
1 parent 4850e9e commit 78f5154
Show file tree
Hide file tree
Showing 25 changed files with 786 additions and 0 deletions.
6 changes: 6 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
83 changes: 83 additions & 0 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<Application x:Class="VidGrab.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VidGrab"
StartupUri="MainWindow.xaml">
<Application.Resources>

<Color x:Key="BackgroundBlue1">#FF111C24</Color>
<Color x:Key="BackgruondBlue2">#0c1419</Color>
<Color x:Key="BackgroundBlue3">#05080b</Color>

<Color x:Key="White">#FFFFFF</Color>
<Color x:Key="Blue">#006FA9</Color>
<Color x:Key="Red">#ED2700</Color>
<Color x:Key="Green">#BED600</Color>

<Style x:Key="ActionButton" TargetType="Button">
<Setter Property="Background" Value="#BED600"/>
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="15"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
</Style.Resources>
</Style>

<Style x:Key="ActionButtonLeftRounded" TargetType="Button">
<Setter Property="Background" Value="#BED600"/>
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="15, 0, 0, 15"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
</Style.Resources>
</Style>

<Style x:Key="ActionButtonRightRounded" TargetType="Button">
<Setter Property="Background" Value="#BED600"/>
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="0, 15, 15, 0"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
</Style.Resources>
</Style>

<Style x:Key="RoundedLabel" TargetType="Label">
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="15"/>
</Style>
</Style.Resources>
</Style>

<Style x:Key="SecondaryAction" TargetType="Button">
<Setter Property="Background" Value="#00000000"/>
<Setter Property="BorderBrush" Value="#BED600"/>
<Setter Property="Foreground" Value="#BED600"/>
<Setter Property="BorderThickness" Value="2"/>
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="15"/>
<Setter Property="BorderThickness" Value="3"/>
</Style>
</Style.Resources>
</Style>

<Style x:Key="TBox" TargetType="TextBox">
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="15"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
</Style.Resources>
<Setter Property="Padding" Value="10, 0, 0, 0"/>
</Style>

<Style x:Key="UnderlinedText" TargetType="Label">
<Setter Property="BorderThickness" Value="0,0,0,3"/>
</Style>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace VidGrab
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
103 changes: 103 additions & 0 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<Window x:Class="VidGrab.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VidGrab"
mc:Ignorable="d"
Title="VidGrab" Height="279" Width="574" ResizeMode="CanMinimize" MinHeight="280">
<Window.Background>
<SolidColorBrush Color="{DynamicResource BackgroundBlue1}"/>
</Window.Background>
<Grid>
<TextBox x:Name="VideoURL" Height="34" Margin="10,10,109,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="14" Style="{DynamicResource TBox}" BorderThickness="3,3,3,3" Padding="7,5,7,5" Background="#FF0C1419">
<TextBox.Foreground>
<SolidColorBrush Color="{DynamicResource Green}"/>
</TextBox.Foreground>
<TextBox.BorderBrush>
<SolidColorBrush Color="{DynamicResource Green}"/>
</TextBox.BorderBrush>
</TextBox>
<Button x:Name="GetVideoInfoButton" Content="Get Video" HorizontalAlignment="Right" Height="34" Margin="0,10,10,0" VerticalAlignment="Top" Width="130" Click="GetVideoInfoButton_Click" RenderTransformOrigin="-0.067,0.835" Style="{DynamicResource ActionButton}" BorderThickness="0,0,0,0"/>
<Label Content="Get a video to load content!" HorizontalAlignment="Center" Margin="0,74,0,0" VerticalAlignment="Top" FontSize="24">
<Label.Foreground>
<SolidColorBrush Color="{DynamicResource Red}"/>
</Label.Foreground>
</Label>
<Canvas x:Name="VideoInformationHolder" Margin="10,59,10,46">
<Canvas.Background>
<SolidColorBrush Color="{DynamicResource BackgroundBlue1}"/>
</Canvas.Background>
<Label x:Name="CreatorLabel" Content="By:" FontSize="14" Canvas.Left="116" Canvas.Top="39">
<Label.Foreground>
<SolidColorBrush Color="{DynamicResource Red}"/>
</Label.Foreground>
</Label>
<Image x:Name="ThumbnailHolder" Height="55" Canvas.Top="5" Width="90" Source="https://www.nidderdalellamas.org/wp-content/uploads/2018/10/Anya-1-e1543436893135.jpeg" Canvas.Left="4"/>
<Label x:Name="VideoTitleLabel" Content="Get a video to load content!" Canvas.Left="116" Canvas.Top="5" Style="{DynamicResource UnderlinedText}" FontSize="16">
<Label.Foreground>
<SolidColorBrush Color="{DynamicResource Blue}"/>
</Label.Foreground>
<Label.BorderBrush>
<SolidColorBrush Color="{DynamicResource Blue}"/>
</Label.BorderBrush>
</Label>
<Button x:Name="DownloadVideoButton" Content="Download Video" Canvas.Left="117" Canvas.Top="73" Canvas.Bottom="10" Style="{DynamicResource ActionButton}" Width="208" Height="40" BorderThickness="0,0,0,0" Click="DownloadVideoButton_Click"/>
<Button x:Name="DownloadAudioButton" Content="Download Audio Only" Canvas.Left="330" Canvas.Top="73" Canvas.Bottom="10" Style="{DynamicResource SecondaryAction}" Width="208" Height="40" BorderThickness="1,1,1,1" Click="DownloadAudioButton_Click"/>
<Button x:Name="CancelAudioDownloadButton" Content="Cancel Download" Height="40" Width="421" Canvas.Left="117" Canvas.Bottom="10" Canvas.Top="73" Style="{DynamicResource ActionButton}" BorderThickness="0,0,0,0" Click="CancelDownloadAudio">
<Button.BorderBrush>
<SolidColorBrush Color="{DynamicResource Red}"/>
</Button.BorderBrush>
<Button.Background>
<SolidColorBrush Color="{DynamicResource Red}"/>
</Button.Background>
</Button>
<Button x:Name="CancelVideoDownloadButton" Content="Cancel Download" Height="40" Width="422" Canvas.Left="116" Canvas.Top="73" Canvas.Bottom="10" Style="{DynamicResource ActionButton}" BorderThickness="0,0,0,0" Click="CancelDownloadVideo">
<Button.BorderBrush>
<SolidColorBrush Color="{DynamicResource Red}"/>
</Button.BorderBrush>
<Button.Background>
<SolidColorBrush Color="{DynamicResource Red}"/>
</Button.Background>
</Button>
<ProgressBar x:Name="ProgressBar" Height="25" Width="420" Canvas.Left="116" Canvas.Top="118">
<ProgressBar.Foreground>
<SolidColorBrush Color="{DynamicResource White}"/>
</ProgressBar.Foreground>
<ProgressBar.BorderBrush>
<SolidColorBrush Color="{DynamicResource BackgroundBlue1}"/>
</ProgressBar.BorderBrush>
<ProgressBar.Background>
<SolidColorBrush Color="{DynamicResource BackgroundBlue1}"/>
</ProgressBar.Background>
</ProgressBar>
</Canvas>
<Label Content=" Save Folder" HorizontalAlignment="Left" Margin="10,0,0,11" Style="{DynamicResource RoundedLabel}" Width="100" VerticalContentAlignment="Center" Height="31" VerticalAlignment="Bottom">
<Label.BorderBrush>
<SolidColorBrush Color="{DynamicResource Green}"/>
</Label.BorderBrush>
<Label.Background>
<SolidColorBrush Color="{DynamicResource Green}"/>
</Label.Background>
</Label>
<TextBox x:Name="FilePathBox" Margin="85,0,71,11" TextWrapping="Wrap" Text="https://www.youtube.com/watch?v=xJeWySiuq1I" FontSize="10" Style="{DynamicResource TBox}" BorderThickness="0,3,3,3" Padding="7,5,7,5" Background="#FF0C1419" Height="31" VerticalAlignment="Bottom">
<TextBox.Foreground>
<SolidColorBrush Color="{DynamicResource Green}"/>
</TextBox.Foreground>
<TextBox.BorderBrush>
<SolidColorBrush Color="{DynamicResource Green}"/>
</TextBox.BorderBrush>
</TextBox>
<Button x:Name="OpenDownloadDirButton" Content="Open Folder" HorizontalAlignment="Right" Margin="0,0,10,11" Width="66" RenderTransformOrigin="-0.067,0.835" Style="{DynamicResource ActionButtonRightRounded}" BorderThickness="0,0,0,0" FontSize="10" Height="31" VerticalAlignment="Bottom" Click="OpenDownloadDirButton_Click">
<Button.Background>
<SolidColorBrush Color="{DynamicResource Green}"/>
</Button.Background>
</Button>
<Button x:Name="LocateFolderButton" Content="Select Folder" HorizontalAlignment="Right" Margin="0,0,76,11" Width="66" RenderTransformOrigin="-0.067,0.835" Style="{DynamicResource ActionButtonLeftRounded}" FontSize="10" BorderThickness="0,0,0,0" Height="31" VerticalAlignment="Bottom" Click="LocateFolderButton_Click"/>
<Label Content="Video URL" HorizontalAlignment="Left" Margin="10,44,0,0" VerticalAlignment="Top" FontSize="8">
<Label.Foreground>
<SolidColorBrush Color="{DynamicResource Green}"/>
</Label.Foreground>
</Label>
</Grid>
</Window>
116 changes: 116 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using YoutubeDLSharp;
using YoutubeDLSharp.Metadata;
using YoutubeDLSharp.Options;

namespace VidGrab
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
YoutubeDL ytdl;
CancellationTokenSource VCanceller;
CancellationTokenSource ACanceller;
Progress<DownloadProgress> progress;

public MainWindow()
{
InitializeComponent();
FilePathBox.Text = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\Downloads";
ytdl = new YoutubeDL()
{
YoutubeDLPath = "binaries/yt-dlp.exe",
FFmpegPath = "binaries/ffmpeg/ffmpeg.exe",
OutputFolder = FilePathBox.Text
};

progress = new Progress<DownloadProgress>(p => ProgressBar.Value = p.Progress*100);
// progress = new Progress<DownloadProgress>(p => Console.WriteLine(p.Progress));
CancelAudioDownloadButton.Visibility = Visibility.Hidden;
CancelVideoDownloadButton.Visibility = Visibility.Hidden;
VideoInformationHolder.Visibility = Visibility.Hidden;
}

private async void GetVideoInfoButton_Click(object sender, RoutedEventArgs e)
{
string URL = VideoURL.Text;
RunResult<VideoData> vd = await ytdl.RunVideoDataFetch(URL);
if (vd.Success)
{
VideoTitleLabel.Content = vd.Data.Title;
CreatorLabel.Content = $"By: {vd.Data.Channel}";
ThumbnailHolder.Source = new BitmapImage(new Uri(vd.Data.Thumbnail));

VideoInformationHolder.Visibility = Visibility.Visible;
//RunResult<string> res = await ytdl.RunVideoDownload(URL);
}
else
{
System.Windows.MessageBox.Show("Something went wrong. Ensure a valid URL was provided and you have a working internet connecion", "An error occured", MessageBoxButton.OK, MessageBoxImage.Error);
}
}

private async void DownloadVideoButton_Click(object sender, RoutedEventArgs e)
{
CancelVideoDownloadButton.Visibility = Visibility.Visible;
string URL = VideoURL.Text;
VCanceller = new CancellationTokenSource();
try
{
RunResult<string> video = await ytdl.RunVideoDownload(URL, ct: VCanceller.Token, progress: progress);
}
catch { }
CancelVideoDownloadButton.Visibility = Visibility.Hidden;
}

private void CancelDownloadVideo(object sender, RoutedEventArgs e){ VCanceller.Cancel(); }

private void CancelDownloadAudio(object sender, RoutedEventArgs e){ ACanceller.Cancel(); }

private async void DownloadAudioButton_Click(object sender, RoutedEventArgs e)
{
CancelAudioDownloadButton.Visibility = Visibility.Visible;
string URL = VideoURL.Text;
ACanceller = new CancellationTokenSource();
try
{
RunResult<string> video = await ytdl.RunAudioDownload(URL, format: AudioConversionFormat.Mp3, ct: ACanceller.Token, progress: progress);
}
catch { }
CancelAudioDownloadButton.Visibility = Visibility.Hidden;
}

private void OpenDownloadDirButton_Click(object sender, RoutedEventArgs e)
{
Process.Start(FilePathBox.Text);
}

private void LocateFolderButton_Click(object sender, RoutedEventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.ShowDialog();
if(fbd.SelectedPath != string.Empty)
{
FilePathBox.Text = fbd.SelectedPath;
}
}
}
}
55 changes: 55 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("VidGrab")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VidGrab")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 78f5154

Please sign in to comment.