Skip to content

Commit

Permalink
Updated files
Browse files Browse the repository at this point in the history
  • Loading branch information
BlyZeDev committed Feb 21, 2023
1 parent 87f0e10 commit 34245a3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Common/AppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static class AppManager

static AppManager()
{
CurrentVersion = new Version("2.2.1.0");
CurrentVersion = new Version("2.3.0.0");

ProgramFolderPath = Path.Combine(
Environment.GetFolderPath(
Expand Down
2 changes: 1 addition & 1 deletion MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ private async void DownloadBtn_Click(object sender, RoutedEventArgs e)
TaskbarInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Indeterminate;
DownloadProgressBar.IsIndeterminate = true;

var wasDownloadedSuccessfully = await _client.DownloadVideoAsync(
var wasDownloadedSuccessfully = await _client.DownloadFileAsync(
new Metadata(
CurrentVideo!.Url,
Path.Combine(DownloadPathTextBox.Text, TitleTextBox.Text),
Expand Down
37 changes: 23 additions & 14 deletions Services/YouTubeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using FFMpegCore;
using Newtonsoft.Json.Linq;
using Syncfusion.Windows.Controls.Input;
using System;
using System.Collections.Generic;
using System.Drawing;
Expand Down Expand Up @@ -36,7 +37,7 @@ public interface IYouTubeClient

public ValueTask<bool> TryDownloadThumbnailAsync(VideoId videoId, string fullPath);

public ValueTask<bool> DownloadVideoAsync(Metadata metadata, DownloadStartedCallback started, DownloadProgressCallback progress, DownloadCancelledCallback cancelled);
public ValueTask<bool> DownloadFileAsync(Metadata metadata, DownloadStartedCallback started, DownloadProgressCallback progress, DownloadCancelledCallback cancelled);

public Task CancelDownloadIfRunning();
}
Expand Down Expand Up @@ -143,7 +144,7 @@ public async ValueTask<bool> TryDownloadThumbnailAsync(VideoId videoId, string f
return false;
}

public async ValueTask<bool> DownloadVideoAsync(Metadata metadata, DownloadStartedCallback started, DownloadProgressCallback progress, DownloadCancelledCallback cancelled)
public async ValueTask<bool> DownloadFileAsync(Metadata metadata, DownloadStartedCallback started, DownloadProgressCallback progress, DownloadCancelledCallback cancelled)
{
IsDownloading = true;

Expand All @@ -154,7 +155,7 @@ public async ValueTask<bool> DownloadVideoAsync(Metadata metadata, DownloadStart
CreateCts();

var fullStreams = await GetStreamsAsync(metadata);

started();

if (fullStreams.IsVideoStreamEmpty)
Expand All @@ -169,8 +170,8 @@ public async ValueTask<bool> DownloadVideoAsync(Metadata metadata, DownloadStart
{
string temppath = Path.GetTempPath();

string videotemp = Path.Combine(temppath, $"video-stream_{Guid.NewGuid()}.tmp");
string audiotemp = Path.Combine(temppath, $"audio-stream_{Guid.NewGuid()}.tmp");
string videotemp = Path.Combine(temppath, $"video-stream_{Guid.NewGuid()}.tmp");

deletionFiles.Add($"{videotemp}.mp4");
deletionFiles.Add($"{audiotemp}.{fullStreams.AudioStream.Container.Name}");
Expand Down Expand Up @@ -215,11 +216,14 @@ private async ValueTask<FullStreamsInfo> GetStreamsAsync(Metadata metadata)
private async Task DownloadVideoTempFile(VideoOnlyStreamInfo videoStream, Metadata metadata, string temppath, DownloadProgressCallback progress)
{
await FFMpegArguments
.FromUrlInput(new Uri(videoStream.Url))
.FromUrlInput(new Uri(videoStream.Url), x =>
{
x.Seek(metadata.StartTime);
x.WithDuration(metadata.GetDuration());
})
.OutputToFile($"{temppath}.mp4", true, x =>
{
x.WithCustomArgument($"-ss {metadata.StartTime} -t {metadata.GetDuration()}");
x.WithVideoBitrate((int)videoStream.Bitrate.KiloBitsPerSecond);
x.WithVideoBitrate((int)Math.Round(videoStream.Bitrate.KiloBitsPerSecond, 0));
x.WithFastStart();
x.UsingShortest(true);
x.UsingMultithreading(true);
Expand All @@ -235,11 +239,14 @@ await FFMpegArguments
private async Task DownloadAudioTempFile(AudioOnlyStreamInfo audioStream, Metadata metadata, string temppath, DownloadProgressCallback progress)
{
await FFMpegArguments
.FromUrlInput(new Uri(audioStream.Url))
.FromUrlInput(new Uri(audioStream.Url), x =>
{
x.Seek(metadata.StartTime);
x.WithDuration(metadata.GetDuration());
})
.OutputToFile($"{temppath}.{audioStream.Container.Name}", true, x =>
{
x.WithCustomArgument($"-ss {metadata.StartTime} -t {metadata.GetDuration()}");
x.WithAudioBitrate((int)audioStream.Bitrate.KiloBitsPerSecond);
x.WithAudioBitrate((int)Math.Round(audioStream.Bitrate.KiloBitsPerSecond, 0));
x.WithFastStart();
x.UsingShortest(true);
x.UsingMultithreading(true);
Expand All @@ -255,11 +262,13 @@ await FFMpegArguments
private async Task DownloadAudioFile(AudioOnlyStreamInfo audioStream, Metadata metadata, DownloadProgressCallback progress)
{
await FFMpegArguments
.FromUrlInput(new Uri(audioStream.Url))
.OutputToFile($"{metadata.FullPath}.mp3", true, x =>
.FromUrlInput(new Uri(audioStream.Url), x =>
{
x.Seek(metadata.StartTime);
x.WithDuration(metadata.GetDuration());
})
.OutputToFile(metadata.FullPath + ".mp3", true, x =>
{
x.WithCustomArgument($"-ss {metadata.StartTime} -t {metadata.GetDuration()}");
x.WithAudioBitrate((int)audioStream.Bitrate.KiloBitsPerSecond);
x.WithAudioCodec(FFMpegCore.Enums.AudioCodec.LibMp3Lame);
x.WithFastStart();
x.UsingShortest(true);
Expand Down
2 changes: 1 addition & 1 deletion Version.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2.2.1.0</version>
<version>2.3.0.0</version>
<url>https://github.com/BlyZeYT/YouTube-Downloader/releases/download/2.2.1.0/YouTube-Downloader-v2.2.1.0.zip</url>
<mandatory>false</mandatory>
</item>
14 changes: 7 additions & 7 deletions YouTubeDownloaderV2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@

<ItemGroup>
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.6" />
<PackageReference Include="FFMpegCore" Version="4.7.0" />
<PackageReference Include="FFMpegCore" Version="5.0.2" />
<PackageReference Include="Gu.Wpf.Adorners" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
<PackageReference Include="Syncfusion.SfInput.WPF" Version="20.4.0.43" />
<PackageReference Include="Syncfusion.SfProgressBar.WPF" Version="20.4.0.43" />
<PackageReference Include="Syncfusion.Shared.WPF" Version="20.4.0.43" />
<PackageReference Include="Syncfusion.SfInput.WPF" Version="20.4.0.51" />
<PackageReference Include="Syncfusion.SfProgressBar.WPF" Version="20.4.0.51" />
<PackageReference Include="Syncfusion.Shared.WPF" Version="20.4.0.51" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="YoutubeExplode" Version="6.2.5" />
<PackageReference Include="YoutubeExplode.Converter" Version="6.2.5" />
<PackageReference Include="YoutubeExplode" Version="6.2.6" />
<PackageReference Include="YoutubeExplode.Converter" Version="6.2.6" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 34245a3

Please sign in to comment.