diff --git a/couchpotato/cli.py b/couchpotato/cli.py
index fe265d1..575f097 100644
--- a/couchpotato/cli.py
+++ b/couchpotato/cli.py
@@ -74,7 +74,7 @@ def cmd_couchpotato(base_path, args):
logger.addHandler(hdlr)
# To file
- hdlr2 = handlers.RotatingFileHandler(Env.get('log_path'), 'a', 5000000, 4)
+ hdlr2 = handlers.RotatingFileHandler(Env.get('log_path'), 'a', 500000, 10)
hdlr2.setFormatter(formatter)
logger.addHandler(hdlr2)
diff --git a/couchpotato/core/plugins/movie/main.py b/couchpotato/core/plugins/movie/main.py
index 646c584..3ed6216 100644
--- a/couchpotato/core/plugins/movie/main.py
+++ b/couchpotato/core/plugins/movie/main.py
@@ -38,7 +38,7 @@ class MoviePlugin(Plugin):
movies = []
for movie in results:
temp = movie.to_dict(deep = {
- 'releases': {'status': {}, 'quality': {}, 'files':{}},
+ 'releases': {'status': {}, 'quality': {}, 'files':{}, 'info': {}},
'library': {'titles': {}, 'files':{}},
'files': {}
})
@@ -68,7 +68,7 @@ class MoviePlugin(Plugin):
fireEventAsync('library.update', identifier = movie.library.identifier, default_title = default_title, force = True)
fireEventAsync('searcher.single', movie.to_dict(deep = {
'profile': {'types': {'quality': {}}},
- 'releases': {'status': {}, 'quality': {}},
+ 'releases': {'status': {}, 'quality': {}, 'files': {}, 'info': {}},
'library': {'titles': {}, 'files':{}},
'files': {}
}))
@@ -119,7 +119,7 @@ class MoviePlugin(Plugin):
db.commit()
movie_dict = m.to_dict(deep = {
- 'releases': {'status': {}, 'quality': {}},
+ 'releases': {'status': {}, 'quality': {}, 'files': {}, 'info': {}},
'library': {'titles': {}}
})
diff --git a/couchpotato/core/plugins/movie/static/list.js b/couchpotato/core/plugins/movie/static/list.js
index 73581e1..94ced76 100644
--- a/couchpotato/core/plugins/movie/static/list.js
+++ b/couchpotato/core/plugins/movie/static/list.js
@@ -3,7 +3,7 @@ var MovieList = new Class({
Implements: [Options],
options: {
- navigation: true
+ navigation: false
},
movies: [],
@@ -23,7 +23,8 @@ var MovieList = new Class({
self.el.empty();
// Create the alphabet nav
- self.createNavigation();
+ if(self.options.navigation)
+ self.createNavigation();
Object.each(self.movies, function(info){
var m = new Movie(self, {
@@ -32,16 +33,18 @@ var MovieList = new Class({
$(m).inject(self.el);
m.fireEvent('injected');
- var first_char = m.getTitle().substr(0, 1);
- self.activateLetter(first_char);
+ if(self.options.navigation){
+ var first_char = m.getTitle().substr(0, 1);
+ self.activateLetter(first_char);
+ }
});
self.el.addEvents({
'mouseenter:relay(.movie)': function(e, el){
- el.addClass('hover')
+ el.addClass('hover');
},
'mouseleave:relay(.movie)': function(e, el){
- el.removeClass('hover')
+ el.removeClass('hover');
}
});
},
@@ -64,13 +67,13 @@ var MovieList = new Class({
self.letters[c] = new Element('li', {
'text': c,
'class': 'letter_'+c
- }).inject(self.alpha)
+ }).inject(self.alpha);
});
},
activateLetter: function(letter){
- this.letters[letter].addClass('active')
+ this.letters[letter].addClass('active');
},
update: function(){
@@ -80,7 +83,7 @@ var MovieList = new Class({
},
getMovies: function(){
- var self = this
+ var self = this;
Api.request('movie.list', {
'data': {
@@ -90,7 +93,7 @@ var MovieList = new Class({
self.store(json.movies);
self.create();
}
- })
+ });
},
store: function(movies){
diff --git a/couchpotato/core/plugins/movie/static/movie.js b/couchpotato/core/plugins/movie/static/movie.js
index a2adc83..02982e3 100644
--- a/couchpotato/core/plugins/movie/static/movie.js
+++ b/couchpotato/core/plugins/movie/static/movie.js
@@ -206,6 +206,7 @@ var ReleaseAction = new Class({
).inject(self.movie, 'top');
Array.each(self.movie.data.releases, function(release){
+ p(release);
new Element('div', {
'text': release.title
}).inject(self.release_container)
diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py
index 0f6ae14..64e6daf 100644
--- a/couchpotato/core/plugins/searcher/main.py
+++ b/couchpotato/core/plugins/searcher/main.py
@@ -1,9 +1,10 @@
from couchpotato import get_session
from couchpotato.core.event import addEvent, fireEvent
from couchpotato.core.helpers.encoding import simplifyString
+from couchpotato.core.helpers.variable import md5
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
-from couchpotato.core.settings.model import Movie, Release
+from couchpotato.core.settings.model import Movie, Release, ReleaseInfo
from couchpotato.environment import Env
import re
@@ -39,15 +40,20 @@ class Searcher(Plugin):
def single(self, movie):
+ downloaded_status = fireEvent('status.get', 'downloaded', single = True)
+ available_status = fireEvent('status.get', 'available', single = True)
+ snatched_status = fireEvent('status.get', 'snatched', single = True)
+
successful = False
for type in movie['profile']['types']:
+ print type
has_better_quality = 0
default_title = movie['library']['titles'][0]['title']
# See if beter quality is available
for release in movie['releases']:
- if release['quality']['order'] <= type['quality']['order']:
+ if release['quality']['order'] <= type['quality']['order'] and release['status_id'] is not available_status.get('id'):
has_better_quality += 1
# Don't search for quality lower then already available.
@@ -57,25 +63,51 @@ class Searcher(Plugin):
results = fireEvent('provider.yarr.search', movie, type['quality'], merge = True)
sorted_results = sorted(results, key = lambda k: k['score'], reverse = True)
+ # Add them to this movie releases list
for nzb in sorted_results:
- successful = fireEvent('download', data = nzb, movie = movie, single = True)
-
- if successful:
- log.info('Downloading of %s successful.' % nzb.get('name'))
+ db = get_session()
- # Add release item, should be updated later when renaming
- snatched_status = fireEvent('status.get', 'snatched', single = True)
- db = get_session()
+ rls = db.query(Release).filter_by(identifier = md5(nzb['url'])).first()
+ if not rls:
rls = Release(
- identifier = '%s.%s' % (movie['library']['identifier'], type['quality']['identifier']),
+ identifier = md5(nzb['url']),
movie_id = movie.get('id'),
quality_id = type.get('quality_id'),
- status_id = snatched_status.get('id')
+ status_id = available_status.get('id')
)
db.add(rls)
db.commit()
+ for info in nzb:
+ rls_info = ReleaseInfo(
+ identifier = info,
+ value = nzb[info]
+ )
+ rls.info.append(rls_info)
+ db.commit()
+
+
+ for nzb in sorted_results:
+ successful = fireEvent('download', data = nzb, movie = movie, single = True)
+
+ if successful:
+ log.info('Downloading of %s successful.' % nzb.get('name'))
+
+ # Mark release as snatched
+ db = get_session()
+ rls = db.query(Release).filter_by(identifier = md5(nzb['url'])).first()
+ rls.status_id = snatched_status.get('id')
+ db.commit()
+
+ # Mark movie snatched if quality is finish-checked
+ if type['finish']:
+ mvie = db.query(Movie).filter_by(id = movie['id']).first()
+ mvie.status_id = snatched_status.get('id')
+ db.commit()
+
return True
+
+ return False
else:
log.info('Better quality (%s) already available or snatched for %s' % (type['quality']['label'], default_title))
break
diff --git a/couchpotato/environment.py b/couchpotato/environment.py
index 067ec4b..cb789a3 100644
--- a/couchpotato/environment.py
+++ b/couchpotato/environment.py
@@ -19,6 +19,7 @@ class Env:
_data_dir = ""
_cache_dir = ""
_db_path = ""
+ _log_path = ""
@staticmethod
def doDebug():
diff --git a/couchpotato/static/scripts/page/wanted.js b/couchpotato/static/scripts/page/wanted.js
index eda8a67..3ba0f2b 100644
--- a/couchpotato/static/scripts/page/wanted.js
+++ b/couchpotato/static/scripts/page/wanted.js
@@ -9,226 +9,239 @@ Page.Wanted = new Class({
var self = this;
if(!self.list){
- self.list = new MovieList({
+
+ // Wanted movies
+ self.wanted = new MovieList({
'status': 'active',
- 'actions': Wanted.Action
+ 'actions': WantedActions
});
- $(self.list).inject(self.el);
-
- App.addEvent('library.update', self.list.update.bind(self.list))
+ $(self.wanted).inject(self.el);
+ App.addEvent('library.update', self.wanted.update.bind(self.wanted));
+
+ // Snatched movies
+ self.snatched = new MovieList({
+ 'status': 'snatched',
+ 'actions': SnatchedActions
+ });
+ $(self.snatched).inject(self.el);
+ App.addEvent('library.update', self.snatched.update.bind(self.snatched));
}
}
});
-var Wanted = {
- 'Action': {
- 'IMBD': IMDBAction
- //,'releases': ReleaseAction
- }
-}
-
-Wanted.Action.Edit = new Class({
-
- Extends: MovieAction,
-
- create: function(){
- var self = this;
-
- self.el = new Element('a.edit', {
- 'title': 'Refresh the movie info and do a forced search',
- 'events': {
- 'click': self.editMovie.bind(self)
+var WantedActions = {
+ 'IMBD': IMDBAction
+ //,'releases': ReleaseAction
+
+ ,'Edit': new Class({
+
+ Extends: MovieAction,
+
+ create: function(){
+ var self = this;
+
+ self.el = new Element('a.edit', {
+ 'title': 'Refresh the movie info and do a forced search',
+ 'events': {
+ 'click': self.editMovie.bind(self)
+ }
+ });
+
+ },
+
+ editMovie: function(e){
+ var self = this;
+ (e).stop();
+
+ if(!self.options_container){
+ self.options_container = new Element('div.options').adopt(
+ $(self.movie.thumbnail).clone(),
+ new Element('div.form', {
+ 'styles': {
+ 'line-height': self.movie.getHeight()
+ }
+ }).adopt(
+ self.title_select = new Element('select', {
+ 'name': 'title'
+ }),
+ self.profile_select = new Element('select', {
+ 'name': 'profile'
+ }),
+ new Element('a.button.edit', {
+ 'text': 'Save',
+ 'events': {
+ 'click': self.save.bind(self)
+ }
+ })
+ )
+ ).inject(self.movie, 'top');
+
+ Array.each(self.movie.data.library.titles, function(alt){
+ new Element('option', {
+ 'text': alt.title
+ }).inject(self.title_select);
+ });
+
+ Object.each(Quality.profiles, function(profile){
+ new Element('option', {
+ 'value': profile.id ? profile.id : profile.data.id,
+ 'text': profile.label ? profile.label : profile.data.label
+ }).inject(self.profile_select);
+ self.profile_select.set('value', self.movie.profile.get('id'));
+ });
+
}
- });
-
- },
-
- editMovie: function(e){
- var self = this;
- (e).stop();
-
- if(!self.options_container){
- self.options_container = new Element('div.options').adopt(
- $(self.movie.thumbnail).clone(),
- new Element('div.form', {
+ self.movie.slide('in');
+ },
+
+ save: function(e){
+ (e).stop();
+ var self = this;
+
+ Api.request('movie.edit', {
+ 'data': {
+ 'id': self.movie.get('id'),
+ 'default_title': self.title_select.get('value'),
+ 'profile_id': self.profile_select.get('value')
+ },
+ 'useSpinner': true,
+ 'spinnerTarget': $(self.movie),
+ 'onComplete': function(){
+ self.movie.quality.set('text', self.profile_select.getSelected()[0].get('text'));
+ self.movie.title.set('text', self.title_select.getSelected()[0].get('text'));
+ }
+ });
+
+ self.movie.slide('out');
+ }
+
+ })
+
+ ,'Refresh': new Class({
+
+ Extends: MovieAction,
+
+ create: function(){
+ var self = this;
+
+ self.el = new Element('a.refresh', {
+ 'title': 'Refresh the movie info and do a forced search',
+ 'events': {
+ 'click': self.doSearch.bind(self)
+ }
+ });
+
+ },
+
+ doSearch: function(e){
+ var self = this;
+ (e).stop();
+
+ Api.request('movie.refresh', {
+ 'data': {
+ 'id': self.movie.get('id')
+ }
+ });
+ }
+
+ })
+
+ ,'Delete': new Class({
+
+ Extends: MovieAction,
+
+ Implements: [Chain],
+
+ create: function(){
+ var self = this;
+
+ self.el = new Element('a.delete', {
+ 'title': 'Remove the movie from your wanted list',
+ 'events': {
+ 'click': self.showConfirm.bind(self)
+ }
+ });
+
+ },
+
+ showConfirm: function(e){
+ var self = this;
+ (e).stop();
+
+ if(!self.delete_container){
+ self.delete_container = new Element('div.delete_container', {
'styles': {
'line-height': self.movie.getHeight()
}
}).adopt(
- self.title_select = new Element('select', {
- 'name': 'title'
+ new Element('a.cancel', {
+ 'text': 'Cancel',
+ 'events': {
+ 'click': self.hideConfirm.bind(self)
+ }
}),
- self.profile_select = new Element('select', {
- 'name': 'profile'
+ new Element('span.or', {
+ 'text': 'or'
}),
- new Element('a.button.edit', {
- 'text': 'Save',
+ new Element('a.button.delete', {
+ 'text': 'Delete ' + self.movie.title.get('text'),
'events': {
- 'click': self.save.bind(self)
+ 'click': self.del.bind(self)
}
})
- )
- ).inject(self.movie, 'top');
-
- Array.each(self.movie.data.library.titles, function(alt){
- new Element('option', {
- 'text': alt.title
- }).inject(self.title_select)
- });
-
- Object.each(Quality.profiles, function(profile){
- new Element('option', {
- 'value': profile.id ? profile.id : profile.data.id,
- 'text': profile.label ? profile.label : profile.data.label
- }).inject(self.profile_select);
- self.profile_select.set('value', self.movie.profile.get('id'));
- });
-
- }
- self.movie.slide('in');
- },
-
- save: function(e){
- (e).stop();
- var self = this;
-
- Api.request('movie.edit', {
- 'data': {
- 'id': self.movie.get('id'),
- 'default_title': self.title_select.get('value'),
- 'profile_id': self.profile_select.get('value')
- },
- 'useSpinner': true,
- 'spinnerTarget': $(self.movie),
- 'onComplete': function(){
- self.movie.quality.set('text', self.profile_select.getSelected()[0].get('text'))
- self.movie.title.set('text', self.title_select.getSelected()[0].get('text'))
+ ).inject(self.movie, 'top');
}
- });
-
- self.movie.slide('out');
- }
-
-})
-
-Wanted.Action.Refresh = new Class({
-
- Extends: MovieAction,
-
- create: function(){
- var self = this;
-
- self.el = new Element('a.refresh', {
- 'title': 'Refresh the movie info and do a forced search',
- 'events': {
- 'click': self.doSearch.bind(self)
- }
- });
-
- },
-
- doSearch: function(e){
- var self = this;
- (e).stop();
-
- Api.request('movie.refresh', {
- 'data': {
- 'id': self.movie.get('id')
- }
- })
- }
-
-})
-
-Wanted.Action.Delete = new Class({
-
- Extends: MovieAction,
-
- Implements: [Chain],
-
- create: function(){
- var self = this;
-
- self.el = new Element('a.delete', {
- 'title': 'Remove the movie from your wanted list',
- 'events': {
- 'click': self.showConfirm.bind(self)
- }
- });
-
- },
-
- showConfirm: function(e){
- var self = this;
- (e).stop();
-
- if(!self.delete_container){
- self.delete_container = new Element('div.delete_container', {
- 'styles': {
- 'line-height': self.movie.getHeight()
+
+ self.movie.slide('in');
+
+ },
+
+ hideConfirm: function(e){
+ var self = this;
+ (e).stop();
+
+ self.movie.slide('out');
+ },
+
+ del: function(e){
+ (e).stop();
+ var self = this;
+
+ var movie = $(self.movie);
+
+ self.chain(
+ function(){
+ $(movie).mask().addClass('loading');
+ self.callChain();
+ },
+ function(){
+ Api.request('movie.delete', {
+ 'data': {
+ 'id': self.movie.get('id')
+ },
+ 'onComplete': function(){
+ movie.set('tween', {
+ 'onComplete': function(){
+ movie.destroy();
+ }
+ });
+ movie.tween('height', 0);
+ }
+ });
}
- }).adopt(
- new Element('a.cancel', {
- 'text': 'Cancel',
- 'events': {
- 'click': self.hideConfirm.bind(self)
- }
- }),
- new Element('span.or', {
- 'text': 'or'
- }),
- new Element('a.button.delete', {
- 'text': 'Delete ' + self.movie.title.get('text'),
- 'events': {
- 'click': self.del.bind(self)
- }
- })
- ).inject(self.movie, 'top')
+ );
+
+ self.callChain();
+
}
- self.movie.slide('in');
-
- },
-
- hideConfirm: function(e){
- var self = this;
- (e).stop();
-
- self.movie.slide('out');
- },
-
- del: function(e){
- (e).stop()
- var self = this;
-
- var movie = $(self.movie);
-
- self.chain(
- function(){
- $(movie).mask().addClass('loading')
- self.callChain();
- },
- function(){
- Api.request('movie.delete', {
- 'data': {
- 'id': self.movie.get('id')
- },
- 'onComplete': function(){
- movie.set('tween', {
- 'onComplete': function(){
- movie.destroy();
- }
- })
- movie.tween('height', 0)
- }
- })
- }
- );
-
- self.callChain();
-
- }
+ })
+};
-})
\ No newline at end of file
+var SnatchedActions = {
+ 'IMBD': IMDBAction
+ ,'Releases': ReleaseAction
+ ,'Delete': WantedActions.Delete
+};
\ No newline at end of file
diff --git a/couchpotato/templates/_desktop.html b/couchpotato/templates/_desktop.html
index 454a3af..fe9b0c9 100644
--- a/couchpotato/templates/_desktop.html
+++ b/couchpotato/templates/_desktop.html
@@ -31,10 +31,10 @@
-
-
-
+
+