Crunchy-Downloader/CRD/Utils/Structs/Crunchyroll/StreamLimits.cs
Elwador ff3e28093e - Added notification service for webhooks
- Added retry delay for rate limit handling
- Added toggle to control whether auto refresh also adds missing episodes to the queue
- Added configurable delay after each dub download
- Changed encoding preset dialog to show a preview of the FFmpeg command
- Changed play sound on queue empty and execute file on completion to be handled by the notification service
- Changed shutdown PC option to disable once triggered
- Fixed crash with queue persistence
- Fixed crash with audio player
- Fixed subscription countdown on the account page
2026-05-14 21:49:57 +02:00

110 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace CRD.Utils.Structs.Crunchyroll;
public class StreamError{
[JsonPropertyName("error")]
public string? Error{ get; set; }
[JsonPropertyName("activeStreams")]
public List<ActiveStream> ActiveStreams{ get; set; } = new ();
[JsonIgnore]
public string? RawJson{ get; set; }
public static StreamError? FromJson(string json){
try{
var error = Helpers.Deserialize<StreamError>(json,null);
if (error != null){
error.RawJson = json;
}
return error;
} catch (Exception e){
Console.Error.WriteLine(e);
return null;
}
}
public bool IsTooManyActiveStreamsError(){
return Error is "TOO_MANY_ACTIVE_STREAMS" or "TOO_MANY_CONCURRENT_STREAMS";
}
public bool IsRateLimitError(){
return IsPlaybackRateLimitError();
}
public bool IsPlaybackRateLimitError(){
return Error?.Contains("4294") == true || RawJson?.Contains("4294") == true;
}
}
public class ActiveStream{
[JsonPropertyName("deviceSubtype")]
public string DeviceSubtype{ get; set; }
[JsonPropertyName("accountId")]
public string AccountId{ get; set; }
[JsonPropertyName("deviceType")]
public string DeviceType{ get; set; }
[JsonPropertyName("subscription")]
public string Subscription{ get; set; }
[JsonPropertyName("maxKeepAliveSeconds")]
public int MaxKeepAliveSeconds{ get; set; }
[JsonPropertyName("ttl")]
public int Ttl{ get; set; }
[JsonPropertyName("episodeIdentity")]
public string EpisodeIdentity{ get; set; }
[JsonPropertyName("tabId")]
public string TabId{ get; set; }
[JsonPropertyName("country")]
public string Country{ get; set; }
[JsonPropertyName("clientId")]
public string ClientId{ get; set; }
[JsonPropertyName("active")]
public bool Active{ get; set; }
[JsonPropertyName("deviceId")]
public string DeviceId{ get; set; }
[JsonPropertyName("token")]
public string Token{ get; set; }
[JsonPropertyName("assetId")]
public string AssetId{ get; set; }
[JsonPropertyName("sessionType")]
public string SessionType{ get; set; }
[JsonPropertyName("contentId")]
public string ContentId{ get; set; }
[JsonPropertyName("usesStreamLimits")]
public bool UsesStreamLimits{ get; set; }
[JsonPropertyName("playbackType")]
public string PlaybackType{ get; set; }
[JsonPropertyName("pk")]
public string Pk{ get; set; }
[JsonPropertyName("id")]
public string Id{ get; set; }
[JsonPropertyName("createdTimestamp")]
public long CreatedTimestamp{ get; set; }
[JsonPropertyName("lastKeepAliveTimestamp")]
public long LastKeepAliveTimestamp{ get; set; }
}