-
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.
- Loading branch information
Ale
authored and
Ale
committed
Nov 24, 2024
1 parent
5171dab
commit 086f8d5
Showing
24 changed files
with
921 additions
and
0 deletions.
There are no files selected for viewing
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,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.12.35506.116 d17.12 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YoutubeDownloader", "YoutubeDownloader\YoutubeDownloader.csproj", "{9F47CD48-8B0B-4422-82A5-93831788B93D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9F47CD48-8B0B-4422-82A5-93831788B93D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9F47CD48-8B0B-4422-82A5-93831788B93D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9F47CD48-8B0B-4422-82A5-93831788B93D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9F47CD48-8B0B-4422-82A5-93831788B93D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
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,14 @@ | ||
<Application x:Class="YoutubeDownloader.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:YoutubeDownloader" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Styles/ButtonStyles.xaml"/> | ||
<ResourceDictionary Source="Styles/TextBlockStyles.xaml"/> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
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,14 @@ | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Windows; | ||
|
||
namespace YoutubeDownloader | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
|
||
} |
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,10 @@ | ||
using System.Windows; | ||
|
||
[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) | ||
)] |
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,42 @@ | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
using System.Windows.Markup; | ||
|
||
namespace YoutubeDownloader.Converters | ||
{ | ||
class BoolToVisibilityConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is bool boolValue) | ||
{ | ||
bool useHidden = parameter?.ToString() == "Hidden"; | ||
return boolValue ? Visibility.Visible : (useHidden ? Visibility.Hidden : Visibility.Collapsed); | ||
} | ||
return Visibility.Collapsed; | ||
} | ||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
class InvertedBoolToVisibilityConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is bool boolValue) | ||
{ | ||
bool useHidden = parameter?.ToString() == "Hidden"; | ||
return boolValue ? (useHidden ? Visibility.Hidden : Visibility.Collapsed) : Visibility.Visible; | ||
} | ||
return Visibility.Collapsed; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
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,59 @@ | ||
using System.Text.RegularExpressions; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using WpfAnimatedGif; | ||
using YoutubeDownloader.ViewModels; | ||
|
||
namespace YoutubeDownloader; | ||
|
||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
private readonly MainViewModel _mainViewModel; | ||
|
||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
_mainViewModel = new MainViewModel(); | ||
DataContext = _mainViewModel; | ||
buttonClose.Click += (s, e) => Close(); | ||
buttonMinimize.Click += (s, e) => WindowState = WindowState.Minimized; | ||
textboxInputUrl.TextChanged += (s, e) => textBlockURLHint.Visibility = textboxInputUrl.Text.Length > 0 ? Visibility.Hidden : Visibility.Visible; | ||
} | ||
|
||
private void buttonPaste_Click(object sender, RoutedEventArgs e) | ||
{ | ||
textboxInputUrl.Text = Regex.Replace(Clipboard.GetText(), @"\t|\n|\r", ""); | ||
} | ||
|
||
private void buttonDownload_Click(object sender, RoutedEventArgs e) | ||
{ | ||
} | ||
|
||
private void buttonSearch_Click(object sender, RoutedEventArgs e) | ||
{ | ||
string inputUrl = textboxInputUrl.Text.Trim(); | ||
if (string.IsNullOrWhiteSpace(inputUrl)) return; | ||
textboxInputUrl.Text = inputUrl; | ||
_mainViewModel.GetVideoMetadata(inputUrl); | ||
} | ||
|
||
private void Image_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) | ||
{ | ||
var img = sender as Image; | ||
var controller = ImageBehavior.GetAnimationController(imgLoadingGif); | ||
if (controller == null) return; | ||
if (img?.Visibility == Visibility.Hidden || img?.Visibility == Visibility.Collapsed) | ||
{ | ||
controller.Pause(); | ||
controller.GotoFrame(1); | ||
} | ||
else | ||
{ | ||
controller.Play(); | ||
} | ||
|
||
} | ||
} |
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,10 @@ | ||
namespace YoutubeDownloader.Models | ||
{ | ||
public class VideoMetadataModel | ||
{ | ||
public string Title { get; set; } = string.Empty; | ||
public string Duration { get; set; } = string.Empty; | ||
public string ChannelName { get; set; } = string.Empty; | ||
public string ThumbnailUrl { get; set; } = string.Empty; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,29 @@ | ||
namespace YoutubeDownloader.Services; | ||
|
||
using System; | ||
using YoutubeDownloader.Models; | ||
using YoutubeExplode; | ||
public class YoutubeService | ||
{ | ||
private YoutubeClient _youtube; | ||
public YoutubeService() | ||
{ | ||
_youtube = new YoutubeClient(); | ||
} | ||
public async Task<VideoMetadataModel> GetInfo(string url) | ||
{ | ||
var video = await _youtube.Videos.GetAsync(url); | ||
VideoMetadataModel metadata = new VideoMetadataModel(); | ||
metadata.Title = video.Title; | ||
metadata.Duration = video.Duration == null ? "Live" : ((TimeSpan)video.Duration).ToString(@"hh\:mm\:ss"); | ||
metadata.ChannelName = video.Author.ChannelTitle; | ||
metadata.ThumbnailUrl = video.Thumbnails[0].Url; | ||
return metadata; | ||
} | ||
|
||
public async Task DownloadVideo(string url) | ||
{ | ||
#warning TODO: Download video | ||
|
||
} | ||
} |
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,110 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Style TargetType="{x:Type Button}" x:Key="ActionButton"> | ||
<Setter Property="Background" Value="#433bff" /> | ||
<Setter Property="Foreground" Value="#fbfbfe"/> | ||
<Setter Property="Height" Value="50"/> | ||
<Setter Property="Width" Value="150"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Button}"> | ||
<Border x:Name="Border" Background="{TemplateBinding Background}"> | ||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | ||
</Border> | ||
<ControlTemplate.Triggers> | ||
<MultiTrigger> | ||
<MultiTrigger.Conditions> | ||
<Condition Property="IsMouseOver" Value="True"/> | ||
<Condition Property="IsEnabled" Value="True"/> | ||
</MultiTrigger.Conditions> | ||
<Setter Property="Background" Value="#2f27ce"/> | ||
</MultiTrigger> | ||
<MultiTrigger> | ||
<MultiTrigger.Conditions> | ||
<Condition Property="IsMouseOver" Value="True"/> | ||
<Condition Property="IsMouseCaptured" Value="True"/> | ||
<Condition Property="IsEnabled" Value="True"/> | ||
</MultiTrigger.Conditions> | ||
<Setter Property="Background" Value="#433bff"/> | ||
</MultiTrigger> | ||
<Trigger Property="IsEnabled" Value="False"> | ||
<Setter Property="Background" Value="LightGray" TargetName="Border"/> | ||
<Setter Property="Foreground" Value="Gray"/> | ||
</Trigger> | ||
</ControlTemplate.Triggers> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Resources> | ||
<Style TargetType="Border"> | ||
<Setter Property="CornerRadius" Value="8"/> | ||
</Style> | ||
</Style.Resources> | ||
</Style> | ||
|
||
<Style TargetType="{x:Type Button}" x:Key="CommonButtonDark"> | ||
<Setter Property="Background" Value="DarkSlateGray" /> | ||
<Setter Property="Height" Value="50"/> | ||
<Setter Property="Width" Value="50"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Button}"> | ||
<Border x:Name="Border" Background="{TemplateBinding Background}"> | ||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | ||
</Border> | ||
<ControlTemplate.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Background" Value="Gray"/> | ||
</Trigger> | ||
<MultiTrigger> | ||
<MultiTrigger.Conditions> | ||
<Condition Property="IsMouseOver" Value="True"/> | ||
<Condition Property="IsMouseCaptured" Value="True"/> | ||
</MultiTrigger.Conditions> | ||
<Setter Property="Background" Value="SlateGray"/> | ||
</MultiTrigger> | ||
</ControlTemplate.Triggers> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Resources> | ||
<Style TargetType="Border"> | ||
<Setter Property="CornerRadius" Value="8"/> | ||
</Style> | ||
</Style.Resources> | ||
</Style> | ||
|
||
<Style TargetType="{x:Type Button}" x:Key="PasteButton"> | ||
<Setter Property="Background" Value="Transparent" /> | ||
<Setter Property="Height" Value="50"/> | ||
<Setter Property="Width" Value="50"/> | ||
<Setter Property="Cursor" Value="Hand"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Button}"> | ||
<Border x:Name="Border" Background="{TemplateBinding Background}"> | ||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | ||
</Border> | ||
<ControlTemplate.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Background" Value="Transparent"/> | ||
</Trigger> | ||
<MultiTrigger> | ||
<MultiTrigger.Conditions> | ||
<Condition Property="IsMouseOver" Value="True"/> | ||
<Condition Property="IsMouseCaptured" Value="True"/> | ||
</MultiTrigger.Conditions> | ||
<Setter Property="Background" Value="Transparent"/> | ||
</MultiTrigger> | ||
</ControlTemplate.Triggers> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Resources> | ||
<Style TargetType="Border"> | ||
<Setter Property="CornerRadius" Value="8"/> | ||
</Style> | ||
</Style.Resources> | ||
</Style> | ||
|
||
</ResourceDictionary> |
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,6 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Style TargetType="TextBlock" x:Key="ButtonTextBlock"> | ||
<Setter Property="FontSize" Value="16"/> | ||
</Style> | ||
</ResourceDictionary> |
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,51 @@ | ||
<UserControl x:Class="YoutubeDownloader.UserControls.VideoSelectedCard" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:YoutubeDownloader.UserControls" | ||
xmlns:vm="clr-namespace:YoutubeDownloader.ViewModels" d:DataContext="{d:DesignInstance Type=vm:MainViewModel}" | ||
Name="VideoCard" | ||
mc:Ignorable="d" Height="135" | ||
Background="Transparent" Width="583"> | ||
<Grid Margin="0,0,0,0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition></RowDefinition> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition></ColumnDefinition> | ||
<ColumnDefinition Width="1.7*"></ColumnDefinition> | ||
</Grid.ColumnDefinitions> | ||
|
||
<!--Thumbnail--> | ||
|
||
<Border Width="180" Height="101" CornerRadius="8" BorderThickness="1" BorderBrush="LightGray"> | ||
<Border.Background> | ||
<ImageBrush Stretch="Fill" ImageSource="{Binding Thumbnail}"/> | ||
</Border.Background> | ||
</Border> | ||
<!--Video Info--> | ||
<Grid Grid.Column="1"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition/> | ||
<RowDefinition Height="1*"/> | ||
<RowDefinition/> | ||
</Grid.RowDefinitions> | ||
<TextBlock Name="tbTitle" Grid.Row="0" Text="{Binding Title}" VerticalAlignment="Bottom" Margin="0,0,10,0" Foreground="#222124" FontSize="16" FontWeight="DemiBold"/> | ||
<Grid Grid.Row="2"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock Name="tbAuthor" Grid.Column="0" Grid.Row="2" Text="{Binding ChannelName}" VerticalAlignment="Top" | ||
Foreground="#222124" | ||
FontSize="14"/> | ||
<TextBlock Name="tbDuration" Grid.Column="1" Grid.Row="2" Text="{Binding Duration}" VerticalAlignment="Top" | ||
Foreground="#222124" | ||
FontSize="14" | ||
Margin="10,0,10,0"/> | ||
</Grid> | ||
|
||
</Grid> | ||
</Grid> | ||
</UserControl> |
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,15 @@ | ||
using System.Windows.Controls; | ||
|
||
namespace YoutubeDownloader.UserControls | ||
{ | ||
/// <summary> | ||
/// Interaction logic for VideoSelectedCard.xaml | ||
/// </summary> | ||
public partial class VideoSelectedCard : UserControl | ||
{ | ||
public VideoSelectedCard() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
Oops, something went wrong.