Skip to content

Commit

Permalink
ci/cd: fix whitespaces (#11749)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngosang committed May 16, 2021
1 parent 519d1ea commit aca4a16
Show file tree
Hide file tree
Showing 79 changed files with 335 additions and 296 deletions.
20 changes: 3 additions & 17 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,23 +300,9 @@ stages:
workingDirectory: $(Build.SourcesDirectory)
targetType: inline
failOnStderr: true
script: |
dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src/DateTimeRoutines
dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src/Jackett.Common
dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src/Jackett.IntegrationTests
dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src/Jackett.Server
dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src/Jackett.Service
dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src/Jackett.Test
dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src/Jackett.Tray
dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src/Jackett.Updater
dotnet-format --check --verbosity diagnostic --folder ./src/DateTimeRoutines
dotnet-format --check --verbosity diagnostic --folder ./src/Jackett.Common
dotnet-format --check --verbosity diagnostic --folder ./src/Jackett.IntegrationTests
dotnet-format --check --verbosity diagnostic --folder ./src/Jackett.Server
dotnet-format --check --verbosity diagnostic --folder ./src/Jackett.Service
dotnet-format --check --verbosity diagnostic --folder ./src/Jackett.Test
dotnet-format --check --verbosity diagnostic --folder ./src/Jackett.Tray
dotnet-format --check --verbosity diagnostic --folder ./src/Jackett.Updater
# execute this command to format all files:
# dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src
script: dotnet-format --check --verbosity diagnostic --folder ./src

- job: Linting_YAML
displayName: Linting YAML
Expand Down
2 changes: 1 addition & 1 deletion src/Jackett.Common/Converters/StringToLongConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist

return long.TryParse((string)reader.Value, out var foo)
? foo
: (long?) null;
: (long?)null;
}

