From 5f01ed4f4a650c2cedae6db1987cadaac7773699 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Mon, 2 Sep 2024 11:00:53 +0300 Subject: [PATCH] myanonamouse: use personal freeleech for DVF --- .../Indexers/Definitions/MyAnonamouse.cs | 75 ++++++++++++++----- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/src/Jackett.Common/Indexers/Definitions/MyAnonamouse.cs b/src/Jackett.Common/Indexers/Definitions/MyAnonamouse.cs index aff39998f..ac75c4187 100644 --- a/src/Jackett.Common/Indexers/Definitions/MyAnonamouse.cs +++ b/src/Jackett.Common/Indexers/Definitions/MyAnonamouse.cs @@ -263,43 +263,46 @@ namespace Jackett.Common.Indexers.Definitions try { - var jsonContent = JObject.Parse(response.ContentString); var sitelink = new Uri(SiteLink); - var error = jsonContent.Value("error"); + var jsonResponse = JsonConvert.DeserializeObject(response.ContentString); + + var error = jsonResponse.Error; if (error.IsNotNullOrWhiteSpace() && error.StartsWithIgnoreCase("Nothing returned, out of")) { return releases; } - foreach (var item in jsonContent.Value("data")) + foreach (var item in jsonResponse.Data) { - var id = item.Value("id"); - var link = new Uri(sitelink, "/tor/download.php?tid=" + id); - var details = new Uri(sitelink, "/t/" + id); + var id = item.Id; + var link = new Uri(sitelink, $"/tor/download.php?tid={id}"); + var details = new Uri(sitelink, $"/t/{id}"); + + var isFreeLeech = item.Free || item.PersonalFreeLeech; var release = new ReleaseInfo { Guid = details, - Title = item.Value("title").Trim(), - Description = item.Value("description").Trim(), + Title = item.Title.Trim(), + Description = item.Description.Trim(), Link = link, Details = details, - Category = MapTrackerCatToNewznab(item.Value("category")), - PublishDate = DateTime.ParseExact(item.Value("added"), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime(), - Grabs = item.Value("times_completed"), - Files = item.Value("numfiles"), - Seeders = item.Value("seeders"), - Peers = item.Value("seeders") + item.Value("leechers"), - Size = ParseUtil.GetBytes(item.Value("size")), - DownloadVolumeFactor = item.Value("free") ? 0 : 1, + Category = MapTrackerCatToNewznab(item.Category), + PublishDate = DateTime.ParseExact(item.Added, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime(), + Grabs = item.Grabs, + Files = item.NumFiles, + Seeders = item.Seeders, + Peers = item.Seeders + item.Leechers, + Size = ParseUtil.GetBytes(item.Size), + DownloadVolumeFactor = isFreeLeech ? 0 : 1, UploadVolumeFactor = 1, // MinimumRatio = 1, // global MR is 1.0 but torrents must be seeded for 3 days regardless of ratio MinimumSeedTime = 259200 // 72 hours }; - var authorInfo = item.Value("author_info"); + var authorInfo = item.AuthorInfo; if (authorInfo != null) { try @@ -321,13 +324,13 @@ namespace Jackett.Common.Indexers.Definitions var flags = new List(); - var langCode = item.Value("lang_code"); + var langCode = item.LanguageCode; if (!string.IsNullOrEmpty(langCode)) { flags.Add(langCode); } - var filetype = item.Value("filetype"); + var filetype = item.Filetype; if (!string.IsNullOrEmpty(filetype)) { flags.Add(filetype.ToUpper()); @@ -338,7 +341,7 @@ namespace Jackett.Common.Indexers.Definitions release.Title += " [" + string.Join(" / ", flags) + "]"; } - if (item.Value("vip")) + if (item.Vip) { release.Title += " [VIP]"; } @@ -354,4 +357,36 @@ namespace Jackett.Common.Indexers.Definitions return releases; } } + + public class MyAnonamouseResponse + { + public string Error { get; set; } + public List Data { get; set; } + } + + public class MyAnonamouseTorrent + { + public int Id { get; set; } + public string Title { get; set; } + [JsonProperty(PropertyName = "author_info")] + public string AuthorInfo { get; set; } + public string Description { get; set; } + [JsonProperty(PropertyName = "lang_code")] + public string LanguageCode { get; set; } + public string Filetype { get; set; } + public bool Vip { get; set; } + public bool Free { get; set; } + [JsonProperty(PropertyName = "personal_freeleech")] + public bool PersonalFreeLeech { get; set; } + [JsonProperty(PropertyName = "fl_vip")] + public bool FreeVip { get; set; } + public string Category { get; set; } + public string Added { get; set; } + [JsonProperty(PropertyName = "times_completed")] + public int Grabs { get; set; } + public int Seeders { get; set; } + public int Leechers { get; set; } + public int NumFiles { get; set; } + public string Size { get; set; } + } }