mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01: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="Commands\CommandResource.cs" />
|
||||||
<Compile Include="Config\NamingConfigResource.cs" />
|
<Compile Include="Config\NamingConfigResource.cs" />
|
||||||
<Compile Include="Config\NamingModule.cs" />
|
<Compile Include="Config\NamingModule.cs" />
|
||||||
|
<Compile Include="EpisodeFiles\EpisodeFileModule.cs" />
|
||||||
|
<Compile Include="EpisodeFiles\EpisodeFileResource.cs" />
|
||||||
<Compile Include="Directories\DirectoryLookupService.cs" />
|
<Compile Include="Directories\DirectoryLookupService.cs" />
|
||||||
<Compile Include="Directories\DirectoryModule.cs" />
|
<Compile Include="Directories\DirectoryModule.cs" />
|
||||||
<Compile Include="Episodes\EpisodeModule.cs" />
|
<Compile Include="Episodes\EpisodeModule.cs" />
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
@ -18,6 +19,7 @@ public interface IMediaFileService
|
|||||||
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
List<EpisodeFile> GetFilesBySeries(int seriesId);
|
||||||
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
List<EpisodeFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
||||||
List<string> FilterExistingFiles(List<string> files, int seriesId);
|
List<string> FilterExistingFiles(List<string> files, int seriesId);
|
||||||
|
EpisodeFile Get(int id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MediaFileService : IMediaFileService, IHandleAsync<SeriesDeletedEvent>
|
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();
|
return files.Select(f => f.CleanFilePath().ToLower()).Except(seriesFiles).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EpisodeFile Get(int id)
|
||||||
|
{
|
||||||
|
return _mediaFileRepository.Get(id);
|
||||||
|
}
|
||||||
|
|
||||||
public void HandleAsync(SeriesDeletedEvent message)
|
public void HandleAsync(SeriesDeletedEvent message)
|
||||||
{
|
{
|
||||||
var files = GetFilesBySeries(message.Series.Id);
|
var files = GetFilesBySeries(message.Series.Id);
|
||||||
|
@ -51,6 +51,7 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
model.set(column.get("name"), newQuality);
|
model.set(column.get("name"), newQuality);
|
||||||
|
model.save();
|
||||||
model.trigger("backgrid:edited", model, column, new Backgrid.Command(e));
|
model.trigger("backgrid:edited", model, column, new Backgrid.Command(e));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ define(
|
|||||||
|
|
||||||
if (hasFile) {
|
if (hasFile) {
|
||||||
var episodeFile = this.model.get('episodeFile');
|
var episodeFile = this.model.get('episodeFile');
|
||||||
var quality = episodeFile.quality;
|
var quality = episodeFile.get('quality');
|
||||||
var size = FormatHelpers.bytes(episodeFile.size);
|
var size = FormatHelpers.bytes(episodeFile.get('size'));
|
||||||
var title = 'Episode downloaded';
|
var title = 'Episode downloaded';
|
||||||
|
|
||||||
if (quality.proper) {
|
if (quality.proper) {
|
||||||
|
@ -36,7 +36,6 @@ define(
|
|||||||
this._setMonitoredState();
|
this._setMonitoredState();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
_showSummary: function (e) {
|
_showSummary: function (e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
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',
|
'backbone',
|
||||||
'moment',
|
'moment',
|
||||||
'Series/SeriesModel'
|
'Series/SeriesModel',
|
||||||
], function (Backbone, Moment, SeriesModel) {
|
'Series/EpisodeFileModel'
|
||||||
|
], function (Backbone, Moment, SeriesModel, EpisodeFileModel) {
|
||||||
return Backbone.Model.extend({
|
return Backbone.Model.extend({
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
@ -19,6 +20,10 @@ define(
|
|||||||
parse: function (model) {
|
parse: function (model) {
|
||||||
model.series = new SeriesModel(model.series);
|
model.series = new SeriesModel(model.series);
|
||||||
|
|
||||||
|
if (model.episodeFile) {
|
||||||
|
model.episodeFile = new EpisodeFileModel(model.episodeFile);
|
||||||
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user