Skip to content

Commit 9fd5357

Browse files
KannagiKannagi
authored andcommitted
2023.03.28
1 parent 2f57fe7 commit 9fd5357

File tree

10 files changed

+111
-305
lines changed

10 files changed

+111
-305
lines changed

languages/en-US/yt-dlp-gui.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Main:
7979
# Advance Tab - Mdified
8080
Modified: Modified
8181
ModifiedModified: Modified Date
82+
ModifiedCreated: Created Date
8283
ModifiedUpload: Upload Date
8384
# Options Tab - Notifications
8485
Notifications: Notifications

languages/zh-TW/yt-dlp-gui.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Main:
7979
# Advance Tab - Mdified
8080
Modified: 修改時間
8181
ModifiedModified: 使用修改時間(預設)
82+
ModifiedCreated: 使用建立時間
8283
ModifiedUpload: 使用上傳時間
8384
# Options Tab - Notifications
8485
Notifications: 通知

yt-dlp-gui/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace yt_dlp_gui {
88
/// Interaction logic for App.xaml
99
/// </summary>
1010
public partial class App : Application {
11-
public static string CurrentVersion = "2023.03.21";
11+
public static string CurrentVersion = "2023.03.28";
1212
public static Lang Lang { get; set; } = new();
1313
private void Application_Startup(object sender, StartupEventArgs e) {
1414
var args = e.Args.ToList();

yt-dlp-gui/Models/Lang.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public class LangMain :INotifyPropertyChanged {
177177
[Description("Advance Tab - Mdified")]
178178
[YamlMember(Order = 1151)] public string Modified { get; set; } = "Modified";
179179
[YamlMember(Order = 1152)] public string ModifiedModified { get; set; } = "Modified Date";
180+
[YamlMember(Order = 1153)] public string ModifiedCreated { get; set; } = "Created Date";
180181
[YamlMember(Order = 1153)] public string ModifiedUpload { get; set; } = "Upload Date";
181182

182183
[Description("Options Tab - Notifications")]

yt-dlp-gui/Models/VTask.cs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using Swordfish.NET.Collections;
2+
using Swordfish.NET.Collections.Auxiliary;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.ComponentModel;
6+
using System.Linq;
7+
8+
namespace yt_dlp_gui.Models {
9+
public class VMain :INotifyPropertyChanged {
10+
public event PropertyChangedEventHandler? PropertyChanged;
11+
public List<Config> Configs { get; set; } = new List<Config>();
12+
public Config SelectedConfig { get; set; } = new Config();
13+
14+
}
15+
public class VTask :INotifyPropertyChanged {
16+
public event PropertyChangedEventHandler? PropertyChanged;
17+
public VTaskVideo Video { get; set; } = new VTaskVideo();
18+
public VTask() {
19+
20+
}
21+
}
22+
public class VTaskVideo :INotifyPropertyChanged {
23+
public event PropertyChangedEventHandler? PropertyChanged;
24+
public Video? Source { get; set; } = new();
25+
// Formats =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
26+
public IEnumerable<Format> Formats => getFormats(Source?.formats);
27+
public IEnumerable<Format> FormatsVideo => Formats.Where(x => x.type == FormatType.package || x.type == FormatType.video).OrderBy(x => x, ComparerVideo.Comparer);
28+
public IEnumerable<Format> FormatsAudio => Formats.Where(x => x.type == FormatType.package || x.type == FormatType.audio).OrderBy(x => x, ComparerAudio.Comparer);
29+
public IEnumerable<Format> RequestedFormats => getFormats(Source?.requested_formats);
30+
private IEnumerable<Format> getFormats(IEnumerable<Format>? source) {
31+
return source?.Select(row => {
32+
if (row.vcodec != "none" && row.acodec != "none") {
33+
row.type = FormatType.package;
34+
if (row.height.HasValue && row.width.HasValue) {
35+
row.resolution = $"{row.width.Value}x{row.height.Value}";
36+
}
37+
} else if (row.vcodec != "none") {
38+
row.type = FormatType.video;
39+
if (row.height.HasValue && row.width.HasValue) {
40+
row.resolution = $"{row.width.Value}x{row.height.Value}";
41+
}
42+
} else if (row.acodec != "none") {
43+
row.type = FormatType.audio;
44+
} else {
45+
row.type = FormatType.other;
46+
}
47+
//Video Codec
48+
if (row.vcodec.StartsWith("vp9", StringComparison.InvariantCultureIgnoreCase)) {
49+
row.vcodec = "VP9";
50+
} else if (row.vcodec.StartsWith("av01", StringComparison.InvariantCultureIgnoreCase)) {
51+
row.vcodec = "AV1";
52+
} else if (row.vcodec.StartsWith("avc", StringComparison.InvariantCultureIgnoreCase)) {
53+
row.vcodec = "H.264";
54+
}
55+
//Audio Codec
56+
if (row.acodec.StartsWith("mp4a", StringComparison.InvariantCultureIgnoreCase)) {
57+
row.acodec = "AAC";
58+
} else if (row.acodec.StartsWith("opus", StringComparison.InvariantCultureIgnoreCase)) {
59+
row.acodec = "OPUS";
60+
}
61+
return row;
62+
}).ToList() ?? new List<Format>();
63+
}
64+
65+
// Chapters =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
66+
public IEnumerable<Chapters> Chapters =>
67+
(Source?.chapters?.Any() ?? false
68+
? new[] {
69+
new Chapters() { title = App.Lang.Main.ChaptersAll, type = ChaptersType.None },
70+
new Chapters() { title = App.Lang.Main.ChaptersSplite, type = ChaptersType.Split },
71+
}.Concat(Source.chapters)
72+
: new[] {
73+
new Chapters() { title = App.Lang.Main.ChaptersNone, type = ChaptersType.None },
74+
}).ToList();
75+
}
76+
}

yt-dlp-gui/Models/Video.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public class Video : INotifyPropertyChanged {
2020
public string upload_date { get; set; } = string.Empty;
2121
}
2222
public enum ModifiedType {
23-
Modified, Upload
23+
Modified, Upload, Created
2424
}
2525
}

yt-dlp-gui/ViewModels/Main.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public void CheckExtension() {
132132
if (RemuxVideo) return;
133133
if (!string.IsNullOrWhiteSpace(TargetName)) {
134134
if (selectedVideo != null && selectedAudio != null) {
135+
/*
135136
if (selectedVideo.type == FormatType.package) {
136137
TargetName = Path.ChangeExtension(TargetName, selectedVideo.video_ext);
137138
} else if (selectedVideo.video_ext == "webm" && selectedAudio.audio_ext == "webm") {
@@ -140,8 +141,23 @@ public void CheckExtension() {
140141
TargetName = Path.ChangeExtension(TargetName, "mp4");
141142
} else {
142143
TargetName = Path.ChangeExtension(TargetName, "mkv");
144+
}*/
145+
TargetName = Path.ChangeExtension(TargetName, OriginExt);
146+
}
147+
}
148+
}
149+
public string OriginExt {
150+
get {
151+
if (selectedVideo != null && selectedAudio != null) {
152+
if (selectedVideo.type == FormatType.package) {
153+
return selectedVideo.video_ext.ToLower().Trim('.');
154+
} else if (selectedVideo.video_ext == "webm" && selectedAudio.audio_ext == "webm") {
155+
return "webm";
156+
} else if (selectedVideo.video_ext == "mp4" && selectedAudio.audio_ext == "m4a") {
157+
return "mp4";
143158
}
144159
}
160+
return "mkv";
145161
}
146162
}
147163
public Lang Lang { get; set; } = new();

yt-dlp-gui/Views/Main.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@
683683
<TextBlock Grid.Row="7" Text="{Binding Source={x:Static app:App.Lang}, Path=Main.Modified}" VerticalAlignment="Center" HorizontalAlignment="Right"/>
684684
<ComboBox Grid.Row="7" Grid.Column="2" SelectedValue="{Binding ModifiedType}" SelectedValuePath="Tag" IsEnabled="{Binding Enable.UseCookie}" HorizontalAlignment="Left">
685685
<ComboBoxItem Content="{Binding Source={x:Static app:App.Lang}, Path=Main.ModifiedModified}" Tag="{x:Static m:ModifiedType.Modified}"/>
686+
<ComboBoxItem Content="{Binding Source={x:Static app:App.Lang}, Path=Main.ModifiedCreated}" Tag="{x:Static m:ModifiedType.Created}"/>
686687
<ComboBoxItem Content="{Binding Source={x:Static app:App.Lang}, Path=Main.ModifiedUpload}" Tag="{x:Static m:ModifiedType.Upload}"/>
687688
</ComboBox>
688689
</Grid>

0 commit comments

Comments
 (0)