1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-04 15:12:23 -05:00

Change improve Add Show/Add Trending Show page.

Fix white screen of death when trying to add a show that is already in library by replacing "Add Show" button with "In library".
Add show sorting options.
Add handler for when Trakt returns no results.
Fix image links when anchor child images are not found at Trakt.
Add image to be used when Trakt posters are void.
This commit is contained in:
JackDandy 2014-11-06 04:55:43 +00:00
parent 7f379b1356
commit 46cd85299e
5 changed files with 582 additions and 495 deletions

View File

@ -1,4 +1,4 @@
### 0.x.x (2014-11-05 xx:xx:xx UTC)
### 0.x.x (2014-11-07 xx:xx:xx UTC)
* Add Bootstrap for UI features
* Change UI to resize fluidly on different display sizes, fixes the issue where top menu items would disappear on smaller screens
@ -42,6 +42,11 @@
* Made all init scripts executable
* Fix invalid responses when using sickbeard.searchtvdb api command
* Fixes unicode issues during searches on newznab providers when rid mapping occur
* Fix white screen of death when trying to add a show that is already in library on Add Show/Add Trending Show page
* Add show sorting options to Add Show/Add Trending Show page
* Add handler for when Trakt returns no results for Add Show/Add Trending Show page
* Fix image links when anchor child images are not found at Trakt on Add Show/Add Trending Show page
* Add image to be used when Trakt posters are void on Add Show/Add Trending Show page
[develop changelog]
* Change improve display of progress bars in the Downloads columns of the show list page

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -4,35 +4,74 @@
#from sickbeard.common import *
#from sickbeard import sbdatetime
#set global $title="Trending Shows"
#set global $header="Trending Shows"
#set global $title='Trending Shows'
#set global $header='Trending Shows'
#set global $sbPath=".."
#set global $sbPath='..'
#set global $topmenu="comingEpisodes"
#set global $topmenu='comingEpisodes'
#import os.path
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_top.tmpl")
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl')
<script type="text/javascript" src="$sbRoot/js/plotTooltip.js?$sbPID"></script>
<script type="text/javascript" charset="utf-8">
<!--
\$(document).ready(function(){
var \$container = [\$('#container'), \$('#container-anime')];
jQuery.each(\$container, function (j) {
\$(document).ready(function(){
// initialise combos for dirty page refreshes
\$('#showsort').val('original');
\$('#showsortdirection').val('asc');
var \$container = [\$('#container')];
jQuery.each(\$container, function (j) {
this.isotope({
itemSelector: '.trakt_show',
layoutMode: 'masonry',
masonry: {
columnWidth: 12,
isFitWidth: true
}
});
});
itemSelector: '.trakt_show',
sortBy: 'original-order',
layoutMode: 'fitRows',
getSortData: {
name: function( itemElem ) {
var name = \$( itemElem ).attr('data-name') || '';
#if not $sickbeard.SORT_ARTICLE:
name = name.replace(/^(The|A|An)\s/i, '');
#end if
return name.toLowerCase();
},
rating: '[data-rating] parseInt',
votes: '[data-votes] parseInt',
}
});
});
\$('#showsort').on( 'change', function() {
var sortCriteria;
switch (this.value) {
case 'original':
sortCriteria = 'original-order'
break;
case 'rating':
/* randomise, else the rating_votes can already
* have sorted leaving this with nothing to do.
*/
\$('#container').isotope({sortBy: 'random'});
sortCriteria = 'rating';
break;
case 'rating_votes':
sortCriteria = ['rating', 'votes'];
break;
case 'votes':
sortCriteria = 'votes';
break;
default:
sortCriteria = 'name'
break;
}
\$('#container').isotope({sortBy: sortCriteria});
});
\$('#showsortdirection').on( 'change', function() {
\$('#container').isotope({sortAscending: ('asc' == this.value)});
});
});
//-->
@ -40,44 +79,74 @@
#if $varExists('header')
<h1 class="header">$header</h1>
#else
#else
<h1 class="title">$title</h1>
#end if
#if $trending_shows
<div class="pull-right" style="margin-top: -40px;">
<span>Sort By:</span>
<select id="showsort" class="form-control form-control-inline input-sm">
<option value="name">Name</option>
<option value="original" selected="selected">Original</option>
<option value="votes">Votes</option>
<option value="rating">% Rating</option>
<option value="rating_votes">% Rating > Votes</option>
</select>
<span style="margin-left:12px">Sort Order:</span>
<select id="showsortdirection" class="form-control form-control-inline input-sm">
<option value="asc" selected="selected">Asc</option>
<option value="desc">Desc</option>
</select>
</div>
#end if
<div id="container">
#if None is $trending_shows
<div class="trakt_show" style="width:100%; margin-top:20px">
<p class="red-text">Trakt API did not return results, this can happen from time to time.
<br /><br />This view should auto refresh every 10 mins.</p>
</div>
#else
#for $cur_show in $trending_shows:
#set $image = re.sub(r"(.*)(\..*?)$", r"\1-300\2", $cur_show["images"]["poster"], 0, re.IGNORECASE | re.MULTILINE)
<div class="trakt_show">
#set $image = re.sub(r'(.*)(\..*?)$', r'\1-300\2', $cur_show['images']['poster'], 0, re.IGNORECASE | re.MULTILINE)
<div class="trakt_show" data-name="$cur_show['title']" data-rating="$cur_show['ratings']['percentage']" data-votes="$cur_show['ratings']['votes']">
<div class="traktContainer">
<div class="trakt-image">
<a href="${cur_show["url"]}" target="_blank"><img alt="" class="trakt-image" src="${image}" /></a>
<a class="trakt-image" href="${cur_show['url']}" target="_blank"><img alt="" class="trakt-image" src="${image}" /></a>
</div>
<div class="show-title">
$cur_show["title"]
<%= (cur_show['title'], '<span>&nbsp;</span>')[ '' == cur_show['title']] %>
</div>
<div class="clearfix">
<p>$cur_show["ratings"]["percentage"]% <img src="$sbRoot/images/heart.png"></p>
<i>$cur_show["ratings"]["votes"] votes</i>
<p>$cur_show['ratings']['percentage']% <img src="$sbRoot/images/heart.png"></p>
<i>$cur_show['ratings']['votes'] votes</i>
<div class="traktShowTitleIcons">
<a href="$sbRoot/home/addTraktShow?indexer_id=${cur_show["tvdb_id"]}&amp;showName=${cur_show["title"]}" class="btn btn-xs">Add Show</a>
#if 'ExistsInLibrary' in $cur_show['tvdb_id']:
<p style="line-height: 1.5; padding: 2px 5px 3px">In library</p>
#else
<a href="$sbRoot/home/addTraktShow?indexer_id=${cur_show['tvdb_id']}&amp;showName=${cur_show['title']}" class="btn btn-xs">Add Show</a>
#end if
</div>
</div>
</div>
</div>
#end for
#end if
</div>
<script type="text/javascript" charset="utf-8">
<!--
window.setInterval( "location.reload(true)", 600000); // Refresh every 10 minutes
window.setInterval('location.reload(true)', 600000); // Refresh every 10 minutes
//-->
</script>
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_bottom.tmpl")
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl')

