Add - Added missing languages

Add -  Added log mode to settings
This commit is contained in:
Elwador 2024-06-15 15:55:39 +02:00
parent d405c9e7d9
commit 8fc0812448
17 changed files with 138 additions and 37 deletions

View File

@ -153,6 +153,10 @@ public class CrAuth{
} }
} }
if (crunInstance.Profile.Username == "???"){
return;
}
var formData = new Dictionary<string, string>{ var formData = new Dictionary<string, string>{
{ "refresh_token", crunInstance.Token?.refresh_token ?? string.Empty }, { "refresh_token", crunInstance.Token?.refresh_token ?? string.Empty },
{ "grant_type", "refresh_token" }, { "grant_type", "refresh_token" },

View File

@ -164,6 +164,12 @@ public class Crunchyroll{
RefreshSonarr(); RefreshSonarr();
} }
if (CrunOptions.LogMode){
CfgManager.EnableLogMode();
} else{
CfgManager.DisableLogMode();
}
calendarLanguage = new(){ calendarLanguage = new(){
{ "en-us", "https://www.crunchyroll.com/simulcastcalendar" }, { "en-us", "https://www.crunchyroll.com/simulcastcalendar" },
{ "es", "https://www.crunchyroll.com/es/simulcastcalendar" }, { "es", "https://www.crunchyroll.com/es/simulcastcalendar" },
@ -559,7 +565,7 @@ public class Crunchyroll{
List<DownloadedMedia> files = new List<DownloadedMedia>(); List<DownloadedMedia> files = new List<DownloadedMedia>();
if (data.Data != null && data.Data.All(a => a.Playback == null)){ if (data.Data != null && data.Data.All(a => a.Playback == null)){
Console.WriteLine("Video not available!"); Console.WriteLine("No Video Data found - Are you trying to download a premium episode without havíng a premium account?");
MainWindow.Instance.ShowError("No Video Data found - Are you trying to download a premium episode without havíng a premium account?"); MainWindow.Instance.ShowError("No Video Data found - Are you trying to download a premium episode without havíng a premium account?");
return new DownloadResponse{ return new DownloadResponse{
Data = files, Data = files,
@ -765,7 +771,7 @@ public class Crunchyroll{
: 1; : 1;
for (int i = 0; i < streams.Count; i++){ for (int i = 0; i < streams.Count; i++){
string isSelected = options.Kstream == i + 1 ? "" : " "; string isSelected = options.Kstream == i + 1 ? "+" : " ";
Console.WriteLine($"Full stream found! ({isSelected}{i + 1}: {streams[i].Type})"); Console.WriteLine($"Full stream found! ({isSelected}{i + 1}: {streams[i].Type})");
} }
@ -922,7 +928,10 @@ public class Crunchyroll{
}; };
} }
Console.WriteLine($"Selected quality: \n\tVideo: {chosenVideoSegments.resolutionText}\n\tAudio: {chosenAudioSegments.resolutionText}\n\tServer: {selectedServer}"); Console.WriteLine($"Selected quality:");
Console.WriteLine($"\tVideo: {chosenVideoSegments.resolutionText}");
Console.WriteLine($"\tAudio: {chosenAudioSegments.resolutionText}");
Console.WriteLine($"\tServer: {selectedServer}");
Console.WriteLine("Stream URL:" + chosenVideoSegments.segments[0].uri.Split(new[]{ ",.urlset" }, StringSplitOptions.None)[0]); Console.WriteLine("Stream URL:" + chosenVideoSegments.segments[0].uri.Split(new[]{ ",.urlset" }, StringSplitOptions.None)[0]);
fileName = Path.Combine(FileNameManager.ParseFileName(options.FileName, variables, options.Numbers, options.Override).ToArray()); fileName = Path.Combine(FileNameManager.ParseFileName(options.FileName, variables, options.Numbers, options.Override).ToArray());

View File

@ -420,7 +420,7 @@ public class History(){
historyEpisode.SonarrSeasonNumber = episode2.SeasonNumber + ""; historyEpisode.SonarrSeasonNumber = episode2.SeasonNumber + "";
episodes.Remove(episode2); episodes.Remove(episode2);
} else{ } else{
Console.WriteLine("Could not match episode to sonarr episode"); Console.WriteLine($"Could not match episode {historyEpisode.EpisodeTitle} to sonarr episode");
} }
} }
} }

View File

@ -67,7 +67,7 @@ public class Widevine{
canDecrypt = false; canDecrypt = false;
} }
} catch (Exception e){ } catch (Exception e){
Console.WriteLine(e); Console.WriteLine("Widevine: " + e);
canDecrypt = false; canDecrypt = false;
} }
} }

