Merge pull request #119 from JackDandy/feature/ImproveAddTrendingPage

Change improve Add Show/Add Trending Show page.
This commit is contained in:
JackDandy 2014-11-07 23:00:29 +00:00
commit a3a38f76e7
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 * 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 * 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 * Made all init scripts executable
* Fix invalid responses when using sickbeard.searchtvdb api command * Fix invalid responses when using sickbeard.searchtvdb api command
* Fixes unicode issues during searches on newznab providers when rid mapping occur * 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] [develop changelog]
* Change improve display of progress bars in the Downloads columns of the show list page * 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.common import *
#from sickbeard import sbdatetime #from sickbeard import sbdatetime
#set global $title="Trending Shows" #set global $title='Trending Shows'
#set global $header="Trending Shows" #set global $header='Trending Shows'
#set global $sbPath=".." #set global $sbPath='..'
#set global $topmenu="comingEpisodes" #set global $topmenu='comingEpisodes'
#import os.path #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" src="$sbRoot/js/plotTooltip.js?$sbPID"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
<!-- <!--
\$(document).ready(function(){ \$(document).ready(function(){
// initialise combos for dirty page refreshes
var \$container = [\$('#container'), \$('#container-anime')]; \$('#showsort').val('original');
\$('#showsortdirection').val('asc');
jQuery.each(\$container, function (j) {
var \$container = [\$('#container')];
jQuery.each(\$container, function (j) {
this.isotope({ this.isotope({
itemSelector: '.trakt_show', itemSelector: '.trakt_show',
layoutMode: 'masonry', sortBy: 'original-order',
masonry: { layoutMode: 'fitRows',
columnWidth: 12, getSortData: {
isFitWidth: true 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') #if $varExists('header')
<h1 class="header">$header</h1> <h1 class="header">$header</h1>
#else #else
<h1 class="title">$title</h1> <h1 class="title">$title</h1>
#end if #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"> <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: #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="traktContainer">
<div class="trakt-image"> <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>
<div class="show-title"> <div class="show-title">
$cur_show["title"] <%= (cur_show['title'], '<span>&nbsp;</span>')[ '' == cur_show['title']] %>
</div> </div>
<div class="clearfix"> <div class="clearfix">
<p>$cur_show["ratings"]["percentage"]% <img src="$sbRoot/images/heart.png"></p> <p>$cur_show['ratings']['percentage']% <img src="$sbRoot/images/heart.png"></p>
<i>$cur_show["ratings"]["votes"] votes</i> <i>$cur_show['ratings']['votes'] votes</i>
<div class="traktShowTitleIcons"> <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>
</div> </div>
</div> </div>
#end for #end for
#end if
</div> </div>
<script type="text/javascript" charset="utf-8"> <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> </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): def setComingEpsSort(self, sort):
if sort not in ('date', 'network', 'show'): if sort not in ('date', 'network', 'show'):
sort = 'date' sort = 'date'
if sickbeard.COMING_EPS_LAYOUT == 'calendar': if sickbeard.COMING_EPS_LAYOUT == 'calendar':
sort = 'date' sort = 'date'
@ -486,7 +486,7 @@ class MainHandler(RequestHandler):
episode['description'].splitlines()[0] + '\r\n' episode['description'].splitlines()[0] + '\r\n'
else: else:
ical = ical + 'DESCRIPTION:' + (show['airs'] or '(Unknown airs)') + ' on ' + (show['network'] or 'Unknown network') + '\r\n' ical = ical + 'DESCRIPTION:' + (show['airs'] or '(Unknown airs)') + ' on ' + (show['network'] or 'Unknown network') + '\r\n'
ical = ical + 'END:VEVENT\r\n' ical = ical + 'END:VEVENT\r\n'
# Ending the iCal # Ending the iCal
@ -1984,25 +1984,25 @@ class ConfigProviders(MainHandler):
''' '''
error = "" error = ""
success = False success = False
if not name: if not name:
error += "\nNo Provider Name specified" error += "\nNo Provider Name specified"
if not url: if not url:
error += "\nNo Provider Url specified" error += "\nNo Provider Url specified"
if not key: if not key:
error += "\nNo Provider Api key specified" error += "\nNo Provider Api key specified"
if error <> "": if error <> "":
return json.dumps({'success' : False, 'error': 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)) #providerDict = dict(zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
#Get newznabprovider obj with provided name #Get newznabprovider obj with provided name
tempProvider= newznab.NewznabProvider(name, url, key) tempProvider= newznab.NewznabProvider(name, url, key)
success, tv_categories, error = tempProvider.get_newznab_categories() success, tv_categories, error = tempProvider.get_newznab_categories()
return json.dumps({'success' : success,'tv_categories' : tv_categories, 'error' : error}) return json.dumps({'success' : success,'tv_categories' : tv_categories, 'error' : error})
def deleteNewznabProvider(self, nnid): def deleteNewznabProvider(self, nnid):
@ -2109,13 +2109,13 @@ class ConfigProviders(MainHandler):
newznabProviderDict[cur_id].name = cur_name newznabProviderDict[cur_id].name = cur_name
newznabProviderDict[cur_id].url = cur_url newznabProviderDict[cur_id].url = cur_url
newznabProviderDict[cur_id].key = cur_key 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 # a 0 in the key spot indicates that no key is needed
if cur_key == '0': if cur_key == '0':
newznabProviderDict[cur_id].needs_auth = False newznabProviderDict[cur_id].needs_auth = False
else: else:
newznabProviderDict[cur_id].needs_auth = True newznabProviderDict[cur_id].needs_auth = True
try: try:
newznabProviderDict[cur_id].search_mode = str(kwargs[cur_id + '_search_mode']).strip() newznabProviderDict[cur_id].search_mode = str(kwargs[cur_id + '_search_mode']).strip()
except: except:
@ -2989,6 +2989,11 @@ class NewHomeAddShows(MainHandler):
t.trending_shows = TraktCall("shows/trending.json/%API%", sickbeard.TRAKT_API_KEY) 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) return _munge(t)
def existingShows(self, *args, **kwargs): def existingShows(self, *args, **kwargs):
@ -4372,9 +4377,9 @@ class Home(MainHandler):
root_ep_obj.rename() root_ep_obj.rename()
redirect("/home/displayShow?show=" + show) redirect("/home/displayShow?show=" + show)
def searchEpisode(self, show=None, season=None, episode=None): def searchEpisode(self, show=None, season=None, episode=None):
# retrieve the episode object and fail if we can't get one # retrieve the episode object and fail if we can't get one
ep_obj = _getEpisode(show, season, episode) ep_obj = _getEpisode(show, season, episode)
if isinstance(ep_obj, str): if isinstance(ep_obj, str):
@ -4384,7 +4389,7 @@ class Home(MainHandler):
ep_queue_item = search_queue.ManualSearchQueueItem(ep_obj.show, ep_obj) ep_queue_item = search_queue.ManualSearchQueueItem(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:
@ -4403,35 +4408,35 @@ class Home(MainHandler):
currentManualSearchThreadsQueued = [] currentManualSearchThreadsQueued = []
currentManualSearchThreadActive = [] currentManualSearchThreadActive = []
finishedManualSearchThreadItems= [] finishedManualSearchThreadItems= []
# 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()): if (sickbeard.searchQueueScheduler.action.is_manualsearch_in_progress()):
currentManualSearchThreadActive = sickbeard.searchQueueScheduler.action.currentItem currentManualSearchThreadActive = sickbeard.searchQueueScheduler.action.currentItem
# Finished Searches # Finished Searches
finishedManualSearchThreadItems = 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):
episodes.append({'episode': searchThread.segment.episode, episodes.append({'episode': searchThread.segment.episode,
'episodeindexid': searchThread.segment.indexerid, 'episodeindexid': searchThread.segment.indexerid,
'season' : searchThread.segment.season, 'season' : searchThread.segment.season,
'searchstatus' : searchstatus, 'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status], 'status' : statusStrings[searchThread.segment.status],
'quality': self.getQualityClass(searchThread.segment)}) 'quality': self.getQualityClass(searchThread.segment)})
else: else:
for epObj in searchThread.segment: for epObj in searchThread.segment:
episodes.append({'episode': epObj.episode, episodes.append({'episode': epObj.episode,
'episodeindexid': epObj.indexerid, 'episodeindexid': epObj.indexerid,
'season' : epObj.season, 'season' : epObj.season,
'searchstatus' : searchstatus, 'searchstatus' : searchstatus,
'status' : statusStrings[epObj.status], 'status' : statusStrings[epObj.status],
'quality': self.getQualityClass(epObj)}) 'quality': self.getQualityClass(epObj)})
if currentManualSearchThreadActive: if currentManualSearchThreadActive:
searchThread = currentManualSearchThreadActive searchThread = currentManualSearchThreadActive
searchstatus = 'searching' searchstatus = 'searching'
@ -4441,11 +4446,11 @@ class Home(MainHandler):
searchstatus = 'searching' searchstatus = 'searching'
episodes.append({'episode': searchThread.segment.episode, episodes.append({'episode': searchThread.segment.episode,
'episodeindexid': searchThread.segment.indexerid, 'episodeindexid': searchThread.segment.indexerid,
'season' : searchThread.segment.season, 'season' : searchThread.segment.season,
'searchstatus' : searchstatus, 'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status], 'status' : statusStrings[searchThread.segment.status],
'quality': self.getQualityClass(searchThread.segment)}) 'quality': self.getQualityClass(searchThread.segment)})
if finishedManualSearchThreadItems: if finishedManualSearchThreadItems:
for searchThread in finishedManualSearchThreadItems: for searchThread in finishedManualSearchThreadItems:
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem): if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):
@ -4453,9 +4458,9 @@ class Home(MainHandler):
searchstatus = 'finished' searchstatus = 'finished'
episodes.append({'episode': searchThread.segment.episode, episodes.append({'episode': searchThread.segment.episode,
'episodeindexid': searchThread.segment.indexerid, 'episodeindexid': searchThread.segment.indexerid,
'season' : searchThread.segment.season, 'season' : searchThread.segment.season,
'searchstatus' : searchstatus, 'searchstatus' : searchstatus,
'status' : statusStrings[searchThread.segment.status], 'status' : statusStrings[searchThread.segment.status],
'quality': self.getQualityClass(searchThread.segment)}) 'quality': self.getQualityClass(searchThread.segment)})
else: else:
### 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
@ -4465,18 +4470,18 @@ class Home(MainHandler):
searchstatus = 'finished' searchstatus = 'finished'
episodes.append({'episode': epObj.episode, episodes.append({'episode': epObj.episode,
'episodeindexid': epObj.indexerid, 'episodeindexid': epObj.indexerid,
'season' : epObj.season, 'season' : epObj.season,
'searchstatus' : searchstatus, 'searchstatus' : searchstatus,
'status' : statusStrings[epObj.status], 'status' : statusStrings[epObj.status],
'quality': self.getQualityClass(epObj)}) 'quality': self.getQualityClass(epObj)})
return json.dumps({'show': show, 'episodes' : episodes}) return json.dumps({'show': show, 'episodes' : episodes})
#return json.dumps() #return json.dumps()
def getQualityClass(self, ep_obj): def getQualityClass(self, ep_obj):
# return the correct json value # return the correct json value
# Find the quality class for the episode # Find the quality class for the episode
quality_class = Quality.qualityStrings[Quality.UNKNOWN] quality_class = Quality.qualityStrings[Quality.UNKNOWN]
ep_status, ep_quality = Quality.splitCompositeStatus(ep_obj.status) ep_status, ep_quality = Quality.splitCompositeStatus(ep_obj.status)
@ -4605,7 +4610,7 @@ class Home(MainHandler):
return json.dumps({'result': 'success'}) return json.dumps({'result': 'success'})
else: else:
return json.dumps({'result': 'failure'}) return json.dumps({'result': 'failure'})
class UI(MainHandler): class UI(MainHandler):
def add_message(self): def add_message(self):