Skip to content

Commit

Permalink
2023.03.28
Browse files Browse the repository at this point in the history
  • Loading branch information
Kannagi authored and Kannagi committed Mar 28, 2023
1 parent 2f57fe7 commit 9fd5357
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 305 deletions.
1 change: 1 addition & 0 deletions languages/en-US/yt-dlp-gui.lang
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Main:
# Advance Tab - Mdified
Modified: Modified
ModifiedModified: Modified Date
ModifiedCreated: Created Date
ModifiedUpload: Upload Date
# Options Tab - Notifications
Notifications: Notifications
Expand Down
1 change: 1 addition & 0 deletions languages/zh-TW/yt-dlp-gui.lang
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Main:
# Advance Tab - Mdified
Modified: 修改時間
ModifiedModified: 使用修改時間(預設)
ModifiedCreated: 使用建立時間
ModifiedUpload: 使用上傳時間
# Options Tab - Notifications
Notifications: 通知
Expand Down
2 changes: 1 addition & 1 deletion yt-dlp-gui/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace yt_dlp_gui {
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application {
public static string CurrentVersion = "2023.03.21";
public static string CurrentVersion = "2023.03.28";
public static Lang Lang { get; set; } = new();
private void Application_Startup(object sender, StartupEventArgs e) {
var args = e.Args.ToList();
Expand Down
1 change: 1 addition & 0 deletions yt-dlp-gui/Models/Lang.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public class LangMain :INotifyPropertyChanged {
[Description("Advance Tab - Mdified")]
[YamlMember(Order = 1151)] public string Modified { get; set; } = "Modified";
[YamlMember(Order = 1152)] public string ModifiedModified { get; set; } = "Modified Date";
[YamlMember(Order = 1153)] public string ModifiedCreated { get; set; } = "Created Date";
[YamlMember(Order = 1153)] public string ModifiedUpload { get; set; } = "Upload Date";

[Description("Options Tab - Notifications")]
Expand Down
76 changes: 76 additions & 0 deletions yt-dlp-gui/Models/VTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Swordfish.NET.Collections;
using Swordfish.NET.Collections.Auxiliary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace yt_dlp_gui.Models {
public class VMain :INotifyPropertyChanged {
public event PropertyChangedEventHandler? PropertyChanged;
public List<Config> Configs { get; set; } = new List<Config>();
public Config SelectedConfig { get; set; } = new Config();

}
public class VTask :INotifyPropertyChanged {
public event PropertyChangedEventHandler? PropertyChanged;
public VTaskVideo Video { get; set; } = new VTaskVideo();
public VTask() {

}
}
public class VTaskVideo :INotifyPropertyChanged {
public event PropertyChangedEventHandler? PropertyChanged;
public Video? Source { get; set; } = new();
// Formats =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
public IEnumerable<Format> Formats => getFormats(Source?.formats);
public IEnumerable<Format> FormatsVideo => Formats.Where(x => x.type == FormatType.package || x.type == FormatType.video).OrderBy(x => x, ComparerVideo.Comparer);
public IEnumerable<Format> FormatsAudio => Formats.Where(x => x.type == FormatType.package || x.type == FormatType.audio).OrderBy(x => x, ComparerAudio.Comparer);
public IEnumerable<Format> RequestedFormats => getFormats(Source?.requested_formats);
private IEnumerable<Format> getFormats(IEnumerable<Format>? source) {
return source?.Select(row => {
if (row.vcodec != "none" && row.acodec != "none") {
row.type = FormatType.package;
if (row.height.HasValue && row.width.HasValue) {
row.resolution = $"{row.width.Value}x{row.height.Value}";
}
} else if (row.vcodec != "none") {
row.type = FormatType.video;
if (row.height.HasValue && row.width.HasValue) {
row.resolution = $"{row.width.Value}x{row.height.Value}";
}
} else if (row.acodec != "none") {
row.type = FormatType.audio;
} else {
row.type = FormatType.other;
}
//Video Codec
if (row.vcodec.StartsWith("vp9", StringComparison.InvariantCultureIgnoreCase)) {
row.vcodec = "VP9";
} else if (row.vcodec.StartsWith("av01", StringComparison.InvariantCultureIgnoreCase)) {
row.vcodec = "AV1";
} else if (row.vcodec.StartsWith("avc", StringComparison.InvariantCultureIgnoreCase)) {
row.vcodec = "H.264";
}
//Audio Codec
if (row.acodec.StartsWith("mp4a", StringComparison.InvariantCultureIgnoreCase)) {
row.acodec = "AAC";
} else if (row.acodec.StartsWith("opus", StringComparison.InvariantCultureIgnoreCase)) {
row.acodec = "OPUS";
}
return row;
}).ToList() ?? new List<Format>();
}

// Chapters =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
public IEnumerable<Chapters> Chapters =>
(Source?.chapters?.Any() ?? false
? new[] {
new Chapters() { title = App.Lang.Main.ChaptersAll, type = ChaptersType.None },
new Chapters() { title = App.Lang.Main.ChaptersSplite, type = ChaptersType.Split },
}.Concat(Source.chapters)
: new[] {
new Chapters() { title = App.Lang.Main.ChaptersNone, type = ChaptersType.None },
}).ToList();
}
}
2 changes: 1 addition & 1 deletion yt-dlp-gui/Models/Video.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public class Video : INotifyPropertyChanged {
public string upload_date { get; set; } = string.Empty;
}
public enum ModifiedType {
Modified, Upload
Modified, Upload, Created
}
}
16 changes: 16 additions & 0 deletions yt-dlp-gui/ViewModels/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void CheckExtension() {
if (RemuxVideo) return;
if (!string.IsNullOrWhiteSpace(TargetName)) {
if (selectedVideo != null && selectedAudio != null) {
/*
if (selectedVideo.type == FormatType.package) {
TargetName = Path.ChangeExtension(TargetName, selectedVideo.video_ext);
} else if (selectedVideo.video_ext == "webm" && selectedAudio.audio_ext == "webm") {
Expand All @@ -140,8 +141,23 @@ public void CheckExtension() {
TargetName = Path.ChangeExtension(TargetName, "mp4");
} else {
TargetName = Path.ChangeExtension(TargetName, "mkv");
}*/
TargetName = Path.ChangeExtension(TargetName, OriginExt);
}
}
}
public string OriginExt {
get {
if (selectedVideo != null && selectedAudio != null) {
if (selectedVideo.type == FormatType.package) {
return selectedVideo.video_ext.ToLower().Trim('.');
} else if (selectedVideo.video_ext == "webm" && selectedAudio.audio_ext == "webm") {
return "webm";
} else if (selectedVideo.video_ext == "mp4" && selectedAudio.audio_ext == "m4a") {
return "mp4";
}
}
return "mkv";
}
}
public Lang Lang { get; set; } = new();
Expand Down
1 change: 1 addition & 0 deletions yt-dlp-gui/Views/Main.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@
<TextBlock Grid.Row="7" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.Modified}" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<ComboBox Grid.Row="7" Grid.Column="2" SelectedValue="{Binding ModifiedType}" SelectedValuePath="Tag" IsEnabled="{Binding Enable.UseCookie}" HorizontalAlignment="Left">
<ComboBoxItem Content="{Binding Source={x:Static app:App.Lang}, Path=Main.ModifiedModified}" Tag="{x:Static m:ModifiedType.Modified}"/>
<ComboBoxItem Content="{Binding Source={x:Static app:App.Lang}, Path=Main.ModifiedCreated}" Tag="{x:Static m:ModifiedType.Created}"/>
<ComboBoxItem Content="{Binding Source={x:Static app:App.Lang}, Path=Main.ModifiedUpload}" Tag="{x:Static m:ModifiedType.Upload}"/>
</ComboBox>
</Grid>
Expand Down
Loading

0 comments on commit 9fd5357

Please sign in to comment.