Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SirSparkles committed Nov 10, 2021
1 parent f7bb34a commit 6b53a9c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions TVRename/Sources/TheTVDB/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public static List<JObject> GetImages(int code, string languageCode, [NotNull] I
public static JObject GetSeriesV4(int code, string requestedLanguageCode)
{
string uri = $"{TokenProvider.TVDB_API_URL}/series/{code}/extended";
return GetUrl(uri, requestedLanguageCode);
return GetUrl(code, uri, requestedLanguageCode);
}

public static JObject? GetEpisode(int episodeId, string requestLangCode)
Expand Down Expand Up @@ -431,39 +431,39 @@ public static void Login(bool forceReconect)
public static JObject GetMovieV4(int code, string requestedLanguageCode)
{
string uri = $"{TokenProvider.TVDB_API_URL}/movies/{code}/extended";
return GetUrl(uri, requestedLanguageCode);
return GetUrl(code, uri, requestedLanguageCode);
}

[NotNull]
public static JObject GetSeasonEpisodesV4(int seasonId, string requestedLanguageCode)
public static JObject GetSeasonEpisodesV4(int id, int seasonId, string requestedLanguageCode)
{
string uri = $"{TokenProvider.TVDB_API_URL}/seasons/{seasonId}/extended";
return GetUrl(uri, requestedLanguageCode);
return GetUrl(id, uri, requestedLanguageCode);
}

[NotNull]
public static JObject GetSeriesTranslationsV4(int code, string requestedLanguageCode)
{
string uri = $"{TokenProvider.TVDB_API_URL}/series/{code}/translations/{requestedLanguageCode}";
return GetUrl(uri, requestedLanguageCode);
return GetUrl(code, uri, requestedLanguageCode);
}

[NotNull]
public static JObject GetEpisodeTranslationsV4(int code, string requestedLanguageCode)
public static JObject GetEpisodeTranslationsV4(int id, int code, string requestedLanguageCode)
{
string uri = $"{TokenProvider.TVDB_API_URL}/episodes/{code}/translations/{requestedLanguageCode}";
return GetUrl(uri, requestedLanguageCode);
return GetUrl(id, uri, requestedLanguageCode);
}

[NotNull]
public static JObject GetMovieTranslationsV4(int code, string requestedLanguageCode)
{
string uri = $"{TokenProvider.TVDB_API_URL}/movies/{code}/translations/{requestedLanguageCode}";
return GetUrl(uri, requestedLanguageCode);
return GetUrl(code, uri, requestedLanguageCode);
}

[NotNull]
private static JObject GetUrl(string uri, string requestedLanguageCode)
private static JObject GetUrl(int code, string uri, string requestedLanguageCode)
{
try
{
Expand All @@ -472,20 +472,20 @@ private static JObject GetUrl(string uri, string requestedLanguageCode)
}
catch (WebException webEx)
{
Logger.LogWebException($"Looking for {uri} (in {requestedLanguageCode}), but got WebException:", webEx);
Logger.LogWebException($"Id={code} Looking for {uri} (in {requestedLanguageCode}), but got WebException:", webEx);
}
catch (IOException ioe)
{
Logger.Warn($"Looking for {uri} (in {requestedLanguageCode}), but got: {ioe.LoggableDetails()}");
Logger.Warn($"Id={code} Looking for {uri} (in {requestedLanguageCode}), but got: {ioe.LoggableDetails()}");
}

throw new SourceConnectivityException($"Looking for {uri} (in {requestedLanguageCode})");
throw new SourceConnectivityException($"Id={code} Looking for {uri} (in {requestedLanguageCode})");
}

[NotNull]
public static JObject ImageTypesV4()
{
return GetUrl("https://api4.thetvdb.com/v4/artwork/types", "en");
return GetUrl(0,"https://api4.thetvdb.com/v4/artwork/types", "en");
}

[NotNull]
Expand Down
4 changes: 2 additions & 2 deletions TVRename/Sources/TheTVDB/LocalCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ public void ReloadEpisodesV4(int code, Locale locale, CachedSeriesInfo si, Proce
Thread.CurrentThread.Name ??= $"Download Season {s.SeasonNumber} for {si.Name}"; // Can only set it once
try
{
JObject seasonInfo = API.GetSeasonEpisodesV4(s.SeasonId,
JObject seasonInfo = API.GetSeasonEpisodesV4(si.TvdbId ,s.SeasonId,
locale.LanguageToUse(TVDoc.ProviderType.TheTVDB).ThreeAbbreviation);

JToken episodeData = seasonInfo["data"]?["episodes"];
Expand Down Expand Up @@ -2323,7 +2323,7 @@ private void GenerateAddEpisodeV4(int code, Locale locale, CachedSeriesInfo si,
if (bestLanguage !=null)
{
AddTranslations(newEp,
API.GetEpisodeTranslationsV4(newEp.EpisodeId, bestLanguage.ThreeAbbreviation));
API.GetEpisodeTranslationsV4(code ,newEp.EpisodeId, bestLanguage.ThreeAbbreviation));
}

si.AddEpisode(newEp);
Expand Down

0 comments on commit 6b53a9c

Please sign in to comment.