This commit is contained in:
Amelia Magee 2025-12-29 23:52:20 +01:00 committed by GitHub
commit 9ad1d91edd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 44 additions and 1 deletions

View file

@ -93,6 +93,18 @@ const fileDateOptions: EnhancedSelectInputValue<string>[] = [
return translate('PhysicalReleaseDate');
},
},
{
key: 'first',
get value() {
return translate('FirstImportedDate');
},
},
{
key: 'tracked',
get value() {
return translate('TrackedDate');
},
},
];
function MediaManagement() {

View file

@ -17,6 +17,7 @@ public interface IHistoryRepository : IBasicRepository<MovieHistory>
List<MovieHistory> FindDownloadHistory(int movieId, QualityModel quality);
List<MovieHistory> GetByMovieId(int movieId, MovieHistoryEventType? eventType);
void DeleteForMovies(List<int> movieIds);
MovieHistory FirstForMovie(int movieId);
MovieHistory MostRecentForMovie(int movieId);
List<MovieHistory> Since(DateTime date, MovieHistoryEventType? eventType);
PagingSpec<MovieHistory> GetPaged(PagingSpec<MovieHistory> pagingSpec, int[] languages, int[] qualities);
@ -75,6 +76,11 @@ public void DeleteForMovies(List<int> movieIds)
Delete(c => movieIds.Contains(c.MovieId));
}
public MovieHistory FirstForMovie(int movieId)
{
return Query(x => x.MovieId == movieId).MinBy(h => h.Date);
}
public MovieHistory MostRecentForMovie(int movieId)
{
return Query(x => x.MovieId == movieId).MaxBy(h => h.Date);

View file

@ -20,6 +20,7 @@ public interface IHistoryService
{
QualityModel GetBestQualityInHistory(QualityProfile profile, int movieId);
PagingSpec<MovieHistory> Paged(PagingSpec<MovieHistory> pagingSpec, int[] languages, int[] qualities);
MovieHistory FirstForMovie(int movieId);
MovieHistory MostRecentForMovie(int movieId);
MovieHistory MostRecentForDownloadId(string downloadId);
MovieHistory Get(int historyId);
@ -54,6 +55,11 @@ public PagingSpec<MovieHistory> Paged(PagingSpec<MovieHistory> pagingSpec, int[]
return _historyRepository.GetPaged(pagingSpec, languages, qualities);
}
public MovieHistory FirstForMovie(int movieId)
{
return _historyRepository.FirstForMovie(movieId);
}
public MovieHistory MostRecentForMovie(int movieId)
{
return _historyRepository.MostRecentForMovie(movieId);

View file

@ -700,6 +700,7 @@
"Filters": "Filters",
"FilterMoviePropertiesOnlyNotFileWarning": "Filters are available only for the properties of a movie, they are not available for properties of the file(s) you may have for that movie.",
"FirstDayOfWeek": "First Day of Week",
"FirstImportedDate": "First Imported Date",
"Fixed": "Fixed",
"Folder": "Folder",
"FolderNameTokens": "Folder Name Tokens",
@ -1932,6 +1933,7 @@
"TotalSpace": "Total Space",
"Trace": "Trace",
"Trailer": "Trailer",
"TrackedDate": "Tracked Date",
"Trakt": "Trakt",
"TraktRating": "Trakt Rating",
"TraktVotes": "Trakt Votes",

View file

@ -4,6 +4,8 @@ public enum FileDateType
{
None = 0,
Cinemas = 1,
Release = 2
Release = 2,
First = 3,
Tracked = 4
}
}

View file

@ -6,6 +6,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Instrumentation.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.History;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies;
@ -23,16 +24,19 @@ public class UpdateMovieFileService : IUpdateMovieFileService,
private readonly IDiskProvider _diskProvider;
private readonly IConfigService _configService;
private readonly IMediaFileService _mediaFileService;
private readonly IHistoryService _historyService;
private readonly Logger _logger;
public UpdateMovieFileService(IDiskProvider diskProvider,
IConfigService configService,
IMediaFileService mediaFileService,
IHistoryService historyService,
Logger logger)
{
_diskProvider = diskProvider;
_configService = configService;
_mediaFileService = mediaFileService;
_historyService = historyService;
_logger = logger;
}
@ -70,6 +74,17 @@ private bool ChangeFileDate(MovieFile movieFile, Movie movie)
return ChangeFileDate(movieFilePath, airDate.Value);
}
case FileDateType.First:
{
var firstMovieHistory = _historyService.FirstForMovie(movie.Id);
return ChangeFileDate(movieFilePath, firstMovieHistory.Date);
}
case FileDateType.Tracked:
{
return ChangeFileDate(movieFilePath, movie.Added);
}
}
return false;