public override bool CanConvert(Type objectType) => objectType == typeof(string);
Expand Down
3 changes: 2 additions & 1 deletion src/Jackett.Common/Indexers/Abnormal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ private ConfigurationDataAbnormal ConfigData
name: "Abnormal",
description: "General French Private Tracker",
link: "https://abnormal.ws/",
caps: new TorznabCapabilities {
caps: new TorznabCapabilities
{
TvSearchParams = new List<TvSearchParam>
{
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
Expand Down
2 changes: 1 addition & 1 deletion src/Jackett.Common/Indexers/Abstract/AvistazTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected virtual List<int> ParseCategories(TorznabQuery query, JToken row)
{
var cats = new List<int>();
var resolution = row.Value<string>("video_quality");
switch(row.Value<string>("type"))
switch (row.Value<string>("type"))
{
case "Movie":
cats.Add(resolution switch
Expand Down
2 changes: 1 addition & 1 deletion src/Jackett.Common/Indexers/Abstract/SpeedAppTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
Link = link,
Details = details,
Guid = details,
Category = MapTrackerCatToNewznab(cat),
Category = MapTrackerCatToNewznab(cat),
PublishDate = publishDate,
Description = description,
Poster = poster,
Expand Down
16 changes: 10 additions & 6 deletions src/Jackett.Common/Indexers/AniLibria.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig.Bespoke;
using Jackett.Common.Services.Interfaces;
Expand Down Expand Up @@ -80,7 +80,8 @@ private async Task<IEnumerable<ReleaseInfo>> PerformSearch(TorznabQuery query)
throw new WebException($"AniLibria search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);

var results = ParseApiResults(response.ContentString);
return results.Where(release => query.MatchQueryStringAND(release.Title, null, title));;
return results.Where(release => query.MatchQueryStringAND(release.Title, null, title));
;
}

private async Task<IEnumerable<ReleaseInfo>> FetchNewReleases()
Expand All @@ -97,7 +98,8 @@ private async Task<IEnumerable<ReleaseInfo>> FetchNewReleases()
return ParseApiResults(response.ContentString);
}

private string composeTitle(dynamic json) {
private string composeTitle(dynamic json)
{
var title = json.names.ru;
title += " / " + json.names.en;
if (json.alternative is string)
Expand All @@ -109,20 +111,22 @@ private async Task<IEnumerable<ReleaseInfo>> FetchNewReleases()
private List<ReleaseInfo> ParseApiResults(string json)
{
var releases = new List<ReleaseInfo>();
foreach (dynamic r in JArray.Parse(json)) {
foreach (dynamic r in JArray.Parse(json))
{
var baseRelease = new ReleaseInfo
{
Title = composeTitle(r),
Poster = new Uri(Configuration.StaticLink.Value + r.poster.url),
Details = new Uri(SiteLink + "/release/" + r.code + ".html"),
DownloadVolumeFactor = 0,
UploadVolumeFactor = 1,
Category = new []
Category = new[]
{
TorznabCatType.TVAnime.ID
}
};
foreach (var t in r.torrents.list) {
foreach (var t in r.torrents.list)
{
var release = (ReleaseInfo)baseRelease.Clone();
release.Title += " [" + t.quality["string"] + "] - " + t.series["string"];
release.Size = t.total_size;
Expand Down
9 changes: 6 additions & 3 deletions src/Jackett.Common/Indexers/AnimeBytes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class AnimeBytes : BaseCachingWebIndexer
link: "https://animebytes.tv/",
configService: configService,
client: client,
caps: new TorznabCapabilities {
caps: new TorznabCapabilities
{
TvSearchParams = new List<TvSearchParam>
{
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
Expand Down Expand Up @@ -214,15 +215,17 @@ private async Task<IEnumerable<ReleaseInfo>> GetResults(TorznabQuery query, stri
synonyms.Add(allSyonyms[1]);
if (AddAlternativeTitles && allSyonyms.Count >= 3)
synonyms.AddRange(allSyonyms[2].Split(',').Select(t => t.Trim()));
} else
}
else
{
var allSynonyms = group["Synonymns"].ToObject<Dictionary<int, string>>();

if (AddJapaneseTitle && allSynonyms.ContainsKey(0))
synonyms.Add(allSynonyms[0]);
if (AddRomajiTitle && allSynonyms.ContainsKey(1))
synonyms.Add(allSynonyms[1]);
if (AddAlternativeTitles && allSynonyms.ContainsKey(2)) {
if (AddAlternativeTitles && allSynonyms.ContainsKey(2))
{
synonyms.AddRange(allSynonyms[2].Split(',').Select(t => t.Trim()));
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Jackett.Common/Indexers/AnimeTorrents.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -38,7 +38,8 @@ private new ConfigurationDataBasicLogin configData
name: "AnimeTorrents",
description: "Definitive source for anime and manga",
link: "https://animetorrents.me/",
caps: new TorznabCapabilities {
caps: new TorznabCapabilities
{
TvSearchParams = new List<TvSearchParam>
{
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
Expand Down
28 changes: 18 additions & 10 deletions src/Jackett.Common/Indexers/Animedia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using AngleSharp.Dom;
using AngleSharp.Html.Dom;
using AngleSharp.Html.Parser;
Expand All @@ -15,7 +16,6 @@
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
using System.Linq;

namespace Jackett.Common.Indexers
{
Expand Down Expand Up @@ -72,11 +72,15 @@ public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken
}

// If the search string is empty use the latest releases
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) {
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
WebResult result;
if (query.IsTest || string.IsNullOrWhiteSpace(query.SearchTerm)) {
if (query.IsTest || string.IsNullOrWhiteSpace(query.SearchTerm))
{
result = await RequestWithCookiesAndRetryAsync(SiteLink);
} else {
}
else
{
// Prepare the search query
var queryParameters = new NameValueCollection
{
Expand Down Expand Up @@ -134,7 +138,7 @@ private async Task<List<ReleaseInfo>> FetchShowReleases(string url)
Details = uri,
DownloadVolumeFactor = 0,
UploadVolumeFactor = 1,
Category = new[]{ TorznabCatType.TVAnime.ID }
Category = new[] { TorznabCatType.TVAnime.ID }
};
foreach (var t in document.QuerySelectorAll("ul.media__tabs__nav > li > a"))
{
Expand All @@ -161,22 +165,26 @@ private async Task<List<ReleaseInfo>> FetchShowReleases(string url)
return releases;
}

private string composeBaseTitle(IHtmlDocument r) {
private string composeBaseTitle(IHtmlDocument r)
{
var name_ru = r.QuerySelector("div.media__post__header > h1").Text().Trim();
var name_en = r.QuerySelector("div.media__panel > div:nth-of-type(1) > div.col-l:nth-of-type(1) > div > span").Text().Trim();
var name_orig = r.QuerySelector("div.media__panel > div:nth-of-type(1) > div.col-l:nth-of-type(2) > div > span").Text().Trim();

var title = name_ru + " / " + name_en;
if (name_en != name_orig) {
if (name_en != name_orig)
{
title += " / " + name_orig;
}
return title;
}

private string composeTitleAdditionalInfo(IElement t, IElement tr) {
private string composeTitleAdditionalInfo(IElement t, IElement tr)
{
var tabName = t.Text();
tabName = tabName.Replace("Сезон", "Season");
if (tabName.Contains("Серии")) {
if (tabName.Contains("Серии"))
{
tabName = "";
}

Expand Down
3 changes: 2 additions & 1 deletion src/Jackett.Common/Indexers/Anthelion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class Anthelion : BaseWebIndexer
name: "Anthelion", // old name: TehConnection.me
description: "A movies tracker",
link: "https://anthelion.me/",
caps: new TorznabCapabilities {
caps: new TorznabCapabilities
{
TvSearchParams = new List<TvSearchParam>
{
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
Expand Down
10 changes: 6 additions & 4 deletions src/Jackett.Common/Indexers/BJShare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class BJShare : BaseWebIndexer

public BJShare(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps,
ICacheService cs)
: base(id: "bjshare",
: base(id: "bjshare",
name: "BJ-Share",
description: "A brazilian tracker.",
link: "https://bj-share.info/",
Expand Down Expand Up @@ -160,7 +160,7 @@ private string ParseTitle(string title, string seasonEp, string year, string cat
var cleanTitle = _EpisodeRegex.Replace(title, string.Empty);
// Removes the year if it comes on the title
// The space is added because on daily releases the date will be XX/XX/YYYY
if(!string.IsNullOrEmpty(year))
if (!string.IsNullOrEmpty(year))
cleanTitle = cleanTitle.Replace(" " + year, string.Empty);
cleanTitle = Regex.Replace(cleanTitle, @"^\s*|[\s-]*$", string.Empty);

Expand Down Expand Up @@ -296,10 +296,12 @@ private async Task<List<ReleaseInfo>> ParseUserSearchAsync(TorznabQuery query)
// so let's try to pick up first without the .tooltip class,
// if nothing is found, then we try again without that filter
var qDetailsLink = row.QuerySelector("a[href^=\"torrents.php?id=\"]:not(.tooltip)");
if (qDetailsLink == null) {
if (qDetailsLink == null)
{
qDetailsLink = row.QuerySelector("a[href^=\"torrents.php?id=\"]");
// if still can't find the right link, skip it
if (qDetailsLink == null) {
if (qDetailsLink == null)
{
logger.Error($"{Id}: Error while parsing row '{row.OuterHtml}': Can't find the right details link");
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Jackett.Common/Indexers/BaseIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Polly;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using Polly;
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;

namespace Jackett.Common.Indexers
Expand Down Expand Up @@ -510,7 +510,7 @@ public virtual async Task<byte[]> Download(Uri link)
return await Download(uncleanLink, RequestType.GET);
}

protected async Task<byte[]> Download(Uri link, RequestType method, string referer = null, Dictionary<string, string>headers = null)
protected async Task<byte[]> Download(Uri link, RequestType method, string referer = null, Dictionary<string, string> headers = null)
{
// return magnet link
if (link.Scheme == "magnet")
Expand Down Expand Up @@ -769,7 +769,7 @@ protected void OnParseError(string results, Exception ex)

public abstract class BaseCachingWebIndexer : BaseWebIndexer
{
protected BaseCachingWebIndexer(string link,string id, string name, string description,
protected BaseCachingWebIndexer(string link, string id, string name, string description,
IIndexerConfigurationService configService, WebClient client, Logger logger,
ConfigurationData configData, IProtectionService p, ICacheService cacheService,
TorznabCapabilities caps = null, string downloadBase = null)
Expand Down
3 changes: 2 additions & 1 deletion src/Jackett.Common/Indexers/BroadcasTheNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
{
searchParam["name"] = $"Season {query.Season}";
searchParam["category"] = "Season";
} else if (query.Season > 0 && int.Parse(query.Episode) > 0)
}
else if (query.Season > 0 && int.Parse(query.Episode) > 0)
{
searchParam["name"] = string.Format("S{0:00}E{1:00}", query.Season, int.Parse(query.Episode));
searchParam["category"] = "Episode";
Expand Down

0 comments on commit aca4a16

Please sign in to comment.