Add - Added ScaleAndBorder to settings
Chg - Adjusted some log messages
This commit is contained in:
parent
f78df5b07f
commit
d220a7d0db
|
@ -151,6 +151,7 @@ public class Crunchyroll{
|
|||
CrunOptions.SelectedCalendarLanguage = "de";
|
||||
CrunOptions.DlVideoOnce = true;
|
||||
CrunOptions.StreamEndpoint = "web/firefox";
|
||||
CrunOptions.SubsAddScaledBorder = ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
||||
|
||||
CrunOptions.History = true;
|
||||
|
||||
|
@ -1023,12 +1024,14 @@ public class Crunchyroll{
|
|||
DownloadSpeed = 0,
|
||||
Doing = "Decrypting"
|
||||
};
|
||||
Queue.Refresh();
|
||||
|
||||
var assetIdRegexMatch = Regex.Match(chosenVideoSegments.segments[0].uri, @"/assets/(?:p/)?([^_,]+)");
|
||||
var assetId = assetIdRegexMatch.Success ? assetIdRegexMatch.Groups[1].Value : null;
|
||||
var sessionId = Helpers.GenerateSessionId();
|
||||
|
||||
Console.WriteLine("Decryption Needed, attempting to decrypt");
|
||||
//TODO change back from error
|
||||
Console.Error.WriteLine("Decryption Needed, attempting to decrypt");
|
||||
|
||||
if (!_widevine.canDecrypt){
|
||||
dlFailed = true;
|
||||
|
@ -1057,8 +1060,9 @@ public class Crunchyroll{
|
|||
var decRequestResponse = await HttpClientReq.Instance.SendHttpRequest(decRequest);
|
||||
|
||||
if (!decRequestResponse.IsOk){
|
||||
Console.WriteLine("Request to DRM Authentication failed: ");
|
||||
Console.Error.WriteLine("Request to DRM Authentication failed: ");
|
||||
MainWindow.Instance.ShowError("Request to DRM Authentication failed");
|
||||
dlFailed = true;
|
||||
return new DownloadResponse{
|
||||
Data = files,
|
||||
Error = dlFailed,
|
||||
|
@ -1066,7 +1070,8 @@ public class Crunchyroll{
|
|||
ErrorText = "DRM Authentication failed"
|
||||
};
|
||||
}
|
||||
|
||||
//TODO change back from error
|
||||
Console.Error.WriteLine("Request to DRM Authentication successful");
|
||||
DrmAuthData authData = Helpers.Deserialize<DrmAuthData>(decRequestResponse.ResponseContent, SettingsJsonSerializerSettings) ?? new DrmAuthData();
|
||||
|
||||
|
||||
|
@ -1076,7 +1081,8 @@ public class Crunchyroll{
|
|||
var encryptionKeys = await _widevine.getKeys(chosenVideoSegments.pssh, "https://lic.drmtoday.com/license-proxy-widevine/cenc/", authDataDict);
|
||||
|
||||
if (encryptionKeys.Count == 0){
|
||||
Console.WriteLine("Failed to get encryption keys");
|
||||
Console.Error.WriteLine("Failed to get encryption keys");
|
||||
dlFailed = true;
|
||||
return new DownloadResponse{
|
||||
Data = files,
|
||||
Error = dlFailed,
|
||||
|
@ -1093,7 +1099,8 @@ public class Crunchyroll{
|
|||
var commandAudio = commandBase + $" \"{tempTsFile}.audio.enc.m4s\" \"{tempTsFile}.audio.m4s\"";
|
||||
|
||||
if (videoDownloaded){
|
||||
Console.WriteLine("Started decrypting video");
|
||||
//TODO change back from error
|
||||
Console.Error.WriteLine("Started decrypting video");
|
||||
var decryptVideo = await Helpers.ExecuteCommandAsync("mp4decrypt", CfgManager.PathMP4Decrypt, commandVideo);
|
||||
|
||||
if (!decryptVideo.IsOk){
|
||||
|
@ -1370,8 +1377,14 @@ public class Crunchyroll{
|
|||
subsAssReqResponse.ResponseContent = '\ufeff' + subsAssReqResponse.ResponseContent;
|
||||
var sBodySplit = subsAssReqResponse.ResponseContent.Split(new[]{ "\r\n" }, StringSplitOptions.None).ToList();
|
||||
// Insert 'ScaledBorderAndShadow: yes' after the second line
|
||||
if (sBodySplit.Count > 2)
|
||||
if (sBodySplit.Count > 2){
|
||||
if (options.SubsAddScaledBorder == ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes){
|
||||
sBodySplit.Insert(2, "ScaledBorderAndShadow: yes");
|
||||
}else if (options.SubsAddScaledBorder == ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo){
|
||||
sBodySplit.Insert(2, "ScaledBorderAndShadow: no");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Rejoin the lines back into a single string
|
||||
subsAssReqResponse.ResponseContent = string.Join("\r\n", sBodySplit);
|
||||
|
|
|
@ -165,6 +165,12 @@ public enum DownloadMediaType{
|
|||
Subtitle,
|
||||
}
|
||||
|
||||
public enum ScaledBorderAndShadowSelection{
|
||||
DontAdd,
|
||||
ScaledBorderAndShadowYes,
|
||||
ScaledBorderAndShadowNo,
|
||||
}
|
||||
|
||||
public enum SonarrCoverType{
|
||||
Banner,
|
||||
FanArt,
|
||||
|
|
|
@ -59,21 +59,18 @@ public class Helpers{
|
|||
return milliseconds + highResTimestamp;
|
||||
}
|
||||
|
||||
public static void ConvertChapterFileForFFMPEG(string chapterFilePath)
|
||||
{
|
||||
public static void ConvertChapterFileForFFMPEG(string chapterFilePath){
|
||||
var chapterLines = File.ReadAllLines(chapterFilePath);
|
||||
var ffmpegChapterLines = new List<string> { ";FFMETADATA1" };
|
||||
var ffmpegChapterLines = new List<string>{ ";FFMETADATA1" };
|
||||
|
||||
for (int i = 0; i < chapterLines.Length; i += 2)
|
||||
{
|
||||
for (int i = 0; i < chapterLines.Length; i += 2){
|
||||
var timeLine = chapterLines[i];
|
||||
var nameLine = chapterLines[i + 1];
|
||||
|
||||
var timeParts = timeLine.Split('=');
|
||||
var nameParts = nameLine.Split('=');
|
||||
|
||||
if (timeParts.Length == 2 && nameParts.Length == 2)
|
||||
{
|
||||
if (timeParts.Length == 2 && nameParts.Length == 2){
|
||||
var startTime = TimeSpan.Parse(timeParts[1]).TotalMilliseconds;
|
||||
var endTime = i + 2 < chapterLines.Length ? TimeSpan.Parse(chapterLines[i + 2].Split('=')[1]).TotalMilliseconds : startTime + 10000;
|
||||
|
||||
|
@ -89,6 +86,7 @@ public class Helpers{
|
|||
}
|
||||
|
||||
public static async Task<(bool IsOk, int ErrorCode)> ExecuteCommandAsync(string type, string bin, string command){
|
||||
try{
|
||||
using (var process = new Process()){
|
||||
process.StartInfo.FileName = bin;
|
||||
process.StartInfo.Arguments = command;
|
||||
|
@ -121,6 +119,10 @@ public class Helpers{
|
|||
|
||||
return (IsOk: isSuccess, ErrorCode: process.ExitCode);
|
||||
}
|
||||
} catch (Exception ex){
|
||||
Console.Error.WriteLine($"An error occurred: {ex.Message}");
|
||||
return (IsOk: false, ErrorCode: -1);
|
||||
}
|
||||
}
|
||||
|
||||
public static double CalculateCosineSimilarity(string text1, string text2){
|
||||
|
|
|
@ -53,6 +53,9 @@ public class CrDownloadOptions{
|
|||
[YamlMember(Alias = "mux_skip_subs", ApplyNamingConventions = false)]
|
||||
public bool SkipSubsMux{ get; set; }
|
||||
|
||||
[YamlMember(Alias = "subs_add_scaled_border", ApplyNamingConventions = false)]
|
||||
public ScaledBorderAndShadowSelection SubsAddScaledBorder{ get; set; }
|
||||
|
||||
[YamlMember(Alias = "mux_mp4", ApplyNamingConventions = false)]
|
||||
public bool Mp4{ get; set; }
|
||||
|
||||
|
|
|
@ -33,6 +33,17 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
[ObservableProperty]
|
||||
private bool _downloadChapters = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _addScaledBorderAndShadow = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private ComboBoxItem _selectedScaledBorderAndShadow;
|
||||
|
||||
public ObservableCollection<ComboBoxItem> ScaledBorderAndShadow{ get; } = new(){
|
||||
new ComboBoxItem(){ Content = "ScaledBorderAndShadow: yes" },
|
||||
new ComboBoxItem(){ Content = "ScaledBorderAndShadow: no" },
|
||||
};
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _muxToMp4;
|
||||
|
||||
|
@ -297,6 +308,9 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
SonarrApiKey = props.ApiKey + "";
|
||||
}
|
||||
|
||||
AddScaledBorderAndShadow = options.SubsAddScaledBorder is ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo or ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
||||
SelectedScaledBorderAndShadow = GetScaledBorderAndShadowFromOptions(options);
|
||||
|
||||
DownloadVideo = !options.Novids;
|
||||
DownloadAudio = !options.Noaudio;
|
||||
DownloadVideoForEveryDub = !options.DlVideoOnce;
|
||||
|
@ -362,6 +376,7 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
Crunchyroll.Instance.CrunOptions.Numbers = LeadingNumbers;
|
||||
Crunchyroll.Instance.CrunOptions.FileName = FileName;
|
||||
|
||||
Crunchyroll.Instance.CrunOptions.SubsAddScaledBorder = GetScaledBorderAndShadowSelection();
|
||||
|
||||
List<string> softSubs = new List<string>();
|
||||
foreach (var listBoxItem in SelectedSubLang){
|
||||
|
@ -434,6 +449,35 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
CfgManager.WriteSettingsToFile();
|
||||
}
|
||||
|
||||
|
||||
private ScaledBorderAndShadowSelection GetScaledBorderAndShadowSelection(){
|
||||
if (!AddScaledBorderAndShadow){
|
||||
return ScaledBorderAndShadowSelection.DontAdd;
|
||||
}
|
||||
|
||||
if (SelectedScaledBorderAndShadow.Content + "" == "ScaledBorderAndShadow: yes"){
|
||||
return ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
||||
}
|
||||
|
||||
if (SelectedScaledBorderAndShadow.Content + "" == "ScaledBorderAndShadow: no"){
|
||||
return ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo;
|
||||
}
|
||||
|
||||
return ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
||||
}
|
||||
|
||||
private ComboBoxItem GetScaledBorderAndShadowFromOptions(CrDownloadOptions options){
|
||||
switch (options.SubsAddScaledBorder){
|
||||
case (ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes):
|
||||
return ScaledBorderAndShadow.FirstOrDefault(a => a.Content != null && (string)a.Content == "ScaledBorderAndShadow: yes") ?? ScaledBorderAndShadow[0];
|
||||
case ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo:
|
||||
return ScaledBorderAndShadow.FirstOrDefault(a => a.Content != null && (string)a.Content == "ScaledBorderAndShadow: no") ?? ScaledBorderAndShadow[0];
|
||||
default:
|
||||
return ScaledBorderAndShadow[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void UpdateSubAndDubString(){
|
||||
if (SelectedSubLang.Count == 0){
|
||||
SelectedSubs = "none";
|
||||
|
@ -626,6 +670,14 @@ public partial class SettingsPageViewModel : ViewModelBase{
|
|||
partial void OnSelectedStreamEndpointChanged(ComboBoxItem value){
|
||||
UpdateSettings();
|
||||
}
|
||||
|
||||
partial void OnAddScaledBorderAndShadowChanged(bool value){
|
||||
UpdateSettings();
|
||||
}
|
||||
|
||||
partial void OnSelectedScaledBorderAndShadowChanged(ComboBoxItem value){
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public class MuxingParam{
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<Popup IsLightDismissEnabled="True"
|
||||
IsOpen="{Binding IsChecked, ElementName=DropdownButtonDub, Mode=TwoWay}" Placement="Bottom"
|
||||
IsOpen="{Binding IsChecked, ElementName=DropdownButtonDub, Mode=TwoWay}"
|
||||
Placement="Bottom"
|
||||
PlacementTarget="{Binding ElementName=DropdownButtonDub}">
|
||||
<Border BorderThickness="1" Background="{DynamicResource ComboBoxDropDownBackground}">
|
||||
<ListBox x:Name="ListBoxDubsSelection" SelectionMode="Multiple,Toggle" Width="210"
|
||||
|
@ -107,6 +108,18 @@
|
|||
</StackPanel>
|
||||
</controls:SettingsExpander.Footer>
|
||||
|
||||
<controls:SettingsExpanderItem Content="Add ScaledBorderAndShadow ">
|
||||
<controls:SettingsExpanderItem.Footer>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ComboBox HorizontalContentAlignment="Center" IsVisible="{Binding AddScaledBorderAndShadow}" Margin="5 0" MinWidth="210" MaxDropDownHeight="400"
|
||||
ItemsSource="{Binding ScaledBorderAndShadow}"
|
||||
SelectedItem="{Binding SelectedScaledBorderAndShadow}">
|
||||
</ComboBox>
|
||||
<CheckBox IsChecked="{Binding AddScaledBorderAndShadow}"> </CheckBox>
|
||||
</StackPanel>
|
||||
</controls:SettingsExpanderItem.Footer>
|
||||
</controls:SettingsExpanderItem>
|
||||
|
||||
</controls:SettingsExpander>
|
||||
|
||||
<controls:SettingsExpander Header="History"
|
||||
|
@ -259,7 +272,8 @@
|
|||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBox Name="TargetTextBox2" HorizontalAlignment="Left" MinWidth="250"
|
||||
Text="{Binding MkvMergeOption }"></TextBox>
|
||||
Text="{Binding MkvMergeOption }">
|
||||
</TextBox>
|
||||
<Button HorizontalAlignment="Center" Margin="5 0" Command="{Binding AddMkvMergeParam}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<controls:SymbolIcon Symbol="Add" FontSize="18" />
|
||||
|
@ -274,11 +288,14 @@
|
|||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderBrush="#4a4a4a" Background="#4a4a4a" BorderThickness="1" CornerRadius="10" Margin="2">
|
||||
<Border BorderBrush="#4a4a4a" Background="#4a4a4a" BorderThickness="1"
|
||||
CornerRadius="10" Margin="2">
|
||||
<StackPanel Orientation="Horizontal" Margin="5">
|
||||
<TextBlock Text="{Binding ParamValue}" Margin="5,0"/>
|
||||
<Button Content="X" FontSize="10" VerticalAlignment="Center" HorizontalAlignment="Center" Width="15" Height="15" Padding="0"
|
||||
Command="{Binding $parent[ItemsControl].((vm:SettingsPageViewModel)DataContext).RemoveMkvMergeParam}" CommandParameter="{Binding .}"/>
|
||||
<TextBlock Text="{Binding ParamValue}" Margin="5,0" />
|
||||
<Button Content="X" FontSize="10" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center" Width="15" Height="15" Padding="0"
|
||||
Command="{Binding $parent[ItemsControl].((vm:SettingsPageViewModel)DataContext).RemoveMkvMergeParam}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
@ -287,7 +304,6 @@
|
|||
</StackPanel>
|
||||
|
||||
|
||||
|
||||
</controls:SettingsExpanderItem.Footer>
|
||||
</controls:SettingsExpanderItem>
|
||||
|
||||
|
@ -296,7 +312,8 @@
|
|||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBox HorizontalAlignment="Left" MinWidth="250"
|
||||
Text="{Binding FfmpegOption }"></TextBox>
|
||||
Text="{Binding FfmpegOption }">
|
||||
</TextBox>
|
||||
<Button HorizontalAlignment="Center" Margin="5 0" Command="{Binding AddFfmpegParam}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<controls:SymbolIcon Symbol="Add" FontSize="18" />
|
||||
|
@ -311,11 +328,14 @@
|
|||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderBrush="#4a4a4a" Background="#4a4a4a" BorderThickness="1" CornerRadius="10" Margin="2">
|
||||
<Border BorderBrush="#4a4a4a" Background="#4a4a4a" BorderThickness="1"
|
||||
CornerRadius="10" Margin="2">
|
||||
<StackPanel Orientation="Horizontal" Margin="5">
|
||||
<TextBlock Text="{Binding ParamValue}" Margin="5,0"/>
|
||||
<Button Content="X" FontSize="10" VerticalAlignment="Center" HorizontalAlignment="Center" Width="15" Height="15" Padding="0"
|
||||
Command="{Binding $parent[ItemsControl].((vm:SettingsPageViewModel)DataContext).RemoveFfmpegParam}" CommandParameter="{Binding .}"/>
|
||||
<TextBlock Text="{Binding ParamValue}" Margin="5,0" />
|
||||
<Button Content="X" FontSize="10" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center" Width="15" Height="15" Padding="0"
|
||||
Command="{Binding $parent[ItemsControl].((vm:SettingsPageViewModel)DataContext).RemoveFfmpegParam}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
@ -363,7 +383,8 @@
|
|||
</controls:SettingsExpanderItem.Footer>
|
||||
</controls:SettingsExpanderItem>
|
||||
|
||||
<controls:SettingsExpanderItem Content="Use Sonarr Numbering" Description="Potentially wrong if it couldn't be matched">
|
||||
<controls:SettingsExpanderItem Content="Use Sonarr Numbering"
|
||||
Description="Potentially wrong if it couldn't be matched">
|
||||
<controls:SettingsExpanderItem.Footer>
|
||||
<CheckBox IsChecked="{Binding SonarrUseSonarrNumbering}"> </CheckBox>
|
||||
</controls:SettingsExpanderItem.Footer>
|
||||
|
|
Loading…
Reference in New Issue