Add force full search options to wanted list
This commit is contained in:
@@ -534,5 +534,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.movies .alph_nav .more_menu > a {
|
.movies .alph_nav .more_menu > a {
|
||||||
background-position: center -157px;
|
background-position: center -158px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from couchpotato import get_session
|
from couchpotato import get_session
|
||||||
from couchpotato.api import addApiView
|
from couchpotato.api import addApiView
|
||||||
from couchpotato.core.event import addEvent, fireEvent
|
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
|
||||||
from couchpotato.core.helpers.encoding import simplifyString, toUnicode
|
from couchpotato.core.helpers.encoding import simplifyString, toUnicode
|
||||||
from couchpotato.core.helpers.request import jsonified, getParam
|
from couchpotato.core.helpers.request import jsonified, getParam
|
||||||
from couchpotato.core.helpers.variable import md5, getTitle
|
from couchpotato.core.helpers.variable import md5, getTitle
|
||||||
@@ -36,9 +36,35 @@ class Searcher(Plugin):
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
addApiView('searcher.full_search', self.allMoviesView, docs = {
|
||||||
|
'desc': 'Starts a full search for all wanted movies',
|
||||||
|
})
|
||||||
|
|
||||||
|
addApiView('searcher.progress', self.getProgress, docs = {
|
||||||
|
'desc': 'Get the progress of current full search',
|
||||||
|
})
|
||||||
|
|
||||||
# Schedule cronjob
|
# Schedule cronjob
|
||||||
fireEvent('schedule.cron', 'searcher.all', self.allMovies, day = self.conf('cron_day'), hour = self.conf('cron_hour'), minute = self.conf('cron_minute'))
|
fireEvent('schedule.cron', 'searcher.all', self.allMovies, day = self.conf('cron_day'), hour = self.conf('cron_hour'), minute = self.conf('cron_minute'))
|
||||||
|
|
||||||
|
def allMoviesView(self):
|
||||||
|
|
||||||
|
in_progress = self.in_progress
|
||||||
|
if not in_progress:
|
||||||
|
fireEventAsync('searcher.all')
|
||||||
|
fireEvent('notify.frontend', type = 'searcher.started', data = True, message = 'Full search started')
|
||||||
|
else:
|
||||||
|
fireEvent('notify.frontend', type = 'searcher.already_started', data = True, message = 'Full search already in progress')
|
||||||
|
|
||||||
|
return jsonified({
|
||||||
|
'success': not in_progress
|
||||||
|
})
|
||||||
|
|
||||||
|
def getProgress(self):
|
||||||
|
|
||||||
|
return jsonified({
|
||||||
|
'progress': self.in_progress
|
||||||
|
})
|
||||||
|
|
||||||
def allMovies(self):
|
def allMovies(self):
|
||||||
|
|
||||||
@@ -54,6 +80,11 @@ class Searcher(Plugin):
|
|||||||
Movie.status.has(identifier = 'active')
|
Movie.status.has(identifier = 'active')
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
|
self.in_progress = {
|
||||||
|
'total': len(movies),
|
||||||
|
'to_go': len(movies),
|
||||||
|
}
|
||||||
|
|
||||||
for movie in movies:
|
for movie in movies:
|
||||||
movie_dict = movie.to_dict({
|
movie_dict = movie.to_dict({
|
||||||
'profile': {'types': {'quality': {}}},
|
'profile': {'types': {'quality': {}}},
|
||||||
@@ -70,6 +101,9 @@ class Searcher(Plugin):
|
|||||||
except:
|
except:
|
||||||
log.error('Search failed for %s: %s', (movie_dict['library']['identifier'], traceback.format_exc()))
|
log.error('Search failed for %s: %s', (movie_dict['library']['identifier'], traceback.format_exc()))
|
||||||
|
|
||||||
|
self.in_progress['to_go'] -= 1
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
# Break if CP wants to shut down
|
# Break if CP wants to shut down
|
||||||
if self.shuttingDown():
|
if self.shuttingDown():
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -10,16 +10,63 @@ Page.Wanted = new Class({
|
|||||||
|
|
||||||
if(!self.wanted){
|
if(!self.wanted){
|
||||||
|
|
||||||
|
self.manual_search = new Element('a', {
|
||||||
|
'title': 'Force a search for the full wanted list',
|
||||||
|
'text': 'Search all wanted',
|
||||||
|
'events':{
|
||||||
|
'click': self.doFullSearch.bind(self, true)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Wanted movies
|
// Wanted movies
|
||||||
self.wanted = new MovieList({
|
self.wanted = new MovieList({
|
||||||
'identifier': 'wanted',
|
'identifier': 'wanted',
|
||||||
'status': 'active',
|
'status': 'active',
|
||||||
'actions': MovieActions,
|
'actions': MovieActions,
|
||||||
'add_new': true
|
'add_new': true,
|
||||||
|
'menu': [self.manual_search]
|
||||||
});
|
});
|
||||||
$(self.wanted).inject(self.el);
|
$(self.wanted).inject(self.el);
|
||||||
|
|
||||||
|
// Check if search is in progress
|
||||||
|
self.startProgressInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
doFullSearch: function(full){
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
if(!self.search_in_progress){
|
||||||
|
|
||||||
|
Api.request('searcher.full_search');
|
||||||
|
self.startProgressInterval();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
startProgressInterval: function(){
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
var start_text = self.manual_search.get('text');
|
||||||
|
self.progress_interval = setInterval(function(){
|
||||||
|
Api.request('searcher.progress', {
|
||||||
|
'onComplete': function(json){
|
||||||
|
self.search_in_progress = true;
|
||||||
|
if(!json.progress){
|
||||||
|
clearInterval(self.progress_interval);
|
||||||
|
self.search_in_progress = false;
|
||||||
|
self.manual_search.set('text', start_text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var progress = json.progress;
|
||||||
|
self.manual_search.set('text', 'Searching.. (' + (((progress.total-progress.to_go)/progress.total)*100).round() + '%)');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user