Don't allow to set episode files with 'Original' language

pull/7763/head
Bogdan 1 month ago committed by Mark McDowall
parent 20c2d59e9a
commit 6aee9c7fd5

@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.Languages;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
@ -153,7 +156,7 @@ namespace Sonarr.Api.V3.EpisodeFiles
if (episodeFile == null)
{
throw new NzbDroneClientException(global::System.Net.HttpStatusCode.NotFound, "Episode file not found");
throw new NzbDroneClientException(HttpStatusCode.NotFound, "Episode file not found");
}
var series = _seriesService.GetSeries(episodeFile.SeriesId);
@ -188,7 +191,8 @@ namespace Sonarr.Api.V3.EpisodeFiles
if (resourceEpisodeFile.Languages != null)
{
episodeFile.Languages = resourceEpisodeFile.Languages;
// Don't allow user to set files with 'Original' language
episodeFile.Languages = resourceEpisodeFile.Languages.Where(l => l != null && l != Language.Original).ToList();
}
if (resourceEpisodeFile.Quality != null)
@ -218,7 +222,9 @@ namespace Sonarr.Api.V3.EpisodeFiles
}
_mediaFileService.Update(episodeFiles);
var series = _seriesService.GetSeries(episodeFiles.First().SeriesId);
return Accepted(episodeFiles.ConvertAll(f => f.ToResource(series, _upgradableSpecification, _formatCalculator)));
}

Loading…
Cancel
Save