mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 03:52:33 +02:00
EpisodeFile is downloaded if not available already
This commit is contained in:
parent
b1899b5f6f
commit
ce9166c6a9
@ -16,10 +16,16 @@ public EpisodeModule(IMediaFileService mediaFileService)
|
||||
: base("/episodefile")
|
||||
{
|
||||
_mediaFileService = mediaFileService;
|
||||
GetResourceById = GetEpisodeFile;
|
||||
GetResourceAll = GetEpisodeFiles;
|
||||
UpdateResource = SetQuality;
|
||||
}
|
||||
|
||||
private EpisodeFileResource GetEpisodeFile(int id)
|
||||
{
|
||||
return ToResource(() => _mediaFileService.Get(id));
|
||||
}
|
||||
|
||||
private List<EpisodeFileResource> GetEpisodeFiles()
|
||||
{
|
||||
var seriesId = (int?)Request.Query.SeriesId;
|
||||
|
@ -2,8 +2,9 @@
|
||||
define(
|
||||
[
|
||||
'backgrid',
|
||||
'Settings/Quality/Profile/QualityProfileSchemaCollection'
|
||||
], function (Backgrid, QualityProfileSchemaCollection) {
|
||||
'Settings/Quality/Profile/QualityProfileSchemaCollection',
|
||||
'Series/EpisodeFileModel'
|
||||
], function (Backgrid, QualityProfileSchemaCollection, EpisodeFileModel) {
|
||||
return Backgrid.CellEditor.extend({
|
||||
|
||||
className: 'quality-cell-editor',
|
||||
|
@ -2,7 +2,7 @@
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Episode/Summary/Layout',
|
||||
'Episode/Summary/EpisodeSummaryLayout',
|
||||
'Episode/Search/Layout',
|
||||
'Series/SeriesCollection'
|
||||
], function (Marionette, SummaryLayout, SearchLayout, SeriesCollection) {
|
||||
|
88
UI/Episode/Summary/EpisodeSummaryLayout.js
Normal file
88
UI/Episode/Summary/EpisodeSummaryLayout.js
Normal file
@ -0,0 +1,88 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Series/EpisodeFileModel',
|
||||
'Series/EpisodeFileCollection',
|
||||
'Cells/FileSizeCell',
|
||||
'Cells/QualityCell',
|
||||
'Episode/Summary/NoFileView'
|
||||
], function (App, Marionette, Backgrid, EpisodeFileModel, EpisodeFileCollection, FileSizeCell, QualityCell, NoFileView) {
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Episode/Summary/EpisodeSummaryLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
overview: '.episode-overview',
|
||||
activity: '.episode-file-info'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'path',
|
||||
label : 'Path',
|
||||
cell : 'string',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
name : 'size',
|
||||
label : 'Size',
|
||||
cell : FileSizeCell,
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
name : 'quality',
|
||||
label : 'Quality',
|
||||
cell : QualityCell,
|
||||
sortable: false,
|
||||
editable: true
|
||||
}
|
||||
],
|
||||
|
||||
templateHelpers: {},
|
||||
|
||||
initialize: function (options) {
|
||||
if (!this.model.series) {
|
||||
this.templateHelpers.series = options.series.toJSON();
|
||||
}
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
if (this.model.get('hasFile')) {
|
||||
var episodeFileId = this.model.get('episodeFileId');
|
||||
|
||||
if (App.reqres.hasHandler(App.Reqres.GetEpisodeFileById)) {
|
||||
var episodeFile = App.request(App.Reqres.GetEpisodeFileById, episodeFileId);
|
||||
var episodeFileCollection = new EpisodeFileCollection(episodeFile, { seriesId: this.model.get('seriesId') });
|
||||
this._showTable(episodeFileCollection)
|
||||
}
|
||||
|
||||
else {
|
||||
var self = this;
|
||||
var newEpisodeFile = new EpisodeFileModel({ id: episodeFileId });
|
||||
var newEpisodeFileCollection = new EpisodeFileCollection(newEpisodeFile, { seriesId: this.model.get('seriesId') });
|
||||
var promise = newEpisodeFile.fetch();
|
||||
|
||||
promise.done(function () {
|
||||
self._showTable(newEpisodeFileCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
this.activity.show(new NoFileView());
|
||||
}
|
||||
},
|
||||
|
||||
_showTable: function (episodeFileCollection) {
|
||||
this.activity.show(new Backgrid.Grid({
|
||||
collection: episodeFileCollection,
|
||||
columns : this.columns,
|
||||
className : 'table table-bordered'
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
@ -4,11 +4,10 @@ define(
|
||||
'app',
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Series/EpisodeFileCollection',
|
||||
'Cells/FileSizeCell',
|
||||
'Cells/QualityCell',
|
||||
'Episode/Summary/NoFileView'
|
||||
], function (App, Marionette, Backgrid, EpisodeFileCollection, FileSizeCell, QualityCell, NoFileView) {
|
||||
], function (App, Marionette, Backgrid, FileSizeCell, QualityCell, NoFileView) {
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Episode/Summary/LayoutTemplate',
|
||||
@ -54,7 +53,7 @@ define(
|
||||
var episodeFile = App.request(App.Reqres.GetEpisodeFileById, this.model.get('episodeFileId'));
|
||||
|
||||
this.activity.show(new Backgrid.Grid({
|
||||
collection: new EpisodeFileCollection(episodeFile, { seriesId: this.model.get('seriesId') }),
|
||||
collection: new Backbone.Collection(episodeFile),
|
||||
columns : this.columns,
|
||||
className : 'table table-bordered'
|
||||
}));
|
||||
|
@ -33,7 +33,7 @@ define(
|
||||
var self = this;
|
||||
|
||||
_.each(message.episode.episodes, function (episode){
|
||||
var ep = self.episodeCollection.find({ id: episode.id });
|
||||
var ep = self.episodeCollection.get(episode.id);
|
||||
ep.set('downloading', true);
|
||||
console.debug(episode.title);
|
||||
});
|
||||
|
@ -1,22 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'moment',
|
||||
'Series/SeriesModel',
|
||||
'Series/EpisodeFileModel'
|
||||
], function (Backbone, Moment, SeriesModel, EpisodeFileModel) {
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
|
||||
parse: function (model) {
|
||||
|
||||
if (model.episodeFile) {
|
||||
model.episodeFile = new EpisodeFileModel(model.episodeFile);
|
||||
}
|
||||
|
||||
return model;
|
||||
},
|
||||
|
||||
defaults: {
|
||||
seasonNumber: 0,
|
||||
status : 0
|
||||
|
Loading…
Reference in New Issue
Block a user