mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-02 17:33:37 +00:00
Fix manual search button on displayShow and episode view page.
Change feedback result of manual search on the clicked button image/tooltip. Devel: Change items from search to retry with Archived status on displayShow page. Change keep manual/failed search item progress for 30 mins in internal manual_search_history. Fix buttons for snatched statuses. Change set wantedquality list for failed to True (needed to also search for previously skipped and similar status items). Change make get_queued_manual() and get_current_manualsearch_item() thread-safe. Change only return retrystatus true to ui if use_failed_downloads is enabled. Change add multi-ep snatches to ajax response.
This commit is contained in:
parent
03fa11aac6
commit
1d00b0e4c2
6 changed files with 185 additions and 57 deletions
|
@ -1,7 +1,7 @@
|
||||||
#import datetime
|
#import datetime
|
||||||
#import sickbeard
|
#import sickbeard
|
||||||
#from sickbeard import network_timezones, sbdatetime, subtitles
|
#from sickbeard import network_timezones, sbdatetime, subtitles
|
||||||
#from sickbeard.common import Overview, Quality, statusStrings, ARCHIVED, UNAIRED, SUBTITLED
|
#from sickbeard.common import Overview, Quality, statusStrings, ARCHIVED, UNAIRED, SUBTITLED, SNATCHED_ANY, DOWNLOADED
|
||||||
#from lib import subliminal
|
#from lib import subliminal
|
||||||
<% def sg_var(varname, default=False): return getattr(sickbeard, varname, default) %>#slurp#
|
<% def sg_var(varname, default=False): return getattr(sickbeard, varname, default) %>#slurp#
|
||||||
<% def sg_str(varname, default=''): return getattr(sickbeard, varname, default) %>#slurp#
|
<% def sg_str(varname, default=''): return getattr(sickbeard, varname, default) %>#slurp#
|
||||||
|
@ -107,7 +107,8 @@
|
||||||
#end if
|
#end if
|
||||||
<td class="col-search">
|
<td class="col-search">
|
||||||
#if 0 != int($ep['season'])
|
#if 0 != int($ep['season'])
|
||||||
#if (int($ep['status']) in $Quality.SNATCHED or int($ep['status']) in $Quality.DOWNLOADED) and $sg_var('USE_FAILED_DOWNLOADS')
|
#set $status = $Quality.splitCompositeStatus(int($ep['status']))[0]
|
||||||
|
#if ($status in $SNATCHED_ANY + [$DOWNLOADED, $ARCHIVED]) and $sg_var('USE_FAILED_DOWNLOADS')
|
||||||
<a class="epRetry" id="$ep_str" name="$ep_str" href="$sbRoot/home/retryEpisode?show=$show.indexerid&season=$ep['season']&episode=$ep['episode']"><img src="$sbRoot/images/search16.png" height="16" alt="retry" title="Retry download"></a>
|
<a class="epRetry" id="$ep_str" name="$ep_str" href="$sbRoot/home/retryEpisode?show=$show.indexerid&season=$ep['season']&episode=$ep['episode']"><img src="$sbRoot/images/search16.png" height="16" alt="retry" title="Retry download"></a>
|
||||||
#else
|
#else
|
||||||
<a class="epSearch" id="$ep_str" name="$ep_str" href="$sbRoot/home/searchEpisode?show=$show.indexerid&season=$ep['season']&episode=$ep['episode']"><img src="$sbRoot/images/search16.png" width="16" height="16" alt="search" title="Manual search"></a>
|
<a class="epSearch" id="$ep_str" name="$ep_str" href="$sbRoot/home/searchEpisode?show=$show.indexerid&season=$ep['season']&episode=$ep['episode']"><img src="$sbRoot/images/search16.png" width="16" height="16" alt="search" title="Manual search"></a>
|
||||||
|
|
|
@ -47,7 +47,7 @@ function updateImages(data) {
|
||||||
if (ep.searchstatus == 'searching') {
|
if (ep.searchstatus == 'searching') {
|
||||||
//el=$('td#' + ep.season + 'x' + ep.episode + '.search img');
|
//el=$('td#' + ep.season + 'x' + ep.episode + '.search img');
|
||||||
img.attr('title','Searching');
|
img.attr('title','Searching');
|
||||||
img.attr('alt','earching');
|
img.prop('alt','searching');
|
||||||
img.attr('src',sbRoot+'/images/' + loadingImage);
|
img.attr('src',sbRoot+'/images/' + loadingImage);
|
||||||
disableLink(el);
|
disableLink(el);
|
||||||
// Update Status and Quality
|
// Update Status and Quality
|
||||||
|
@ -58,20 +58,31 @@ function updateImages(data) {
|
||||||
else if (ep.searchstatus == 'queued') {
|
else if (ep.searchstatus == 'queued') {
|
||||||
//el=$('td#' + ep.season + 'x' + ep.episode + '.search img');
|
//el=$('td#' + ep.season + 'x' + ep.episode + '.search img');
|
||||||
img.attr('title','Queued');
|
img.attr('title','Queued');
|
||||||
img.attr('alt','queued');
|
img.prop('alt','queued');
|
||||||
img.attr('src',sbRoot+'/images/' + queuedImage );
|
img.attr('src',sbRoot+'/images/' + queuedImage );
|
||||||
disableLink(el);
|
disableLink(el);
|
||||||
HtmlContent = ep.searchstatus;
|
HtmlContent = ep.searchstatus;
|
||||||
}
|
}
|
||||||
else if (ep.searchstatus == 'finished') {
|
else if (ep.searchstatus == 'finished') {
|
||||||
//el=$('td#' + ep.season + 'x' + ep.episode + '.search img');
|
//el=$('td#' + ep.season + 'x' + ep.episode + '.search img');
|
||||||
img.attr('title','Searching');
|
imgparent=img.parent();
|
||||||
img.attr('alt','searching');
|
if (ep.retrystatus) {
|
||||||
if (ep.retrystatus) {img.parent().attr('class','epRetry');} else {img.parent().attr('class','epSearch');}
|
imgparent.attr('class','epRetry');
|
||||||
|
imgparent.attr('href', imgparent.attr('href').replace('/home/searchEpisode?', '/home/retryEpisode?'));
|
||||||
|
img.attr('title','Retry download');
|
||||||
|
img.prop('alt', 'retry download');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
imgparent.attr('class','epSearch');
|
||||||
|
imgparent.attr('href', imgparent.attr('href').replace('/home/retryEpisode?', '/home/searchEpisode?'));
|
||||||
|
img.attr('title','Manual search');
|
||||||
|
img.prop('alt', 'manual search');
|
||||||
|
}
|
||||||
img.attr('src',sbRoot+'/images/' + searchImage);
|
img.attr('src',sbRoot+'/images/' + searchImage);
|
||||||
enableLink(el);
|
enableLink(el);
|
||||||
|
|
||||||
// Update Status and Quality
|
// Update Status and Quality
|
||||||
|
parent.closest('tr').removeClass('skipped wanted qual good unaired snatched').addClass(ep.statusoverview);
|
||||||
var rSearchTerm = /(\w+)\s\((.+?)\)/;
|
var rSearchTerm = /(\w+)\s\((.+?)\)/;
|
||||||
HtmlContent = ep.status.replace(rSearchTerm,"$1"+' <span class="quality '+ep.quality+'">'+"$2"+'</span>');
|
HtmlContent = ep.status.replace(rSearchTerm,"$1"+' <span class="quality '+ep.quality+'">'+"$2"+'</span>');
|
||||||
|
|
||||||
|
@ -140,7 +151,7 @@ function disableLink(el) {
|
||||||
// Create var for img under anchor and set options for the loading gif
|
// Create var for img under anchor and set options for the loading gif
|
||||||
img=$(this).children('img');
|
img=$(this).children('img');
|
||||||
img.attr('title','loading');
|
img.attr('title','loading');
|
||||||
img.attr('alt','');
|
img.prop('alt','');
|
||||||
img.attr('src',sbRoot+'/images/' + options.loadingImage);
|
img.attr('src',sbRoot+'/images/' + options.loadingImage);
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,7 +180,7 @@ function disableLink(el) {
|
||||||
|
|
||||||
// put the corresponding image as the result of queuing of the manual search
|
// put the corresponding image as the result of queuing of the manual search
|
||||||
img.attr('title',img_result);
|
img.attr('title',img_result);
|
||||||
img.attr('alt',img_result);
|
img.prop('alt',img_result);
|
||||||
img.attr('height', options.size);
|
img.attr('height', options.size);
|
||||||
img.attr('src',sbRoot+"/images/"+img_name);
|
img.attr('src',sbRoot+"/images/"+img_name);
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import threading
|
import threading
|
||||||
|
import copy
|
||||||
|
|
||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ class GenericQueue(object):
|
||||||
self.currentItem.name = self.queue_name + '-' + self.currentItem.name
|
self.currentItem.name = self.queue_name + '-' + self.currentItem.name
|
||||||
self.currentItem.start()
|
self.currentItem.start()
|
||||||
|
|
||||||
|
|
||||||
class QueueItem(threading.Thread):
|
class QueueItem(threading.Thread):
|
||||||
def __init__(self, name, action_id=0):
|
def __init__(self, name, action_id=0):
|
||||||
super(QueueItem, self).__init__()
|
super(QueueItem, self).__init__()
|
||||||
|
@ -109,6 +111,24 @@ class QueueItem(threading.Thread):
|
||||||
self.stop = threading.Event()
|
self.stop = threading.Event()
|
||||||
self.added = None
|
self.added = None
|
||||||
|
|
||||||
|
def copy(self, deepcopy_obj=None):
|
||||||
|
"""
|
||||||
|
Returns a shallow copy of QueueItem with optional deepcopises of in deepcopy_obj listed objects
|
||||||
|
:param deepcopy_obj: List of properties to be deepcopied
|
||||||
|
:type deepcopy_obj: list
|
||||||
|
:return: return QueueItem
|
||||||
|
:rtype: QueueItem
|
||||||
|
"""
|
||||||
|
cls = self.__class__
|
||||||
|
result = cls.__new__(cls)
|
||||||
|
result.__dict__.update(self.__dict__)
|
||||||
|
if deepcopy_obj:
|
||||||
|
for o in deepcopy_obj:
|
||||||
|
if self.__dict__.get(o):
|
||||||
|
new_seg = copy.deepcopy(self.__dict__.get(o))
|
||||||
|
result.__dict__[o] = new_seg
|
||||||
|
return result
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Implementing classes should call this"""
|
"""Implementing classes should call this"""
|
||||||
|
|
||||||
|
|
|
@ -70,12 +70,18 @@ class SearchQueue(generic_queue.GenericQueue):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_all_ep_from_queue(self, show):
|
def get_all_ep_from_queue(self, show):
|
||||||
|
"""
|
||||||
|
Returns False or List of copies of all show related items in manual or failed queue
|
||||||
|
:param show: indexerid
|
||||||
|
:type show: str
|
||||||
|
:return: False or List of copies of all show related items in manual or failed queue
|
||||||
|
"""
|
||||||
with self.lock:
|
with self.lock:
|
||||||
ep_obj_list = []
|
ep_obj_list = []
|
||||||
for cur_item in self.queue:
|
for cur_item in self.queue:
|
||||||
if (isinstance(cur_item, (ManualSearchQueueItem, FailedQueueItem)) and
|
if (isinstance(cur_item, (ManualSearchQueueItem, FailedQueueItem)) and
|
||||||
show == str(cur_item.show.indexerid)):
|
show == str(cur_item.show.indexerid)):
|
||||||
ep_obj_list.append(cur_item)
|
ep_obj_list.append(cur_item.copy())
|
||||||
|
|
||||||
if ep_obj_list:
|
if ep_obj_list:
|
||||||
return ep_obj_list
|
return ep_obj_list
|
||||||
|
@ -101,6 +107,18 @@ class SearchQueue(generic_queue.GenericQueue):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_current_manualsearch_item(self, show):
|
||||||
|
"""
|
||||||
|
Returns a static copy of the current item
|
||||||
|
:param show: indexerid
|
||||||
|
:type show: str
|
||||||
|
:return: copy of ManualSearchQueueItem or FailedQueueItem or None
|
||||||
|
"""
|
||||||
|
with self.lock:
|
||||||
|
if self.currentItem and isinstance(self.currentItem, (ManualSearchQueueItem, FailedQueueItem)) \
|
||||||
|
and show == str(self.currentItem.show.indexerid):
|
||||||
|
return self.currentItem.copy()
|
||||||
|
|
||||||
def is_manualsearch_in_progress(self):
|
def is_manualsearch_in_progress(self):
|
||||||
# Only referenced in webserve.py, only current running manualsearch or failedsearch is needed!!
|
# Only referenced in webserve.py, only current running manualsearch or failedsearch is needed!!
|
||||||
return self._is_in_progress((ManualSearchQueueItem, FailedQueueItem))
|
return self._is_in_progress((ManualSearchQueueItem, FailedQueueItem))
|
||||||
|
@ -188,6 +206,7 @@ class RecentSearchQueueItem(generic_queue.QueueItem):
|
||||||
self.success = None
|
self.success = None
|
||||||
self.episodes = []
|
self.episodes = []
|
||||||
generic_queue.QueueItem.__init__(self, 'Recent Search', RECENT_SEARCH)
|
generic_queue.QueueItem.__init__(self, 'Recent Search', RECENT_SEARCH)
|
||||||
|
self.snatched_eps = {}
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
generic_queue.QueueItem.run(self)
|
generic_queue.QueueItem.run(self)
|
||||||
|
@ -243,6 +262,10 @@ class RecentSearchQueueItem(generic_queue.QueueItem):
|
||||||
# just use the first result for now
|
# just use the first result for now
|
||||||
logger.log(u'Downloading %s from %s' % (result.name, result.provider.name))
|
logger.log(u'Downloading %s from %s' % (result.name, result.provider.name))
|
||||||
self.success = search.snatch_episode(result)
|
self.success = search.snatch_episode(result)
|
||||||
|
if self.success:
|
||||||
|
for ep in result.episodes:
|
||||||
|
self.snatched_eps.update({'%sx%s' % (ep.season, ep.episode):
|
||||||
|
{'season': ep.season, 'episode': ep.episode}})
|
||||||
|
|
||||||
helpers.cpu_sleep()
|
helpers.cpu_sleep()
|
||||||
|
|
||||||
|
@ -400,6 +423,13 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
|
||||||
self.show = show
|
self.show = show
|
||||||
self.segment = segment
|
self.segment = segment
|
||||||
self.started = None
|
self.started = None
|
||||||
|
self.snatched_eps = {}
|
||||||
|
|
||||||
|
def copy(self, deepcopy_obj=None):
|
||||||
|
if not isinstance(deepcopy_obj, list):
|
||||||
|
deepcopy_obj = []
|
||||||
|
deepcopy_obj += ['segment', 'show']
|
||||||
|
return super(ManualSearchQueueItem, self).copy(deepcopy_obj)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
generic_queue.QueueItem.run(self)
|
generic_queue.QueueItem.run(self)
|
||||||
|
@ -417,6 +447,9 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
|
||||||
# just use the first result for now
|
# just use the first result for now
|
||||||
logger.log(u'Downloading %s from %s' % (search_result[0].name, search_result[0].provider.name))
|
logger.log(u'Downloading %s from %s' % (search_result[0].name, search_result[0].provider.name))
|
||||||
self.success = search.snatch_episode(search_result[0])
|
self.success = search.snatch_episode(search_result[0])
|
||||||
|
for ep in search_result[0].episodes:
|
||||||
|
self.snatched_eps.update({'%sx%s' % (ep.season, ep.episode):
|
||||||
|
{'season': ep.season, 'episode': ep.episode}})
|
||||||
|
|
||||||
helpers.cpu_sleep()
|
helpers.cpu_sleep()
|
||||||
|
|
||||||
|
@ -451,6 +484,13 @@ class BacklogQueueItem(generic_queue.QueueItem):
|
||||||
self.limited_backlog = limited_backlog
|
self.limited_backlog = limited_backlog
|
||||||
self.forced = forced
|
self.forced = forced
|
||||||
self.torrent_only = torrent_only
|
self.torrent_only = torrent_only
|
||||||
|
self.snatched_eps = {}
|
||||||
|
|
||||||
|
def copy(self, deepcopy_obj=None):
|
||||||
|
if not isinstance(deepcopy_obj, list):
|
||||||
|
deepcopy_obj = []
|
||||||
|
deepcopy_obj += ['segment', 'show']
|
||||||
|
return super(BacklogQueueItem, self).copy(deepcopy_obj)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
generic_queue.QueueItem.run(self)
|
generic_queue.QueueItem.run(self)
|
||||||
|
@ -472,7 +512,10 @@ class BacklogQueueItem(generic_queue.QueueItem):
|
||||||
for result in search_result:
|
for result in search_result:
|
||||||
# just use the first result for now
|
# just use the first result for now
|
||||||
logger.log(u'Downloading %s from %s' % (result.name, result.provider.name))
|
logger.log(u'Downloading %s from %s' % (result.name, result.provider.name))
|
||||||
search.snatch_episode(result)
|
if search.snatch_episode(result):
|
||||||
|
for ep in result.episodes:
|
||||||
|
self.snatched_eps.update({'%sx%s' % (ep.season, ep.episode):
|
||||||
|
{'season': ep.season, 'episode': ep.episode}})
|
||||||
|
|
||||||
helpers.cpu_sleep()
|
helpers.cpu_sleep()
|
||||||
else:
|
else:
|
||||||
|
@ -495,6 +538,13 @@ class FailedQueueItem(generic_queue.QueueItem):
|
||||||
self.segment = segment
|
self.segment = segment
|
||||||
self.success = None
|
self.success = None
|
||||||
self.started = None
|
self.started = None
|
||||||
|
self.snatched_eps = {}
|
||||||
|
|
||||||
|
def copy(self, deepcopy_obj=None):
|
||||||
|
if not isinstance(deepcopy_obj, list):
|
||||||
|
deepcopy_obj = []
|
||||||
|
deepcopy_obj += ['segment', 'show']
|
||||||
|
return super(FailedQueueItem, self).copy(deepcopy_obj)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
generic_queue.QueueItem.run(self)
|
generic_queue.QueueItem.run(self)
|
||||||
|
@ -515,7 +565,7 @@ class FailedQueueItem(generic_queue.QueueItem):
|
||||||
|
|
||||||
logger.log(u'Beginning failed download search for: [%s]' % ep_obj.prettyName())
|
logger.log(u'Beginning failed download search for: [%s]' % ep_obj.prettyName())
|
||||||
|
|
||||||
set_wanted_aired(ep_obj, True, ep_count, ep_count_scene)
|
set_wanted_aired(ep_obj, True, ep_count, ep_count_scene, manual=True)
|
||||||
|
|
||||||
search_result = search.search_providers(self.show, self.segment, True, try_other_searches=True)
|
search_result = search.search_providers(self.show, self.segment, True, try_other_searches=True)
|
||||||
|
|
||||||
|
@ -523,7 +573,10 @@ class FailedQueueItem(generic_queue.QueueItem):
|
||||||
for result in search_result:
|
for result in search_result:
|
||||||
# just use the first result for now
|
# just use the first result for now
|
||||||
logger.log(u'Downloading %s from %s' % (result.name, result.provider.name))
|
logger.log(u'Downloading %s from %s' % (result.name, result.provider.name))
|
||||||
search.snatch_episode(result)
|
if search.snatch_episode(result):
|
||||||
|
for ep in result.episodes:
|
||||||
|
self.snatched_eps.update({'%sx%s' % (ep.season, ep.episode):
|
||||||
|
{'season': ep.season, 'episode': ep.episode}})
|
||||||
|
|
||||||
helpers.cpu_sleep()
|
helpers.cpu_sleep()
|
||||||
else:
|
else:
|
||||||
|
@ -543,6 +596,17 @@ class FailedQueueItem(generic_queue.QueueItem):
|
||||||
|
|
||||||
|
|
||||||
def fifo(my_list, item, max_size=100):
|
def fifo(my_list, item, max_size=100):
|
||||||
|
remove_old_fifo(my_list)
|
||||||
|
item.added_dt = datetime.datetime.now()
|
||||||
if len(my_list) >= max_size:
|
if len(my_list) >= max_size:
|
||||||
my_list.pop(0)
|
my_list.pop(0)
|
||||||
my_list.append(item)
|
my_list.append(item)
|
||||||
|
|
||||||
|
|
||||||
|
def remove_old_fifo(my_list, age=datetime.timedelta(minutes=30)):
|
||||||
|
try:
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
my_list[:] = [i for i in my_list if not isinstance(getattr(i, 'added_dt', None), datetime.datetime)
|
||||||
|
or now - i.added_dt < age]
|
||||||
|
except (StandardError, Exception):
|
||||||
|
pass
|
||||||
|
|
|
@ -85,6 +85,12 @@ class ShowUpdater:
|
||||||
logger.log('image cache cleanup error', logger.ERROR)
|
logger.log('image cache cleanup error', logger.ERROR)
|
||||||
logger.log(traceback.format_exc(), logger.ERROR)
|
logger.log(traceback.format_exc(), logger.ERROR)
|
||||||
|
|
||||||
|
# cleanup manual search history
|
||||||
|
try:
|
||||||
|
sickbeard.search_queue.remove_old_fifo(sickbeard.search_queue.MANUAL_SEARCH_HISTORY)
|
||||||
|
except (StandardError, Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
# add missing mapped ids
|
# add missing mapped ids
|
||||||
if not sickbeard.background_mapping_task.is_alive():
|
if not sickbeard.background_mapping_task.is_alive():
|
||||||
logger.log(u'Updating the Indexer mappings')
|
logger.log(u'Updating the Indexer mappings')
|
||||||
|
|
|
@ -2777,8 +2777,8 @@ class Home(MainHandler):
|
||||||
|
|
||||||
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
|
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
|
||||||
|
|
||||||
if ep_queue_item.success:
|
#if ep_queue_item.success:
|
||||||
return returnManualSearchResult(ep_queue_item)
|
# return returnManualSearchResult(ep_queue_item)
|
||||||
if not ep_queue_item.started and ep_queue_item.success is None:
|
if not ep_queue_item.started and ep_queue_item.success is None:
|
||||||
return json.dumps({'result': 'success'}) #I Actually want to call it queued, because the search hasnt been started yet!
|
return json.dumps({'result': 'success'}) #I Actually want to call it queued, because the search hasnt been started yet!
|
||||||
if ep_queue_item.started and ep_queue_item.success is None:
|
if ep_queue_item.started and ep_queue_item.success is None:
|
||||||
|
@ -2792,6 +2792,7 @@ class Home(MainHandler):
|
||||||
def getManualSearchStatus(self, show=None, season=None):
|
def getManualSearchStatus(self, show=None, season=None):
|
||||||
|
|
||||||
episodes = []
|
episodes = []
|
||||||
|
eps_list = set()
|
||||||
currentManualSearchThreadsQueued = []
|
currentManualSearchThreadsQueued = []
|
||||||
currentManualSearchThreadActive = []
|
currentManualSearchThreadActive = []
|
||||||
finishedManualSearchThreadItems= []
|
finishedManualSearchThreadItems= []
|
||||||
|
@ -2799,83 +2800,108 @@ class Home(MainHandler):
|
||||||
# Queued Searches
|
# Queued Searches
|
||||||
currentManualSearchThreadsQueued = sickbeard.searchQueueScheduler.action.get_all_ep_from_queue(show)
|
currentManualSearchThreadsQueued = sickbeard.searchQueueScheduler.action.get_all_ep_from_queue(show)
|
||||||
# Running Searches
|
# Running Searches
|
||||||
if (sickbeard.searchQueueScheduler.action.is_manualsearch_in_progress()):
|
currentManualSearchThreadActive = sickbeard.searchQueueScheduler.action.get_current_manualsearch_item(show)
|
||||||
currentManualSearchThreadActive = sickbeard.searchQueueScheduler.action.currentItem
|
|
||||||
|
|
||||||
# Finished Searches
|
# Finished Searches
|
||||||
finishedManualSearchThreadItems = sickbeard.search_queue.MANUAL_SEARCH_HISTORY
|
sickbeard.search_queue.remove_old_fifo(sickbeard.search_queue.MANUAL_SEARCH_HISTORY)
|
||||||
|
finishedManualSearchThreadItems = sickbeard.search_queue.MANUAL_SEARCH_HISTORY
|
||||||
|
|
||||||
if currentManualSearchThreadsQueued:
|
if currentManualSearchThreadsQueued:
|
||||||
for searchThread in currentManualSearchThreadsQueued:
|
for searchThread in currentManualSearchThreadsQueued:
|
||||||
searchstatus = 'queued'
|
searchstatus = 'queued'
|
||||||
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
|
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
|
||||||
|
eps_list.add('%sx%s' % (searchThread.segment.season, searchThread.segment.episode))
|
||||||
episodes.append({'episode': searchThread.segment.episode,
|
episodes.append({'episode': searchThread.segment.episode,
|
||||||
'episodeindexid': searchThread.segment.indexerid,
|
'showindexer': searchThread.show.indexer,
|
||||||
'season' : searchThread.segment.season,
|
'showindexid': searchThread.show.indexerid,
|
||||||
'searchstatus' : searchstatus,
|
'season': searchThread.segment.season,
|
||||||
'status' : statusStrings[searchThread.segment.status],
|
'searchstatus': searchstatus,
|
||||||
|
'status': statusStrings[searchThread.segment.status],
|
||||||
'quality': self.getQualityClass(searchThread.segment)})
|
'quality': self.getQualityClass(searchThread.segment)})
|
||||||
elif hasattr(searchThread, 'segment'):
|
elif hasattr(searchThread, 'segment'):
|
||||||
for epObj in searchThread.segment:
|
for epObj in searchThread.segment:
|
||||||
|
eps_list.add('%sx%s' % (epObj.season, epObj.episode))
|
||||||
episodes.append({'episode': epObj.episode,
|
episodes.append({'episode': epObj.episode,
|
||||||
'episodeindexid': epObj.indexerid,
|
'showindexer': epObj.show.indexer,
|
||||||
'season' : epObj.season,
|
'showindexid': epObj.show.indexerid,
|
||||||
'searchstatus' : searchstatus,
|
'season': epObj.season,
|
||||||
'status' : statusStrings[epObj.status],
|
'searchstatus': searchstatus,
|
||||||
'quality': self.getQualityClass(epObj)})
|
'status': statusStrings[epObj.status],
|
||||||
|
'quality': self.getQualityClass(epObj)})
|
||||||
|
|
||||||
retry_statues = SNATCHED_ANY + [DOWNLOADED, ARCHIVED]
|
retry_statues = SNATCHED_ANY + [DOWNLOADED, ARCHIVED]
|
||||||
if currentManualSearchThreadActive:
|
if currentManualSearchThreadActive:
|
||||||
searchThread = currentManualSearchThreadActive
|
searchThread = currentManualSearchThreadActive
|
||||||
searchstatus = 'searching'
|
|
||||||
if searchThread.success:
|
if searchThread.success:
|
||||||
searchstatus = 'finished'
|
searchstatus = 'finished'
|
||||||
else:
|
else:
|
||||||
searchstatus = 'searching'
|
searchstatus = 'searching'
|
||||||
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
|
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
|
||||||
|
eps_list.add('%sx%s' % (searchThread.segment.season, searchThread.segment.episode))
|
||||||
episodes.append({'episode': searchThread.segment.episode,
|
episodes.append({'episode': searchThread.segment.episode,
|
||||||
'episodeindexid': searchThread.segment.indexerid,
|
'showindexer': searchThread.show.indexer,
|
||||||
'season' : searchThread.segment.season,
|
'showindexid': searchThread.show.indexerid,
|
||||||
'searchstatus' : searchstatus,
|
'season': searchThread.segment.season,
|
||||||
'retrystatus': Quality.splitCompositeStatus(searchThread.segment.status)[0] in retry_statues,
|
'searchstatus': searchstatus,
|
||||||
'status' : statusStrings[searchThread.segment.status],
|
'retrystatus': sickbeard.USE_FAILED_DOWNLOADS and Quality.splitCompositeStatus(searchThread.segment.status)[0] in retry_statues,
|
||||||
|
'status': statusStrings[searchThread.segment.status],
|
||||||
'quality': self.getQualityClass(searchThread.segment)})
|
'quality': self.getQualityClass(searchThread.segment)})
|
||||||
elif hasattr(searchThread, 'segment'):
|
elif hasattr(searchThread, 'segment'):
|
||||||
for epObj in searchThread.segment:
|
for epObj in searchThread.segment:
|
||||||
|
eps_list.add('%sx%s' % (epObj.season, epObj.episode))
|
||||||
episodes.append({'episode': epObj.episode,
|
episodes.append({'episode': epObj.episode,
|
||||||
'episodeindexid': epObj.indexerid,
|
'showindexer': epObj.show.indexer,
|
||||||
'season' : epObj.season,
|
'showindexid': epObj.show.indexerid,
|
||||||
'searchstatus' : searchstatus,
|
'season': epObj.season,
|
||||||
'retrystatus': Quality.splitCompositeStatus(epObj.status)[0] in retry_statues,
|
'searchstatus': searchstatus,
|
||||||
'status' : statusStrings[epObj.status],
|
'retrystatus': sickbeard.USE_FAILED_DOWNLOADS and Quality.splitCompositeStatus(epObj.status)[0] in retry_statues,
|
||||||
|
'status': statusStrings[epObj.status],
|
||||||
'quality': self.getQualityClass(epObj)})
|
'quality': self.getQualityClass(epObj)})
|
||||||
|
|
||||||
if finishedManualSearchThreadItems:
|
if finishedManualSearchThreadItems:
|
||||||
|
searchstatus = 'finished'
|
||||||
for searchThread in finishedManualSearchThreadItems:
|
for searchThread in finishedManualSearchThreadItems:
|
||||||
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
|
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
|
||||||
if str(searchThread.show.indexerid) == show and not [x for x in episodes if x['episodeindexid'] == searchThread.segment.indexerid]:
|
if str(searchThread.show.indexerid) == show and '%sx%s' % (searchThread.segment.season, searchThread.segment.episode) not in eps_list:
|
||||||
searchstatus = 'finished'
|
eps_list.add('%sx%s' % (searchThread.segment.season, searchThread.segment.episode))
|
||||||
episodes.append({'episode': searchThread.segment.episode,
|
episodes.append({'episode': searchThread.segment.episode,
|
||||||
'episodeindexid': searchThread.segment.indexerid,
|
'showindexer': searchThread.show.indexer,
|
||||||
'season' : searchThread.segment.season,
|
'showindexid': searchThread.show.indexerid,
|
||||||
'searchstatus' : searchstatus,
|
'season': searchThread.segment.season,
|
||||||
'retrystatus': Quality.splitCompositeStatus(searchThread.segment.status)[0] in retry_statues,
|
'searchstatus': searchstatus,
|
||||||
'status' : statusStrings[searchThread.segment.status],
|
'retrystatus': sickbeard.USE_FAILED_DOWNLOADS and Quality.splitCompositeStatus(searchThread.segment.status)[0] in retry_statues,
|
||||||
'quality': self.getQualityClass(searchThread.segment)})
|
'status': statusStrings[searchThread.segment.status],
|
||||||
|
'quality': self.getQualityClass(searchThread.segment),
|
||||||
|
'statusoverview': Overview.overviewStrings[searchThread.show.getOverview(searchThread.segment.status)]})
|
||||||
### These are only Failed Downloads/Retry SearchThreadItems.. lets loop through the segement/episodes
|
### These are only Failed Downloads/Retry SearchThreadItems.. lets loop through the segement/episodes
|
||||||
elif hasattr(searchThread, 'segment') and str(searchThread.show.indexerid) == show:
|
elif hasattr(searchThread, 'segment') and str(searchThread.show.indexerid) == show:
|
||||||
for epObj in searchThread.segment:
|
for epObj in searchThread.segment:
|
||||||
if not [x for x in episodes if x['episodeindexid'] == epObj.indexerid]:
|
if '%sx%s' % (epObj.season, epObj.episode) not in eps_list:
|
||||||
searchstatus = 'finished'
|
eps_list.add('%sx%s' % (epObj.season, epObj.episode))
|
||||||
episodes.append({'episode': epObj.episode,
|
episodes.append({'episode': epObj.episode,
|
||||||
'episodeindexid': epObj.indexerid,
|
'showindexer': epObj.show.indexer,
|
||||||
'season' : epObj.season,
|
'showindexid': epObj.show.indexerid,
|
||||||
'searchstatus' : searchstatus,
|
'season': epObj.season,
|
||||||
'retrystatus': Quality.splitCompositeStatus(epObj.status)[0] in retry_statues,
|
'searchstatus': searchstatus,
|
||||||
'status' : statusStrings[epObj.status],
|
'retrystatus': sickbeard.USE_FAILED_DOWNLOADS and Quality.splitCompositeStatus(epObj.status)[0] in retry_statues,
|
||||||
'quality': self.getQualityClass(epObj)})
|
'status': statusStrings[epObj.status],
|
||||||
|
'quality': self.getQualityClass(epObj),
|
||||||
|
'statusoverview': Overview.overviewStrings[searchThread.show.getOverview(epObj.status)]})
|
||||||
|
|
||||||
return json.dumps({'show': show, 'episodes' : episodes})
|
for ep in [v for k, v in searchThread.snatched_eps.iteritems() if k not in eps_list]:
|
||||||
|
ep_obj = searchThread.show.getEpisode(season=ep['season'], episode=ep['episode'])
|
||||||
|
episodes.append({'episode': ep['episode'],
|
||||||
|
'showindexer': searchThread.show.indexer,
|
||||||
|
'showindexid': searchThread.show.indexerid,
|
||||||
|
'season': ep['season'],
|
||||||
|
'searchstatus': searchstatus,
|
||||||
|
'retrystatus': sickbeard.USE_FAILED_DOWNLOADS and Quality.splitCompositeStatus(ep_obj.status)[0] in retry_statues,
|
||||||
|
'status': statusStrings[ep_obj.status],
|
||||||
|
'quality': self.getQualityClass(ep_obj),
|
||||||
|
'statusoverview': Overview.overviewStrings[searchThread.show.getOverview(ep_obj.status)]})
|
||||||
|
|
||||||
|
|
||||||
|
return json.dumps({'show': show, 'episodes': episodes})
|
||||||
|
|
||||||
#return json.dumps()
|
#return json.dumps()
|
||||||
|
|
||||||
|
@ -2936,8 +2962,8 @@ class Home(MainHandler):
|
||||||
ep_queue_item = search_queue.FailedQueueItem(ep_obj.show, [ep_obj])
|
ep_queue_item = search_queue.FailedQueueItem(ep_obj.show, [ep_obj])
|
||||||
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
|
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
|
||||||
|
|
||||||
if ep_queue_item.success:
|
#if ep_queue_item.success:
|
||||||
return returnManualSearchResult(ep_queue_item)
|
# return returnManualSearchResult(ep_queue_item)
|
||||||
if not ep_queue_item.started and ep_queue_item.success is None:
|
if not ep_queue_item.started and ep_queue_item.success is None:
|
||||||
return json.dumps({'result': 'success'}) #I Actually want to call it queued, because the search hasnt been started yet!
|
return json.dumps({'result': 'success'}) #I Actually want to call it queued, because the search hasnt been started yet!
|
||||||
if ep_queue_item.started and ep_queue_item.success is None:
|
if ep_queue_item.started and ep_queue_item.success is None:
|
||||||
|
|
Loading…
Reference in a new issue