View File

@ -64,6 +64,39 @@ public enum Locale{
[EnumMember(Value = "id-ID")] [EnumMember(Value = "id-ID")]
IdId, IdId,
[EnumMember(Value = "en-IN")]
EnIn,
[EnumMember(Value = "pt-PT")]
PtPt,
[EnumMember(Value = "zh-TW")]
ZhTw,
[EnumMember(Value = "ca-ES")]
CaEs,
[EnumMember(Value = "pl-PL")]
PlPl,
[EnumMember(Value = "th-TH")]
ThTh,
[EnumMember(Value = "ta-IN")]
TaIn,
[EnumMember(Value = "ms-MY")]
MsMy,
[EnumMember(Value = "vi-VN")]
ViVn,
[EnumMember(Value = "te-IN")]
TeIn,
[EnumMember(Value = "id-ID")]
idID,
} }
public static class EnumExtensions{ public static class EnumExtensions{

View File

@ -24,6 +24,31 @@ public class CfgManager{
public static readonly string PathVIDEOS_DIR = WorkingDirectory + "/video/"; public static readonly string PathVIDEOS_DIR = WorkingDirectory + "/video/";
public static readonly string PathFONTS_DIR = WorkingDirectory + "/video/"; public static readonly string PathFONTS_DIR = WorkingDirectory + "/video/";
public static readonly string PathLogFile = WorkingDirectory + "/logfile.txt";
private static StreamWriter logFile;
private static bool isLogModeEnabled = false;
public static void EnableLogMode(){
if (!isLogModeEnabled){
logFile = new StreamWriter(PathLogFile);
logFile.AutoFlush = true;
Console.SetOut(logFile);
isLogModeEnabled = true;
Console.WriteLine("Log mode enabled.");
}
}
public static void DisableLogMode(){
if (isLogModeEnabled){
logFile.Close();
StreamWriter standardOutput = new StreamWriter(Console.OpenStandardOutput());
standardOutput.AutoFlush = true;
Console.SetOut(standardOutput);
isLogModeEnabled = false;
Console.WriteLine("Log mode disabled.");
}
}
public static void WriteJsonResponseToYamlFile(string jsonResponse, string filePath){ public static void WriteJsonResponseToYamlFile(string jsonResponse, string filePath){
// Convert JSON to an object // Convert JSON to an object
@ -143,6 +168,7 @@ public class CfgManager{
Crunchyroll.Instance.CrunOptions.History = loadedOptions.History; Crunchyroll.Instance.CrunOptions.History = loadedOptions.History;
Crunchyroll.Instance.CrunOptions.UseNonDrmStreams = loadedOptions.UseNonDrmStreams; Crunchyroll.Instance.CrunOptions.UseNonDrmStreams = loadedOptions.UseNonDrmStreams;
Crunchyroll.Instance.CrunOptions.SonarrProperties = loadedOptions.SonarrProperties; Crunchyroll.Instance.CrunOptions.SonarrProperties = loadedOptions.SonarrProperties;
Crunchyroll.Instance.CrunOptions.LogMode = loadedOptions.LogMode;
} }
private static object fileLock = new object(); private static object fileLock = new object();

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -67,18 +67,14 @@ public class Helpers{
process.StartInfo.UseShellExecute = false; process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true; process.StartInfo.CreateNoWindow = true;
process.OutputDataReceived += (sender, e) => process.OutputDataReceived += (sender, e) => {
{ if (!string.IsNullOrEmpty(e.Data)){
if (!string.IsNullOrEmpty(e.Data))
{
Console.WriteLine(e.Data); Console.WriteLine(e.Data);
} }
}; };
process.ErrorDataReceived += (sender, e) => process.ErrorDataReceived += (sender, e) => {
{ if (!string.IsNullOrEmpty(e.Data)){
if (!string.IsNullOrEmpty(e.Data))
{
Console.WriteLine($"ERROR: {e.Data}"); Console.WriteLine($"ERROR: {e.Data}");
} }
}; };

View File

@ -97,7 +97,7 @@ public class HttpClientReq{
return (IsOk: true, ResponseContent: content); return (IsOk: true, ResponseContent: content);
} catch (Exception e){ } catch (Exception e){
Console.WriteLine(e); Console.WriteLine($"Error: {e} \n Response: {content}");
return (IsOk: false, ResponseContent: content); return (IsOk: false, ResponseContent: content);
} }
} }

View File

@ -24,8 +24,6 @@ public class DashParser{
return ToM3u8Class.ToM3u8(parsedElement); return ToM3u8Class.ToM3u8(parsedElement);
// string jsonString = JsonConvert.SerializeObject(M3u8); // string jsonString = JsonConvert.SerializeObject(M3u8);
Console.WriteLine("Hallo");
} }
private static XmlElement StringToMpdXml(string manifestString){ private static XmlElement StringToMpdXml(string manifestString){

View File

@ -92,7 +92,7 @@ public class SonarrClient{
series = JsonConvert.DeserializeObject<List<SonarrSeries>>(json) ?? []; series = JsonConvert.DeserializeObject<List<SonarrSeries>>(json) ?? [];
} catch (Exception e){ } catch (Exception e){
MainWindow.Instance.ShowError("Sonarr GetSeries error \n" + e); MainWindow.Instance.ShowError("Sonarr GetSeries error \n" + e);
Console.WriteLine(e); Console.WriteLine("Sonarr GetSeries error \n" + e);
} }
return series; return series;
@ -106,8 +106,8 @@ public class SonarrClient{
try{ try{
episodes = JsonConvert.DeserializeObject<List<SonarrEpisode>>(json) ?? []; episodes = JsonConvert.DeserializeObject<List<SonarrEpisode>>(json) ?? [];
} catch (Exception e){ } catch (Exception e){
MainWindow.Instance.ShowError("Sonarr GetSeries error \n" + e); MainWindow.Instance.ShowError("Sonarr GetEpisodes error \n" + e);
Console.WriteLine(e); Console.WriteLine("Sonarr GetEpisodes error \n" + e);
} }
return episodes; return episodes;
@ -120,8 +120,8 @@ public class SonarrClient{
try{ try{
episode = JsonConvert.DeserializeObject<SonarrEpisode>(json) ?? new SonarrEpisode(); episode = JsonConvert.DeserializeObject<SonarrEpisode>(json) ?? new SonarrEpisode();
} catch (Exception e){ } catch (Exception e){
MainWindow.Instance.ShowError("Sonarr GetSeries error \n" + e); MainWindow.Instance.ShowError("Sonarr GetEpisode error \n" + e);
Console.WriteLine(e); Console.WriteLine("Sonarr GetEpisode error \n" + e);
} }
return episode; return episode;

View File

@ -119,4 +119,7 @@ public class CrDownloadOptions{
[YamlMember(Alias = "sonarr_properties", ApplyNamingConventions = false)] [YamlMember(Alias = "sonarr_properties", ApplyNamingConventions = false)]
public SonarrProperties? SonarrProperties{ get; set; } public SonarrProperties? SonarrProperties{ get; set; }
[YamlMember(Alias = "log_mode", ApplyNamingConventions = false)]
public bool LogMode{ get; set; }
} }

View File

@ -8,7 +8,9 @@ namespace CRD.Utils.Structs;
public class Languages{ public class Languages{
public static readonly LanguageItem[] languages ={ public static readonly LanguageItem[] languages ={
new(){ CrLocale = "ja-JP", Locale = "ja", Code = "jpn", Name = "Japanese" },
new(){ CrLocale = "en-US", Locale = "en", Code = "eng", Name = "English" }, new(){ CrLocale = "en-US", Locale = "en", Code = "eng", Name = "English" },
new(){ CrLocale = "de-DE", Locale = "de", Code = "deu", Name = "German" },
new(){ CrLocale = "en-IN", Locale = "en-IN", Code = "eng", Name = "English (India)" }, new(){ CrLocale = "en-IN", Locale = "en-IN", Code = "eng", Name = "English (India)" },
new(){ CrLocale = "es-LA", Locale = "es-419", Code = "spa", Name = "Spanish", Language = "Latin American Spanish" }, new(){ CrLocale = "es-LA", Locale = "es-419", Code = "spa", Name = "Spanish", Language = "Latin American Spanish" },
new(){ CrLocale = "es-419", Locale = "es-419", Code = "spa-419", Name = "Spanish", Language = "Latin American Spanish" }, new(){ CrLocale = "es-419", Locale = "es-419", Code = "spa-419", Name = "Spanish", Language = "Latin American Spanish" },
@ -16,7 +18,6 @@ public class Languages{
new(){ CrLocale = "pt-BR", Locale = "pt-BR", Code = "por", Name = "Portuguese", Language = "Brazilian Portuguese" }, new(){ CrLocale = "pt-BR", Locale = "pt-BR", Code = "por", Name = "Portuguese", Language = "Brazilian Portuguese" },
new(){ CrLocale = "pt-PT", Locale = "pt-PT", Code = "por", Name = "Portuguese (Portugal)", Language = "Portugues (Portugal)" }, new(){ CrLocale = "pt-PT", Locale = "pt-PT", Code = "por", Name = "Portuguese (Portugal)", Language = "Portugues (Portugal)" },
new(){ CrLocale = "fr-FR", Locale = "fr", Code = "fra", Name = "French" }, new(){ CrLocale = "fr-FR", Locale = "fr", Code = "fra", Name = "French" },
new(){ CrLocale = "de-DE", Locale = "de", Code = "deu", Name = "German" },
new(){ CrLocale = "ar-ME", Locale = "ar", Code = "ara-ME", Name = "Arabic" }, new(){ CrLocale = "ar-ME", Locale = "ar", Code = "ara-ME", Name = "Arabic" },
new(){ CrLocale = "ar-SA", Locale = "ar", Code = "ara", Name = "Arabic (Saudi Arabia)" }, new(){ CrLocale = "ar-SA", Locale = "ar", Code = "ara", Name = "Arabic (Saudi Arabia)" },
new(){ CrLocale = "it-IT", Locale = "it", Code = "ita", Name = "Italian" }, new(){ CrLocale = "it-IT", Locale = "it", Code = "ita", Name = "Italian" },
@ -35,14 +36,14 @@ public class Languages{
new(){ CrLocale = "vi-VN", Locale = "vi-VN", Code = "vie", Name = "Vietnamese", Language = "Tiếng Việt" }, new(){ CrLocale = "vi-VN", Locale = "vi-VN", Code = "vie", Name = "Vietnamese", Language = "Tiếng Việt" },
new(){ CrLocale = "id-ID", Locale = "id-ID", Code = "ind", Name = "Indonesian", Language = "Bahasa Indonesia" }, new(){ CrLocale = "id-ID", Locale = "id-ID", Code = "ind", Name = "Indonesian", Language = "Bahasa Indonesia" },
new(){ CrLocale = "te-IN", Locale = "te-IN", Code = "tel", Name = "Telugu (India)", Language = "తెలుగు" }, new(){ CrLocale = "te-IN", Locale = "te-IN", Code = "tel", Name = "Telugu (India)", Language = "తెలుగు" },
new(){ CrLocale = "ja-JP", Locale = "ja", Code = "jpn", Name = "Japanese" }, new(){ CrLocale = "id-ID", Locale = "id", Code = "in", Name = "Indonesian " }
new(){ CrLocale = "id-ID", Locale = "id", Code = "in", Name = "Indonesian " },
}; };
public static LanguageItem FixAndFindCrLc(string cr_locale){ public static LanguageItem FixAndFindCrLc(string cr_locale){
if (string.IsNullOrEmpty(cr_locale)){ if (string.IsNullOrEmpty(cr_locale)){
return new LanguageItem(); return new LanguageItem();
} }
string str = FixLanguageTag(cr_locale); string str = FixLanguageTag(cr_locale);
return FindLang(str); return FindLang(str);
} }
@ -70,7 +71,6 @@ public class Languages{
var match = Regex.Match(tag, @"^(\w{2})-?(\w{2})$"); var match = Regex.Match(tag, @"^(\w{2})-?(\w{2})$");
if (match.Success){ if (match.Success){
string tagLang = $"{match.Groups[1].Value}-{match.Groups[2].Value.ToUpper()}"; string tagLang = $"{match.Groups[1].Value}-{match.Groups[2].Value.ToUpper()}";
var langObj = FindLang(tagLang); var langObj = FindLang(tagLang);

View File

@ -156,7 +156,7 @@ public partial class AddDownloadPageViewModel : ViewModelBase{
} }
} }
} else{ } else{
Console.WriteLine("Probably not a url"); Console.WriteLine("Unnkown input");
} }
} }

View File

@ -42,7 +42,7 @@ public partial class DownloadsPageViewModel : ViewModelBase{
if (downloadItem != null){ if (downloadItem != null){
Crunchyroll.Instance.DownloadItemModels.Remove(downloadItem); Crunchyroll.Instance.DownloadItemModels.Remove(downloadItem);
} else{ } else{
Console.WriteLine("Failed to Remove From Preview"); Console.WriteLine("Failed to Remove Episode from list");
} }
} }
} }
@ -145,6 +145,15 @@ public partial class DownloadItemModel : INotifyPropertyChanged{
var softSubs = "Softsub: "; var softSubs = "Softsub: ";
if (Crunchyroll.Instance.CrunOptions.DlSubs.Contains("all")){
if (epMeta.AvailableSubs != null){
foreach (var epMetaAvailableSub in epMeta.AvailableSubs){
softSubs += epMetaAvailableSub + " ";
}
return softSubs;
}
}
foreach (var crunOptionsDlSub in Crunchyroll.Instance.CrunOptions.DlSubs){ foreach (var crunOptionsDlSub in Crunchyroll.Instance.CrunOptions.DlSubs){
if (epMeta.AvailableSubs != null && epMeta.AvailableSubs.Contains(crunOptionsDlSub)){ if (epMeta.AvailableSubs != null && epMeta.AvailableSubs.Contains(crunOptionsDlSub)){

View File

@ -87,7 +87,7 @@ public partial class SeriesPageViewModel : ViewModelBase{
UseShellExecute = true UseShellExecute = true
}); });
} catch (Exception e){ } catch (Exception e){
Console.WriteLine($"An error occurred: {e.Message}"); Console.WriteLine($"An error occurred while trying to open URL - {url} : {e.Message}");
} }
} }
} }

