Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e8c316bc2 | ||
|
|
f9853efe1a | ||
|
|
55d04877f6 |
No files matched your search
@@ -6,6 +6,14 @@
|
|||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
<Version>0.1.0</Version>
|
||||||
|
<Title>PantherByte</Title>
|
||||||
|
<Authors>Region 15 Schools</Authors>
|
||||||
|
<PackageProjectUrl>https://github.com/R15-Software-Dev/PantherByte</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://github.com/R15-Software-Dev/PantherByte</RepositoryUrl>
|
||||||
|
<Company>Region 15 Schools</Company>
|
||||||
|
<AssemblyVersion>0.0.1.0</AssemblyVersion>
|
||||||
|
<FileVersion>0.0.1.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Avalonia.Controls;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using PantherByte.Messages;
|
using PantherByte.Messages;
|
||||||
@@ -17,8 +19,8 @@ namespace PantherByte.ViewModels;
|
|||||||
public partial class MainWindowViewModel : ViewModelBase {
|
public partial class MainWindowViewModel : ViewModelBase {
|
||||||
private string _link = string.Empty;
|
private string _link = string.Empty;
|
||||||
private string _saveLocation = string.Empty;
|
private string _saveLocation = string.Empty;
|
||||||
private string _format = "mp3";
|
private string _format = "mp4";
|
||||||
private bool _isDownloading = false;
|
private ObservableCollection<string> _availableFormats = ["mp4", "mp3", "wav", "aac", "mkv"];
|
||||||
private bool _canDownload = true;
|
private bool _canDownload = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -37,24 +39,20 @@ public partial class MainWindowViewModel : ViewModelBase {
|
|||||||
get => _format;
|
get => _format;
|
||||||
set => this.RaiseAndSetIfChanged(ref _format, value);
|
set => this.RaiseAndSetIfChanged(ref _format, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<string> AvailableFormats {
|
||||||
|
get => _availableFormats;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _availableFormats, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The folder to save the files in. This will become the argument passed to the "-P" argument in
|
/// The folder to save the files in. This will become the argument passed to the "-P" argument in
|
||||||
/// <see cref="GenerateCmdStringAsync"/>.
|
/// <see cref="GenerateCmdArgsAsync"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SaveLocation {
|
public string SaveLocation {
|
||||||
get => _saveLocation;
|
get => _saveLocation;
|
||||||
set => this.RaiseAndSetIfChanged(ref _saveLocation, value);
|
set => this.RaiseAndSetIfChanged(ref _saveLocation, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates if the command is currently running. When the command is running, the application
|
|
||||||
/// should disable all inputs and/or open a blocking modal window.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsDownloading {
|
|
||||||
get => _isDownloading;
|
|
||||||
set => this.RaiseAndSetIfChanged(ref _isDownloading, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if the file can be downloaded. If not, the download button is disabled.
|
/// Indicates if the file can be downloaded. If not, the download button is disabled.
|
||||||
@@ -116,7 +114,7 @@ public partial class MainWindowViewModel : ViewModelBase {
|
|||||||
Console.WriteLine(ex.ToString());
|
Console.WriteLine(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates the arguments used for the main command string.
|
/// Generates the arguments used for the main command string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -126,16 +124,27 @@ public partial class MainWindowViewModel : ViewModelBase {
|
|||||||
// yt-dlp requires usage of ffmpeg as well.
|
// yt-dlp requires usage of ffmpeg as well.
|
||||||
// Code will be executed when the button is clicked.
|
// Code will be executed when the button is clicked.
|
||||||
|
|
||||||
var fileName = "";
|
return await Task.Run(() => {
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
var fileName = "";
|
||||||
Console.WriteLine("Using Windows program.");
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
||||||
fileName = "Programs/yt-dlp-win64.exe";
|
Console.WriteLine("Using Windows program.");
|
||||||
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
|
fileName = "Programs/yt-dlp-win64.exe";
|
||||||
Console.WriteLine("Using Linux program. May require additional run permissions.");
|
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
|
||||||
fileName = "Programs/yt-dlp-linux";
|
Console.WriteLine("Using Linux program. May require additional run permissions.");
|
||||||
}
|
fileName = "Programs/yt-dlp-linux";
|
||||||
|
}
|
||||||
|
|
||||||
return await Task.Run(() => new List<string>([fileName, Link, "-t", Format, "-P", SaveLocation, "--no-playlist"]));
|
List<string> args = [fileName, Link, "-P", SaveLocation, "--no-playlist"];
|
||||||
|
|
||||||
|
// WAV files require special command arguments
|
||||||
|
if (Format.Equals("wav")) {
|
||||||
|
args.AddRange(["--extract-audio", "--audio-format", Format]);
|
||||||
|
} else {
|
||||||
|
args.AddRange(["-t", Format]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -33,52 +33,48 @@
|
|||||||
</ExperimentalAcrylicBorder.Material>
|
</ExperimentalAcrylicBorder.Material>
|
||||||
</ExperimentalAcrylicBorder>
|
</ExperimentalAcrylicBorder>
|
||||||
|
|
||||||
<Grid
|
<StackPanel Margin="20 35 20 20"
|
||||||
Margin="20 35 20 20"
|
Width="500"
|
||||||
ShowGridLines="False"
|
Spacing="10"
|
||||||
Width="500"
|
HorizontalAlignment="Stretch">
|
||||||
RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto"
|
<TextBlock Text="Youtube Video Downloads"
|
||||||
RowSpacing="10">
|
FontSize="30"/>
|
||||||
<TextBlock
|
<TextBlock Text="Enter your video link and save location."
|
||||||
Grid.Row="0"
|
FontSize="20"></TextBlock>
|
||||||
Text="Youtube Video Downloads"
|
<Border BorderBrush="White" BorderThickness="0,0,0,1"/>
|
||||||
FontSize="30"/>
|
<StackPanel Spacing="5">
|
||||||
<TextBlock
|
|
||||||
Grid.Row="1"
|
|
||||||
Text="Enter your video link and save location."
|
|
||||||
FontSize="20"></TextBlock>
|
|
||||||
<Border Grid.Row="2" BorderBrush="White" BorderThickness="0,0,0,1"/>
|
|
||||||
<StackPanel Grid.Row="3" Spacing="5">
|
|
||||||
<TextBlock Text="Save location:"/>
|
<TextBlock Text="Save location:"/>
|
||||||
<Grid
|
<Grid ColumnDefinitions="*, 30"
|
||||||
ColumnDefinitions="*, 30"
|
ColumnSpacing="5">
|
||||||
ColumnSpacing="5">
|
<TextBox Grid.Column="0"
|
||||||
<TextBox
|
Text="{Binding SaveLocation}"
|
||||||
Grid.Column="0"
|
Watermark="Choose a folder..."/>
|
||||||
Text="{Binding SaveLocation}"
|
<Button Grid.Column="1"
|
||||||
Watermark="Choose a folder..."/>
|
Content=">"
|
||||||
<Button
|
HorizontalContentAlignment="Center"
|
||||||
Grid.Column="1"
|
VerticalContentAlignment="Center"
|
||||||
Content=">"
|
Command="{Binding GetSaveLocationCommand}"/>
|
||||||
HorizontalContentAlignment="Center"
|
|
||||||
VerticalContentAlignment="Center"
|
|
||||||
Command="{Binding GetSaveLocationCommand}"/>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="4" Spacing="5">
|
<StackPanel Spacing="5">
|
||||||
<TextBlock Text="Video link:"/>
|
<TextBlock Text="Video link:"/>
|
||||||
<TextBox
|
<TextBox Text="{Binding Link}"
|
||||||
Text="{Binding Link}"
|
Watermark="Paste link here..."/>
|
||||||
Watermark="Paste link here..."/>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button
|
<StackPanel Spacing="5"
|
||||||
Grid.Row="5"
|
HorizontalAlignment="Stretch">
|
||||||
Content="Download"
|
<TextBlock Text="Format:"/>
|
||||||
HorizontalAlignment="Center"
|
<ComboBox HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Center"
|
ItemsSource="{Binding AvailableFormats}"
|
||||||
IsEnabled="{Binding CanDownload}"
|
SelectedItem="{Binding Format, Mode=TwoWay}">
|
||||||
Command="{Binding DownloadFileCommand}"/>
|
</ComboBox>
|
||||||
</Grid>
|
</StackPanel>
|
||||||
|
<Button Content="Download"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
IsEnabled="{Binding CanDownload}"
|
||||||
|
Command="{Binding DownloadFileCommand}"/>
|
||||||
|
</StackPanel>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|
||||||
</Window>
|
</Window>
|
||||||
Reference in new issue
Block a user