Skip to content

Commit

Permalink
chore: ==is & !=is not
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Dec 30, 2024
1 parent 80072a3 commit 063658d
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Shoko.Server/Providers/TMDB/TmdbMetadataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ public async Task ScanForMatches()
if (ser.IsTMDBAutoMatchingDisabled)
continue;

var anime = ser.AniDB_Anime;
if (anime == null)
if (ser.AniDB_Anime is not { } anime)
continue;

if (anime.IsRestricted && !settings.TMDB.AutoLinkRestricted)
Expand Down Expand Up @@ -456,7 +455,7 @@ public async Task<bool> UpdateMovie(int movieId, bool forceRefresh = false, bool
if (downloadCrewAndCast)
methods |= MovieMethods.Credits;
var movie = await UseClient(c => c.GetMovieAsync(movieId, "en-US", null, methods), $"Get movie {movieId}").ConfigureAwait(false);
if (movie == null)
if (movie is null)
return false;

var settings = _settingsProvider.GetSettings();
Expand Down Expand Up @@ -816,7 +815,7 @@ public async Task PurgeMovie(int movieId, bool removeImageFiles = true)
_imageService.PurgeImages(ForeignEntityType.Movie, movieId, removeImageFiles);

var movie = _tmdbMovies.GetByTmdbMovieID(movieId);
if (movie != null)
if (movie is not null)
{
_logger.LogTrace("Removing movie {MovieName} (Movie={MovieID})", movie.OriginalTitle, movie.Id);
_tmdbMovies.Delete(movie);
Expand Down Expand Up @@ -1010,7 +1009,7 @@ public async Task<bool> UpdateShow(int showId, bool forceRefresh = false, bool d
if (downloadAlternateOrdering && !quickRefresh)
methods |= TvShowMethods.EpisodeGroups;
var show = await UseClient(c => c.GetTvShowAsync(showId, methods, "en-US"), $"Get Show {showId}").ConfigureAwait(false);
if (show == null)
if (show is null)
return false;

var settings = _settingsProvider.GetSettings();
Expand Down Expand Up @@ -1743,7 +1742,7 @@ public async Task PurgeShow(int showId, bool removeImageFiles = true)

_imageService.PurgeImages(ForeignEntityType.Show, showId, removeImageFiles);

if (show != null)
if (show is not null)
{
_logger.LogTrace(
"Removing show {ShowName} (Show={ShowId})",
Expand Down Expand Up @@ -1800,7 +1799,7 @@ private void PurgeShowNetworks(int showId, bool removeImageFiles = true)
private void PurgeShowNetwork(int networkId, bool removeImageFiles = true)
{
var tmdbNetwork = _tmdbNetwork.GetByTmdbNetworkID(networkId);
if (tmdbNetwork != null)
if (tmdbNetwork is not null)
{
_logger.LogDebug("Removing TMDB Network (Network={NetworkId})", networkId);
_tmdbNetwork.Delete(tmdbNetwork);
Expand Down Expand Up @@ -1979,7 +1978,7 @@ private bool UpdateTitlesAndOverviews(IEntityMetadata tmdbEntity, TranslationsCo
(!string.IsNullOrEmpty(tmdbEntity.OriginalLanguageCode) && languageCode != tmdbEntity.OriginalLanguageCode && !string.IsNullOrEmpty(tmdbEntity.OriginalTitle) && string.Equals(tmdbEntity.OriginalTitle, currentTitle, StringComparison.InvariantCultureIgnoreCase))
))
{
if (existingTitle == null)
if (existingTitle is null)
{
titlesToAdd++;
titlesToSave.Add(new(tmdbEntity.Type, tmdbEntity.Id, currentTitle, languageCode, countryCode));
Expand Down Expand Up @@ -2007,7 +2006,7 @@ private bool UpdateTitlesAndOverviews(IEntityMetadata tmdbEntity, TranslationsCo
var existingOverview = existingOverviews.FirstOrDefault(overview => overview.LanguageCode == languageCode && overview.CountryCode == countryCode);
if (shouldInclude && !string.IsNullOrEmpty(currentOverview))
{
if (existingOverview == null)
if (existingOverview is null)
{
overviewsToAdd++;
overviewsToSave.Add(new(tmdbEntity.Type, tmdbEntity.Id, currentOverview, languageCode, countryCode));
Expand Down Expand Up @@ -2150,7 +2149,7 @@ private async Task UpdateCompany(ProductionCompany company)
private void PurgeCompany(int companyId, bool removeImageFiles = true)
{
var tmdbCompany = _tmdbCompany.GetByTmdbCompanyID(companyId);
if (tmdbCompany != null)
if (tmdbCompany is not null)
{
_logger.LogDebug("Removing studio. (Company={CompanyId})", companyId);
_tmdbCompany.Delete(tmdbCompany);
Expand Down Expand Up @@ -2267,7 +2266,7 @@ public async Task<bool> PurgePerson(int personId, bool removeImageFiles = true)
internal async Task PurgePersonInternal(int personId, bool removeImageFiles = true, int? currentShowId = null, int? currentMovieId = null)
{
var person = _tmdbPeople.GetByTmdbPersonID(personId);
if (person != null)
if (person is not null)
{
_logger.LogDebug("Removing staff. (Person={PersonId})", personId);
_tmdbPeople.Delete(person);
Expand Down

0 comments on commit 063658d

Please sign in to comment.