diff --git a/couchpotato/core/plugins/movie/static/movie.actions.js b/couchpotato/core/plugins/movie/static/movie.actions.js index a56e9abd..2b7f76d0 100644 --- a/couchpotato/core/plugins/movie/static/movie.actions.js +++ b/couchpotato/core/plugins/movie/static/movie.actions.js @@ -94,36 +94,30 @@ MA.Release = new Class({ } else { - var buttons_done = false; + var releases = self.movie.data.releases.sortBy('-info.score'); - self.movie.data.releases.sortBy('-info.score').each(function(release){ - if(buttons_done) return; - - var status = Status.get(release.status_id); + for(x in releases){ + var release = releases[x], + status = Status.get(release.status_id); if((self.next_release && (status.identifier == 'ignored' || status.identifier == 'failed')) || (!self.next_release && status.identifier == 'available')){ - self.hide_on_click = false; - self.show(); - buttons_done = true; + self.showHelper(); + break; } - - }); - + } } }, - show: function(e){ + createReleases: function(){ var self = this; - if(e) - (e).preventDefault(); if(!self.options_container){ self.options_container = new Element('div.options').adopt( self.release_container = new Element('div.releases.table').adopt( self.trynext_container = new Element('div.buttons.try_container') ) - ).inject(self.movie, 'top'); + ); // Header new Element('div.item.head').adopt( @@ -238,9 +232,71 @@ MA.Release = new Class({ } + }, + + show: function(e){ + var self = this; + if(e) + (e).preventDefault(); + + self.createReleases(); + self.options_container.inject(self.movie, 'top'); self.movie.slide('in', self.options_container); }, + showHelper: function(e){ + var self = this; + if(e) + (e).preventDefault(); + + self.createReleases(); + self.trynext_container = new Element('div.buttons.trynext').inject(self.movie.info_container); + + if(self.next_release || self.last_release){ + + self.trynext_container.adopt( + self.next_release ? [new Element('a.icon.readd', { + 'text': self.last_release ? 'Download another release' : 'Download the best release', + 'events': { + 'click': self.tryNextRelease.bind(self) + } + }), + new Element('a.icon.download', { + 'text': 'pick one yourself', + 'events': { + 'click': function(){ + self.movie.quality.fireEvent('click'); + } + } + })] : null, + new Element('a.icon.completed', { + 'text': 'mark this movie done', + 'events': { + 'click': function(){ + Api.request('movie.delete', { + 'data': { + 'id': self.movie.get('id'), + 'delete_from': 'wanted' + }, + 'onComplete': function(){ + var movie = $(self.movie); + movie.set('tween', { + 'duration': 300, + 'onComplete': function(){ + self.movie.destroy() + } + }); + movie.tween('height', 0); + } + }); + } + } + }) + ) + } + + }, + get: function(release, type){ return release.info[type] || 'n/a' }, @@ -251,14 +307,15 @@ MA.Release = new Class({ var release_el = self.release_container.getElement('#release_'+release.id), icon = release_el.getElement('.download.icon'); - icon.addClass('spinner'); + self.movie.busy(true); Api.request('release.download', { 'data': { 'id': release.id }, 'onComplete': function(json){ - icon.removeClass('spinner') + self.movie.busy(false); + if(json.success) icon.addClass('completed'); else @@ -281,6 +338,8 @@ MA.Release = new Class({ tryNextRelease: function(movie_id){ var self = this; + self.createReleases(); + if(self.last_release) self.ignore(self.last_release); diff --git a/couchpotato/core/plugins/movie/static/movie.css b/couchpotato/core/plugins/movie/static/movie.css index 65fe5209..dd1bcbd3 100644 --- a/couchpotato/core/plugins/movie/static/movie.css +++ b/couchpotato/core/plugins/movie/static/movie.css @@ -39,7 +39,7 @@ overflow: hidden; width: 100%; height: 180px; - transition: all 0.2s linear; + transition: all 0.6s cubic-bezier(0.9,0,0.1,1); } .movies.list_list .movie:not(.details_view), @@ -95,7 +95,7 @@ width: 938px; box-shadow: none; border: 0; - background: none; + background: #4e5969; } .movies.thumbs_list .data { @@ -322,8 +322,8 @@ right: 10px; } - .movies .data:hover .action { opacity: 0.6; } - .movies .data:hover .action:hover { opacity: 1; } + .movies .movie:hover .action { opacity: 0.6; } + .movies .movie:hover .action:hover { opacity: 1; } .movies.mass_edit_list .data .actions { display: none; } @@ -338,8 +338,8 @@ opacity: 0; } - .movies.list_list .movie:not(.details_view) .data:hover .actions, - .movies.mass_edit_list .data:hover .actions { + .movies.list_list .movie:not(.details_view):hover .actions, + .movies.mass_edit_list .movie:hover .actions { margin: 0; background: #4e5969; top: 2px; @@ -510,6 +510,29 @@ .movies .movie .releases .last_release > :first-child { margin-left: -6px; } + .movies .movie .trynext { + display: inline; + position: absolute; + right: 135px; + z-index: 2; + opacity: 0; + text-shadow: none; + background: #4e5969; + } + .movies .movie:hover .trynext { + opacity: 1; + } + + .movies .movie .trynext a { + background-position: 5px center; + padding: 0 5px 0 25px; + margin-right: 10px; + color: #FFF; + border-radius: 2px; + } + .movies .movie .trynext a:hover { + background-color: #369545; + } .movies .load_more { display: block; diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py index 02843f85..68bf60a6 100644 --- a/couchpotato/core/plugins/release/main.py +++ b/couchpotato/core/plugins/release/main.py @@ -160,7 +160,9 @@ class Release(Plugin): db = get_session() id = getParam('id') - status_snatched = fireEvent('status.add', 'snatched', single = True) + + snatched_status = fireEvent('status.add', 'snatched', single = True) + done_status = fireEvent('status.get', 'done', single = True) rel = db.query(Relea).filter_by(id = id).first() if rel: @@ -168,6 +170,8 @@ class Release(Plugin): for info in rel.info: item[info.identifier] = info.value + fireEvent('notify.frontend', type = 'release.download', data = True, message = 'Snatching "%s"' % item['name']) + # Get matching provider provider = fireEvent('provider.belongs_to', item['url'], provider = item.get('provider'), single = True) @@ -182,8 +186,14 @@ class Release(Plugin): }), manual = True, single = True) if success: - rel.status_id = status_snatched.get('id') - db.commit() + db.expunge_all() + rel = db.query(Relea).filter_by(id = id).first() # Get release again + + if rel.status_id != done_status.get('id'): + rel.status_id = snatched_status.get('id') + db.commit() + + fireEvent('notify.frontend', type = 'release.download', data = True, message = 'Successfully snatched "%s"' % item['name']) return jsonified({ 'success': success diff --git a/couchpotato/static/scripts/page/home.js b/couchpotato/static/scripts/page/home.js index c1e91162..004f0513 100644 --- a/couchpotato/static/scripts/page/home.js +++ b/couchpotato/static/scripts/page/home.js @@ -23,7 +23,7 @@ Page.Home = new Class({ 'identifier': 'snatched', 'load_more': false, 'view': 'list', - 'actions': [MA.IMDB, MA.Trailer, MA.Files, MA.Release, MA.Edit, MA.Readd, MA.Refresh, MA.Delete], + 'actions': [MA.IMDB, MA.Trailer, MA.Release, MA.Refresh, MA.Delete], 'title': 'Snatched & Available', 'on_empty_element': new Element('div'), 'filter': {