View File

@ -340,7 +340,7 @@ class MainHandler(RequestHandler):
def setComingEpsSort(self, sort):
if sort not in ('date', 'network', 'show'):
sort = 'date'
if sickbeard.COMING_EPS_LAYOUT == 'calendar':
sort = 'date'
@ -486,7 +486,7 @@ class MainHandler(RequestHandler):
episode['description'].splitlines()[0] + '\r\n'
else:
ical = ical + 'DESCRIPTION:' + (show['airs'] or '(Unknown airs)') + ' on ' + (show['network'] or 'Unknown network') + '\r\n'
ical = ical + 'END:VEVENT\r\n'
# Ending the iCal
@ -1984,25 +1984,25 @@ class ConfigProviders(MainHandler):
'''
error = ""
success = False
if not name:
error += "\nNo Provider Name specified"
error += "\nNo Provider Name specified"
if not url:
error += "\nNo Provider Url specified"
if not key:
error += "\nNo Provider Api key specified"
if error <> "":
return json.dumps({'success' : False, 'error': error})
#Get list with Newznabproviders
#Get list with Newznabproviders
#providerDict = dict(zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
#Get newznabprovider obj with provided name
tempProvider= newznab.NewznabProvider(name, url, key)
success, tv_categories, error = tempProvider.get_newznab_categories()
return json.dumps({'success' : success,'tv_categories' : tv_categories, 'error' : error})
def deleteNewznabProvider(self, nnid):
@ -2109,13 +2109,13 @@ class ConfigProviders(MainHandler):
newznabProviderDict[cur_id].name = cur_name
newznabProviderDict[cur_id].url = cur_url
newznabProviderDict[cur_id].key = cur_key
newznabProviderDict[cur_id].catIDs = cur_cat
newznabProviderDict[cur_id].catIDs = cur_cat
# a 0 in the key spot indicates that no key is needed
if cur_key == '0':
newznabProviderDict[cur_id].needs_auth = False
else:
newznabProviderDict[cur_id].needs_auth = True
try:
newznabProviderDict[cur_id].search_mode = str(kwargs[cur_id + '_search_mode']).strip()
except:
@ -2989,6 +2989,11 @@ class NewHomeAddShows(MainHandler):
t.trending_shows = TraktCall("shows/trending.json/%API%", sickbeard.TRAKT_API_KEY)
if None is not t.trending_shows:
for item in t.trending_shows:
if helpers.findCertainShow(sickbeard.showList, int(item['tvdb_id'])):
item['tvdb_id'] = u'ExistsInLibrary'
return _munge(t)
def existingShows(self, *args, **kwargs):
@ -4372,9 +4377,9 @@ class Home(MainHandler):
root_ep_obj.rename()
redirect("/home/displayShow?show=" + show)
def searchEpisode(self, show=None, season=None, episode=None):
# retrieve the episode object and fail if we can't get one
ep_obj = _getEpisode(show, season, episode)
if isinstance(ep_obj, str):
@ -4384,7 +4389,7 @@ class Home(MainHandler):
ep_queue_item = search_queue.ManualSearchQueueItem(ep_obj.show, ep_obj)
sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) # @UndefinedVariable
if ep_queue_item.success:
return returnManualSearchResult(ep_queue_item)
if not ep_queue_item.started and ep_queue_item.success is None:
@ -4403,35 +4408,35 @@ class Home(MainHandler):
currentManualSearchThreadsQueued = []
currentManualSearchThreadActive = []
finishedManualSearchThreadItems= []
# Queued Searches
currentManualSearchThreadsQueued = sickbeard.searchQueueScheduler.action.get_all_ep_from_queue(show)
# Running Searches
if (sickbeard.searchQueueScheduler.action.is_manualsearch_in_progress()):
currentManualSearchThreadActive = sickbeard.searchQueueScheduler.action.currentItem
# Finished Searches
finishedManualSearchThreadItems = sickbeard.search_queue.MANUAL_SEARCH_HISTORY
if currentManualSearchThreadsQueued:
for searchThread in currentManualSearchThreadsQueued:
searchstatus = 'queued'
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
episodes.append({'episode': searchThread.segment.episode,
'episodeindexid': searchThread.segment.indexerid,
'season' : searchThread.segment.season,
'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status],
'episodeindexid': searchThread.segment.indexerid,
'season' : searchThread.segment.season,
'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status],
'quality': self.getQualityClass(searchThread.segment)})
else:
for epObj in searchThread.segment:
episodes.append({'episode': epObj.episode,
'episodeindexid': epObj.indexerid,
'season' : epObj.season,
'searchstatus' : searchstatus,
'status' : statusStrings[epObj.status],
'season' : epObj.season,
'searchstatus' : searchstatus,
'status' : statusStrings[epObj.status],
'quality': self.getQualityClass(epObj)})
if currentManualSearchThreadActive:
searchThread = currentManualSearchThreadActive
searchstatus = 'searching'
@ -4441,11 +4446,11 @@ class Home(MainHandler):
searchstatus = 'searching'
episodes.append({'episode': searchThread.segment.episode,
'episodeindexid': searchThread.segment.indexerid,
'season' : searchThread.segment.season,
'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status],
'season' : searchThread.segment.season,
'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status],
'quality': self.getQualityClass(searchThread.segment)})
if finishedManualSearchThreadItems:
for searchThread in finishedManualSearchThreadItems:
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
@ -4453,9 +4458,9 @@ class Home(MainHandler):
searchstatus = 'finished'
episodes.append({'episode': searchThread.segment.episode,
'episodeindexid': searchThread.segment.indexerid,
'season' : searchThread.segment.season,
'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status],
'season' : searchThread.segment.season,
'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status],
'quality': self.getQualityClass(searchThread.segment)})
else:
### These are only Failed Downloads/Retry SearchThreadItems.. lets loop through the segement/episodes
@ -4465,18 +4470,18 @@ class Home(MainHandler):
searchstatus = 'finished'
episodes.append({'episode': epObj.episode,
'episodeindexid': epObj.indexerid,
'season' : epObj.season,
'searchstatus' : searchstatus,
'status' : statusStrings[epObj.status],
'season' : epObj.season,
'searchstatus' : searchstatus,
'status' : statusStrings[epObj.status],
'quality': self.getQualityClass(epObj)})
return json.dumps({'show': show, 'episodes' : episodes})
#return json.dumps()
def getQualityClass(self, ep_obj):
# return the correct json value
# Find the quality class for the episode
quality_class = Quality.qualityStrings[Quality.UNKNOWN]
ep_status, ep_quality = Quality.splitCompositeStatus(ep_obj.status)
@ -4605,7 +4610,7 @@ class Home(MainHandler):
return json.dumps({'result': 'success'})
else:
return json.dumps({'result': 'failure'})
class UI(MainHandler):
def add_message(self):