2013-06-25 04:51:17 +00:00
|
|
|
|
'use strict';
|
2013-06-24 23:41:59 +00:00
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'backbone',
|
2013-06-25 05:12:42 +00:00
|
|
|
|
'Quality/QualityProfileCollection'
|
2013-06-24 23:41:59 +00:00
|
|
|
|
], function (Backbone, QualityProfileCollection) {
|
|
|
|
|
return Backbone.Model.extend({
|
|
|
|
|
|
2013-06-25 05:12:42 +00:00
|
|
|
|
urlRoot: ApiRoot + '/series',
|
2013-06-24 23:41:59 +00:00
|
|
|
|
|
|
|
|
|
mutators: {
|
|
|
|
|
percentOfEpisodes: function () {
|
|
|
|
|
var episodeCount = this.get('episodeCount');
|
|
|
|
|
var episodeFileCount = this.get('episodeFileCount');
|
|
|
|
|
|
|
|
|
|
var percent = 100;
|
|
|
|
|
|
|
|
|
|
if (episodeCount > 0) {
|
|
|
|
|
percent = episodeFileCount / episodeCount * 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return percent;
|
|
|
|
|
},
|
|
|
|
|
poster : function () {
|
|
|
|
|
var poster = _.find(this.get('images'), function (image) {
|
|
|
|
|
return image.coverType === 'poster';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (poster) {
|
|
|
|
|
return poster.url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
fanArt : function () {
|
|
|
|
|
var poster = _.find(this.get('images'), function (image) {
|
|
|
|
|
return image.coverType === 'fanart';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (poster) {
|
|
|
|
|
return poster.url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
traktUrl : function () {
|
|
|
|
|
return 'http://trakt.tv/show/' + this.get('titleSlug');
|
|
|
|
|
},
|
|
|
|
|
imdbUrl : function () {
|
|
|
|
|
return 'http://imdb.com/title/' + this.get('imdbId');
|
|
|
|
|
},
|
|
|
|
|
isContinuing : function () {
|
|
|
|
|
return this.get('status') === 'continuing';
|
|
|
|
|
},
|
|
|
|
|
route : function () {
|
|
|
|
|
return '/series/details/' + this.get('titleSlug');
|
|
|
|
|
//return '/series/details/' + this.get('id');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
qualityProfile: function () {
|
|
|
|
|
var profile = QualityProfileCollection.get(this.get('qualityProfileId'));
|
|
|
|
|
if (profile) {
|
|
|
|
|
return profile.toJSON();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return undefined;
|
2013-06-13 01:37:05 +00:00
|
|
|
|
}
|
2013-04-04 04:38:51 +00:00
|
|
|
|
},
|
2013-06-13 01:37:05 +00:00
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
|
defaults: {
|
|
|
|
|
episodeFileCount: 0,
|
|
|
|
|
episodeCount : 0,
|
|
|
|
|
isExisting : false,
|
|
|
|
|
status : 0
|
2013-02-14 02:28:56 +00:00
|
|
|
|
}
|
2013-06-24 23:41:59 +00:00
|
|
|
|
});
|
2013-02-14 02:28:56 +00:00
|
|
|
|
});
|