mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-02 17:33:37 +00:00
Merge branch 'feature/AddShowMoreToSearch' into develop
This commit is contained in:
commit
fd7587c2d3
7 changed files with 91 additions and 38 deletions
|
@ -16,6 +16,10 @@
|
|||
* Change site services tester to fallback to http if error with SSL
|
||||
* Change try to use folder name when filename does not contain show name
|
||||
* Change force redirects in TVMaze API to be https
|
||||
* Add display first 20 results with link to display more
|
||||
* Add search results sort by Z to A
|
||||
* Add search results sort by newest aired
|
||||
* Add search results sort by oldest aired
|
||||
|
||||
|
||||
[develop changelog]
|
||||
|
|
|
@ -330,7 +330,7 @@ home_newShow.tmpl
|
|||
border:0
|
||||
}
|
||||
|
||||
.step-one #searchResults .alt{
|
||||
.step-one #search-results .alt{
|
||||
background-color:rgb(40, 40, 40)
|
||||
}
|
||||
|
||||
|
@ -1418,7 +1418,7 @@ div.stepsguide .step p{
|
|||
color:#ccc
|
||||
}
|
||||
|
||||
.stepDiv #searchResults div .exists-db{
|
||||
.stepDiv #search-results div .exists-db{
|
||||
color:#1178B3
|
||||
}
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ home_newShow.tmpl
|
|||
border-color:#dfdede
|
||||
}
|
||||
|
||||
.step-one #searchResults .alt{
|
||||
.step-one #search-results .alt{
|
||||
background-color:rgb(245, 245, 245)
|
||||
}
|
||||
|
||||
|
@ -1384,7 +1384,7 @@ div.stepsguide .disabledstep p{
|
|||
color:#8a775e
|
||||
}
|
||||
|
||||
.stepDiv #searchResults div .exists-db{
|
||||
.stepDiv #search-results div .exists-db{
|
||||
color:#1178B3
|
||||
}
|
||||
|
||||
|
|
|
@ -1138,7 +1138,7 @@ div.formpaginate{
|
|||
border:1px solid
|
||||
}
|
||||
|
||||
#searchResults input[type="radio"]{
|
||||
#search-results input[type="radio"]{
|
||||
vertical-align:-2px
|
||||
}
|
||||
|
||||
|
@ -1174,21 +1174,21 @@ div.formpaginate{
|
|||
margin-left:10px
|
||||
}
|
||||
|
||||
.stepDiv #searchResults .results-item{
|
||||
.stepDiv #search-results .results-item{
|
||||
width:100%;
|
||||
line-height:1.7
|
||||
}
|
||||
|
||||
.stepDiv #searchResults .results-item input[disabled=disabled]{
|
||||
.stepDiv #search-results .results-item input[disabled=disabled]{
|
||||
visibility:hidden
|
||||
}
|
||||
|
||||
.stepDiv #searchResults .results-item .exists-db{
|
||||
.stepDiv #search-results .results-item .exists-db{
|
||||
font-weight:800;
|
||||
font-style:italic
|
||||
}
|
||||
|
||||
.stepDiv #searchResults #searchingAnim{
|
||||
.stepDiv #search-results #searchingAnim{
|
||||
margin-right:6px
|
||||
}
|
||||
|
||||
|
@ -4377,7 +4377,7 @@ fieldset.sectionwrap{
|
|||
border-width:0
|
||||
}
|
||||
|
||||
.step-one #searchResults legend.legendStep{
|
||||
.step-one #search-results legend.legendStep{
|
||||
margin-top:10px
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,9 @@
|
|||
<br>
|
||||
<p style="margin:5px 0 15px"><span class="add-tip">Enter show name, TVDB ID, IMDb Url, or IMDb ID. </span><b>*</b>SickGear supports english, language is used for show/episode data</p>
|
||||
|
||||
<div id="searchResults" style="height: 100%"></div>
|
||||
<div id="search-results" style="height: 100%"></div>
|
||||
<div id="more-results" style="display:none"><a href="#">More results...</a></div>
|
||||
<div id="search-results-buffer" style="display:none"></div>
|
||||
#end if
|
||||
|
||||
</div>
|
||||
|
|
|
@ -57,7 +57,7 @@ $(document).ready(function () {
|
|||
tvsrcName = elTvDatabase.find('option:selected').text(),
|
||||
tvSearchSrc = 0 < tvsrcName.length ? ' on ' + tvsrcName : '';
|
||||
|
||||
$('#searchResults').empty().html('<img id="searchingAnim" src="' + sbRoot + '/images/loading32' + themeSpinner + '.gif" height="32" width="32" />'
|
||||
$('#search-results').empty().html('<img id="searchingAnim" src="' + sbRoot + '/images/loading32' + themeSpinner + '.gif" height="32" width="32" />'
|
||||
+ ' searching <span class="boldest">' + cleanseText(elNameToSearch.val(), !0) + '</span>'
|
||||
+ tvSearchSrc + ' in ' + elIndexerLang.val()
|
||||
+ '...');
|
||||
|
@ -72,17 +72,18 @@ $(document).ready(function () {
|
|||
timeout: parseInt($('#indexer_timeout').val(), 10) * parseInt($('#indexer_count').val(), 2) * 1000 + 15000,
|
||||
dataType: 'json',
|
||||
error: function () {
|
||||
$('#searchResults').empty().html('search timed out, try again or try another database');
|
||||
$('#search-results').empty().html('search timed out, try again in a few mins.');
|
||||
},
|
||||
success: function (data) {
|
||||
var resultStr = '', attrs = '', checked = !1, rowType, row = 0, srcState = '';
|
||||
var resultStr = '', attrs = '', checked = !1, rowType, row = 0, srcState = '',
|
||||
resultItem, resultStrBuffer = '', nBufferSize = 20, nBuffer = 0, nAll = 0;
|
||||
|
||||
if (0 === data.results.length) {
|
||||
if (null === data.results || 0 === data.results.length) {
|
||||
resultStr += '<span class="boldest">Sorry, no results found. Try a different search.</span>';
|
||||
} else {
|
||||
var result = {
|
||||
SrcName: 0, isInDB: 1, SrcId: 2, SrcDBId: 3, SrcUrl: 4, ShowID: 5, Title: 6, TitleHtml: 7,
|
||||
Aired: 8, Network: 9, Genre: 10, Overview: 11, RelSort: 12, DateSort: 13, AzSort: 14, ImgUrl: 15
|
||||
Aired: 8, Network: 9, Genre: 10, Overview: 11, RelSort: 12, NewestAired: 13, OldestAired: 14, AzSort: 15 , ZaSort: 16, ImgUrl: 17
|
||||
};
|
||||
$.each(data.results, function (index, item) {
|
||||
attrs = (!1 !== item[result.isInDB] ? ' disabled="disabled"' : (!0 === checked ? '' : ' checked'));
|
||||
|
@ -104,7 +105,7 @@ $(document).ready(function () {
|
|||
null === item[result.SrcName] ? '' : item[result.SrcName],
|
||||
!1 === item[result.isInDB] ? '' : '<span class="exists-db"><a href="' + sbRoot + item[result.isInDB] + '" target="_blank">exists in db</a></span>']
|
||||
.join(' - ').replace(/(^[\s-]+|[\s-]+$)/, '');
|
||||
resultStr += '<div class="results-item' + rowType + '" data-indb="' + (!1 === item[result.isInDB] ? '' : '1') + '" data-sort-rel="' + item[result.RelSort] + '" data-sort-date="' + item[result.DateSort] + '" data-sort-az="' + item[result.AzSort] + '">'
|
||||
resultItem = '<div class="results-item' + rowType + '" data-indb="' + (!1 === item[result.isInDB] ? '' : '1') + '" data-sort-rel="' + item[result.RelSort] + '" data-sort-newest="' + item[result.NewestAired] + '" data-sort-oldest="' + item[result.OldestAired] + '" data-sort-az="' + item[result.AzSort] + '" data-sort-za="' + item[result.ZaSort] + '">'
|
||||
+ '<input id="whichSeries" type="radio"'
|
||||
+ ' class="stepone-result-radio"'
|
||||
+ (!1 === item[result.isInDB]
|
||||
|
@ -130,23 +131,32 @@ $(document).ready(function () {
|
|||
+ ('' === srcState ? ''
|
||||
: ' <span class="stepone-result-db grey-text">' + '[' + srcState + ']' + '</span>')
|
||||
+ '</div>' + "\n";
|
||||
|
||||
if (nBuffer < nBufferSize || item[result.isInDB]) {
|
||||
resultStr += resultItem;
|
||||
if (!1 === item[result.isInDB])
|
||||
nBuffer++;
|
||||
} else {
|
||||
resultStrBuffer += resultItem;
|
||||
}
|
||||
nAll++;
|
||||
});
|
||||
}
|
||||
var selAttr = 'selected="selected" ',
|
||||
selClass = 'selected-text',
|
||||
classAttrSel = 'class="' + selClass + '" ',
|
||||
defSortby = /^az/.test(config.resultsSortby) || /^date/.test(config.resultsSortby) ? '': classAttrSel + selAttr;
|
||||
useBuffer = nBufferSize < nAll,
|
||||
defSortby = /^az/.test(config.resultsSortby) || /^za/.test(config.resultsSortby) || /^newest/.test(config.resultsSortby) || /^oldest/.test(config.resultsSortby) ? '': classAttrSel + selAttr;
|
||||
|
||||
$('#searchResults').html(
|
||||
$('#search-results').html(
|
||||
'<fieldset>' + "\n" + '<legend class="legendStep" style="margin-bottom: 15px">'
|
||||
+ (0 < row ? row : 'No')
|
||||
+ ' search result' + (1 == row ? '' : 's') + '...'
|
||||
+ '<span id="count"></span>'
|
||||
+ '<span style="float:right;height:32px;line-height:1">'
|
||||
+ '<select id="results-sortby" class="form-control form-control-inline input-sm">'
|
||||
+ '<optgroup label="Sort by">'
|
||||
+ '<option ' + (/^az/.test(config.resultsSortby) ? classAttrSel + selAttr : '') + 'value="az">A to Z</option>'
|
||||
+ '<option ' + (/^date/.test(config.resultsSortby) ? classAttrSel + selAttr : '') + 'value="date">First aired</option>'
|
||||
+ '<option ' + (/^za/.test(config.resultsSortby) ? classAttrSel + selAttr : '') + 'value="za">Z to A</option>'
|
||||
+ '<option ' + (/^newest/.test(config.resultsSortby) ? classAttrSel + selAttr : '') + 'value="newest">Newest aired</option>'
|
||||
+ '<option ' + (/^oldest/.test(config.resultsSortby) ? classAttrSel + selAttr : '') + 'value="oldest">Oldest aired</option>'
|
||||
+ '<option ' + defSortby + 'value="rel">Relevancy</option>'
|
||||
+ '</optgroup><optgroup label="With...">'
|
||||
+ '<option ' + (!/notop$/.test(config.resultsSortby) ? classAttrSel : '') + 'value="ontop">Exists on top</option>'
|
||||
|
@ -159,6 +169,25 @@ $(document).ready(function () {
|
|||
+ '</fieldset>'
|
||||
);
|
||||
|
||||
if (useBuffer) {
|
||||
$('#search-results-buffer').html(resultStrBuffer);
|
||||
$('#more-results').show();
|
||||
$('#more-results a').on('click', function(e, d) {
|
||||
e.preventDefault();
|
||||
$('#more-results').hide();
|
||||
$('#search-results #count').text(nAll + ' search result' + (1 === nAll ? '' : 's') + '...');
|
||||
$('#search-results-buffer .results-item').appendTo('#holder');
|
||||
container$.isotope( 'reloadItems' ).isotope(
|
||||
{sortBy: $('#results-sortby').find('option:not([value$="top"]).selected-text').val()});
|
||||
myform.loadsection(0);
|
||||
});
|
||||
$('#search-results #count').text((nBuffer + ' / ' + nAll)
|
||||
+ ' search result' + (1 === nBuffer ? '' : 's') + '...');
|
||||
} else {
|
||||
$('#search-results #count').text((0 < nBuffer ? nBuffer + (useBuffer ? ' / ' + nAll : '') : 'No')
|
||||
+ ' search result' + (1 === nAll ? '' : 's') + '...');
|
||||
}
|
||||
|
||||
var container$ = $('#holder'),
|
||||
sortbySelect$ = $('#results-sortby'),
|
||||
reOrder = (function(value){
|
||||
|
@ -180,7 +209,9 @@ $(document).ready(function () {
|
|||
layoutMode: 'masonry',
|
||||
getSortData: {
|
||||
az: function(itemElem){ return getData(itemElem, 'az'); },
|
||||
date: function(itemElem){ return getData(itemElem, 'date'); },
|
||||
za: function(itemElem){ return getData(itemElem, 'za'); },
|
||||
newest: function(itemElem){ return getData(itemElem, 'newest'); },
|
||||
oldest: function(itemElem){ return getData(itemElem, 'oldest'); },
|
||||
rel: function(itemElem){ return getData(itemElem, 'rel'); }
|
||||
}
|
||||
}).on('arrangeComplete', function(event, items){
|
||||
|
@ -362,7 +393,7 @@ $(document).ready(function () {
|
|||
|
||||
$('#rootDirText').change(updateSampleText);
|
||||
|
||||
$('#searchResults').on('click', '.stepone-result-radio', updateSampleText);
|
||||
$('#search-results').on('click', '.stepone-result-radio', updateSampleText);
|
||||
|
||||
elNameToSearch.keyup(function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
|
|
|
@ -3176,7 +3176,7 @@ class NewHomeAddShows(Home):
|
|||
re.sub(r'([,.!][^,.!]*?)$', '...',
|
||||
re.sub(r'([.!?])(?=\w)', r'\1 ',
|
||||
self.encode_html((show.get('overview', '') or '')[:250:].strip()))),
|
||||
self.get_UWRatio(term, show['seriesname'], show.get('aliases', [])), None, None,
|
||||
self.get_UWRatio(term, show['seriesname'], show.get('aliases', [])), None, None, None, None,
|
||||
self._make_search_image_url(iid, show)
|
||||
] for show in shows.itervalues()] for iid, shows in results.iteritems()))
|
||||
|
||||
|
@ -3186,22 +3186,34 @@ class NewHomeAddShows(Home):
|
|||
x[sortby_index] = n + (1000, 0)[x[idx_is_indb] and 'notop' not in sickbeard.RESULTS_SORTBY]
|
||||
return data if not final_sort else sorted(data, reverse=False, key=lambda x: x[sortby_index])
|
||||
|
||||
def sort_date(data_result, is_last_sort):
|
||||
idx_date_sort, idx_src, idx_aired = 13, 2, 8
|
||||
def sort_newest(data_result, is_last_sort):
|
||||
return sort_date(data_result, is_last_sort, 13)
|
||||
|
||||
def sort_oldest(data_result, is_last_sort):
|
||||
return sort_date(data_result, is_last_sort, 14, False)
|
||||
|
||||
def sort_date(data_result, is_last_sort, idx_sort, reverse=True):
|
||||
idx_src, idx_aired = 2, 8
|
||||
return final_order(
|
||||
idx_date_sort,
|
||||
idx_sort,
|
||||
sorted(
|
||||
sorted(data_result, reverse=True, key=lambda x: (dateutil.parser.parse(
|
||||
sorted(data_result, reverse=reverse, key=lambda x: (dateutil.parser.parse(
|
||||
re.match('^(?:19|20)\d\d$', str(x[idx_aired])) and ('%s-12-31' % str(x[idx_aired]))
|
||||
or (x[idx_aired] and str(x[idx_aired])) or '1900'))),
|
||||
reverse=False, key=lambda x: x[idx_src]), is_last_sort)
|
||||
|
||||
def sort_az(data_result, is_last_sort):
|
||||
idx_az_sort, idx_src, idx_title = 14, 2, 6
|
||||
return sort_zaaz(data_result, is_last_sort, 15)
|
||||
|
||||
def sort_za(data_result, is_last_sort):
|
||||
return sort_zaaz(data_result, is_last_sort, 16, True)
|
||||
|
||||
def sort_zaaz(data_result, is_last_sort, idx_sort, reverse=False):
|
||||
idx_src, idx_title = 2, 6
|
||||
return final_order(
|
||||
idx_az_sort,
|
||||
idx_sort,
|
||||
sorted(
|
||||
data_result, reverse=False, key=lambda x: (
|
||||
data_result, reverse=reverse, key=lambda x: (
|
||||
x[idx_src],
|
||||
(remove_article(x[idx_title].lower()), x[idx_title].lower())[sickbeard.SORT_ARTICLE])),
|
||||
is_last_sort)
|
||||
|
@ -3215,11 +3227,15 @@ class NewHomeAddShows(Home):
|
|||
reverse=False, key=lambda x: x[idx_src]), is_last_sort)
|
||||
|
||||
if 'az' == sickbeard.RESULTS_SORTBY[:2]:
|
||||
sort_results = [sort_date, sort_rel, sort_az]
|
||||
elif 'date' == sickbeard.RESULTS_SORTBY[:4]:
|
||||
sort_results = [sort_az, sort_rel, sort_date]
|
||||
sort_results = [sort_date, sort_rel, sort_za, sort_az]
|
||||
elif 'za' == sickbeard.RESULTS_SORTBY[:2]:
|
||||
sort_results = [sort_date, sort_rel, sort_az, sort_za]
|
||||
elif 'newest' == sickbeard.RESULTS_SORTBY[:6]:
|
||||
sort_results = [sort_az, sort_rel, sort_oldest, sort_newest]
|
||||
elif 'oldest' == sickbeard.RESULTS_SORTBY[:6]:
|
||||
sort_results = [sort_az, sort_rel, sort_newest, sort_oldest]
|
||||
else:
|
||||
sort_results = [sort_az, sort_date, sort_rel]
|
||||
sort_results = [sort_za, sort_az, sort_oldest, sort_newest, sort_rel]
|
||||
|
||||
for n, func in enumerate(sort_results):
|
||||
final_results = func(final_results, n == len(sort_results) - 1)
|
||||
|
@ -5696,7 +5712,7 @@ class ConfigGeneral(Config):
|
|||
|
||||
def saveResultPrefs(self, ui_results_sortby=None):
|
||||
|
||||
if ui_results_sortby in ('az', 'date', 'rel', 'notop', 'ontop'):
|
||||
if ui_results_sortby in ('az', 'za', 'newest', 'oldest', 'rel', 'notop', 'ontop'):
|
||||
was_ontop = 'notop' not in sickbeard.RESULTS_SORTBY
|
||||
if 'top' == ui_results_sortby[-3:]:
|
||||
maybe_ontop = ('', ' notop')[was_ontop]
|
||||
|
|
Loading…
Reference in a new issue