mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-17 10:45:49 +02:00
Save episode quality after change
This commit is contained in:
parent
df1cb91a84
commit
7c915bd522
34
NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs
Normal file
34
NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using System.Linq;
|
||||
using Omu.ValueInjecter;
|
||||
|
||||
namespace NzbDrone.Api.EpisodeFiles
|
||||
{
|
||||
public class EpisodeModule : NzbDroneRestModule<EpisodeFileResource>
|
||||
{
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
|
||||
public EpisodeModule(IMediaFileService mediaFileService)
|
||||
: base("/episodefile")
|
||||
{
|
||||
_mediaFileService = mediaFileService;
|
||||
|
||||
UpdateResource = SetQuality;
|
||||
}
|
||||
|
||||
private EpisodeFileResource SetQuality(EpisodeFileResource episodeFileResource)
|
||||
{
|
||||
var episodeFile = _mediaFileService.Get(episodeFileResource.Id);
|
||||
episodeFile.Quality = episodeFileResource.Quality;
|
||||
|
||||
_mediaFileService.Update(episodeFile);
|
||||
episodeFileResource.InjectFrom(episodeFile);
|
||||
|
||||
return episodeFileResource;
|
||||
}
|
||||
}
|
||||
}
|
17
NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs
Normal file
17
NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Api.EpisodeFiles
|
||||
{
|
||||
public class EpisodeFileResource : RestResource
|
||||
{
|
||||
public Int32 SeriesId { get; set; }
|
||||
public Int32 SeasonNumber { get; set; }
|
||||
public String Path { get; set; }
|
||||
public Int64 Size { get; set; }
|
||||
public DateTime DateAdded { get; set; }
|
||||
public String SceneName { get; set; }
|
||||
public QualityModel Quality { get; set; }
|
||||
}
|
||||
}
|
@ -85,6 +85,8 @@
|
||||
<Compile Include="Commands\CommandResource.cs" />
|
||||
<Compile Include="Config\NamingConfigResource.cs" />
|
||||
<Compile Include="Config\NamingModule.cs" />
|
||||
<Compile Include="EpisodeFiles\EpisodeFileModule.cs" />
|
||||
<Compile Include="EpisodeFiles\EpisodeFileResource.cs" />
|
||||
<Compile Include="Directories\DirectoryLookupService.cs" />
|
||||
<Compile Include="Directories\DirectoryModule.cs" />
|
||||
<Compile Include="Episodes\EpisodeModule.cs" />
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
@ -18,6 +19,7 @@ public interface IMediaFileService
|
||||
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
||||
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
||||
List<string> FilterExistingFiles(List<string> files, int seriesId);
|
||||
EpisodeFile Get(int id);
|
||||
}
|
||||
|
||||
public class MediaFileService : IMediaFileService, IHandleAsync<SeriesDeletedEvent>
|
||||
@ -81,6 +83,11 @@ public List<string> FilterExistingFiles(List<string> files, int seriesId)
|
||||
return files.Select(f => f.CleanFilePath().ToLower()).Except(seriesFiles).ToList();
|
||||
}
|
||||
|
||||
public EpisodeFile Get(int id)
|
||||
{
|
||||
return _mediaFileRepository.Get(id);
|
||||
}
|
||||
|
||||
public void HandleAsync(SeriesDeletedEvent message)
|
||||
{
|
||||
var files = GetFilesBySeries(message.Series.Id);
|
||||
|
@ -51,6 +51,7 @@ define(
|
||||
};
|
||||
|
||||
model.set(column.get("name"), newQuality);
|
||||
model.save();
|
||||
model.trigger("backgrid:edited", model, column, new Backgrid.Command(e));
|
||||
},
|
||||
|
||||
|
@ -23,8 +23,8 @@ define(
|
||||
|
||||
if (hasFile) {
|
||||
var episodeFile = this.model.get('episodeFile');
|
||||
var quality = episodeFile.quality;
|
||||
var size = FormatHelpers.bytes(episodeFile.size);
|
||||
var quality = episodeFile.get('quality');
|
||||
var size = FormatHelpers.bytes(episodeFile.get('size'));
|
||||
var title = 'Episode downloaded';
|
||||
|
||||
if (quality.proper) {
|
||||
|
@ -36,7 +36,6 @@ define(
|
||||
this._setMonitoredState();
|
||||
},
|
||||
|
||||
|
||||
_showSummary: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
|
9
UI/Series/EpisodeFileModel.js
Normal file
9
UI/Series/EpisodeFileModel.js
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
url: window.ApiRoot + '/episodefile'
|
||||
});
|
||||
});
|
@ -3,8 +3,9 @@ define(
|
||||
[
|
||||
'backbone',
|
||||
'moment',
|
||||
'Series/SeriesModel'
|
||||
], function (Backbone, Moment, SeriesModel) {
|
||||
'Series/SeriesModel',
|
||||
'Series/EpisodeFileModel'
|
||||
], function (Backbone, Moment, SeriesModel, EpisodeFileModel) {
|
||||
return Backbone.Model.extend({
|
||||
|
||||
initialize: function () {
|
||||
@ -19,6 +20,10 @@ define(
|
||||
parse: function (model) {
|
||||
model.series = new SeriesModel(model.series);
|
||||
|
||||
if (model.episodeFile) {
|
||||
model.episodeFile = new EpisodeFileModel(model.episodeFile);
|
||||
}
|
||||
|
||||
return model;
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user