View File

@ -104,6 +104,9 @@ public partial class SettingsPageViewModel : ViewModelBase{
[ObservableProperty] [ObservableProperty]
private bool _sonarrUseSonarrNumbering = false; private bool _sonarrUseSonarrNumbering = false;
[ObservableProperty]
private bool _logMode = false;
public ObservableCollection<Color> PredefinedColors{ get; } = new(){ public ObservableCollection<Color> PredefinedColors{ get; } = new(){
Color.FromRgb(255, 185, 0), Color.FromRgb(255, 185, 0),
Color.FromRgb(255, 140, 0), Color.FromRgb(255, 140, 0),
@ -248,6 +251,7 @@ public partial class SettingsPageViewModel : ViewModelBase{
LeadingNumbers = options.Numbers; LeadingNumbers = options.Numbers;
FileName = options.FileName; FileName = options.FileName;
SimultaneousDownloads = options.SimultaneousDownloads; SimultaneousDownloads = options.SimultaneousDownloads;
LogMode = options.LogMode;
ComboBoxItem? qualityAudio = AudioQualityList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.QualityAudio) ?? null; ComboBoxItem? qualityAudio = AudioQualityList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.QualityAudio) ?? null;
SelectedAudioQuality = qualityAudio ?? AudioQualityList[0]; SelectedAudioQuality = qualityAudio ?? AudioQualityList[0];
@ -335,6 +339,7 @@ public partial class SettingsPageViewModel : ViewModelBase{
Crunchyroll.Instance.CrunOptions.SonarrProperties = props; Crunchyroll.Instance.CrunOptions.SonarrProperties = props;
Crunchyroll.Instance.CrunOptions.LogMode = LogMode;
//TODO - Mux Options //TODO - Mux Options
@ -486,4 +491,13 @@ public partial class SettingsPageViewModel : ViewModelBase{
partial void OnSonarrUseSonarrNumberingChanged(bool value){ partial void OnSonarrUseSonarrNumberingChanged(bool value){
UpdateSettings(); UpdateSettings();
} }
partial void OnLogModeChanged(bool value){
UpdateSettings();
if (value){
CfgManager.EnableLogMode();
} else{
CfgManager.DisableLogMode();
}
}
} }

View File

@ -446,6 +446,15 @@
</controls:SettingsExpander> </controls:SettingsExpander>
<controls:SettingsExpander Header="Log Mode"
IconSource="Help"
Description="Should only be enabled if something isn't working">
<controls:SettingsExpander.Footer>
<CheckBox IsChecked="{Binding LogMode}"> </CheckBox>
</controls:SettingsExpander.Footer>
</controls:SettingsExpander>
<Grid Margin="0 0 0 10" <Grid Margin="0 0 0 10"
ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> ColumnDefinitions="*,Auto" RowDefinitions="*,Auto">