Browse Source

Starting simple, removed non working pages for now

pull/51/merge
Ruud 14 years ago
parent
commit
aa24e3e249
  1. 2
      couchpotato/cli.py
  2. 6
      couchpotato/core/plugins/movie/main.py
  3. 23
      couchpotato/core/plugins/movie/static/list.js
  4. 1
      couchpotato/core/plugins/movie/static/movie.js
  5. 54
      couchpotato/core/plugins/searcher/main.py
  6. 1
      couchpotato/environment.py
  7. 413
      couchpotato/static/scripts/page/wanted.js
  8. 6
      couchpotato/templates/_desktop.html

2
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)

6
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': {}}
})

23
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){

1
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)

54
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

1
couchpotato/environment.py

@ -19,6 +19,7 @@ class Env:
_data_dir = ""
_cache_dir = ""
_db_path = ""
_log_path = ""
@staticmethod
def doDebug():

413
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();
}
})
};
})
var SnatchedActions = {
'IMBD': IMDBAction
,'Releases': ReleaseAction
,'Delete': WantedActions.Delete
};

6
couchpotato/templates/_desktop.html

@ -31,10 +31,10 @@
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page.js') }}"></script>
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/wanted.js') }}"></script>
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/settings.js') }}"></script>
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/log.js') }}"></script>
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/soon.js') }}"></script>
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/manage.js') }}"></script>
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/settings.js') }}"></script>
<!--<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/soon.js') }}"></script>
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/manage.js') }}"></script>-->
<link href="{{ url_for('.static', filename='images/favicon.ico') }}" rel="icon" type="image/x-icon" />
<link rel="apple-touch-icon" href="{{ url_for('.static', filename='images/homescreen.png') }}" />

Loading…
Cancel
Save