Add logic to display overdue/future shows on the Episodes page/DayByDay layout.

This commit is contained in:
JackDandy 2015-02-05 20:22:50 +00:00
parent 0c03b6ba6c
commit 320c4c854e
7 changed files with 313 additions and 148 deletions

View file

@ -25,6 +25,14 @@
* Add api disabled error code for newznab providers * Add api disabled error code for newznab providers
* Add support for a proxy host PAC url on the General Config/Advanced Settings page * Add support for a proxy host PAC url on the General Config/Advanced Settings page
* Add proxy request url parsing to enforce netloc only matching which prevents false positives when url query parts contain FQDNs * Add proxy request url parsing to enforce netloc only matching which prevents false positives when url query parts contain FQDNs
* Add scroll into view buttons when overdues shows are available on the Episodes page/DayByDay layout
* Add scroll into view buttons when future shows are available on the Episodes page/DayByDay layout
* Add qTips to episode names on the Episodes page/DayByDay layout
* Change Episodes page/List layout qtips to prepend show title to episode plot
* Change Episodes page/DayByDay layout qtips to prepend show title to episode plot
* Change Episodes page/DayByDay layout cards to display show title in a qtip when there is no plot
* Change position of "[paused]" text to top right of a card on the Episodes page/DayByDay layout
* Add "On Air until" text and overdue/on air colour bars to show episode states on the Episodes page/DayByDay layout
[develop changelog] [develop changelog]

View file

@ -632,6 +632,17 @@ h2.day, h2.network {
color: #999; color: #999;
} }
.over-layer0 {
background: rgb(61,61,61);
}
.over-layer1 {
background: transparent;
color:white;
border-left: 1px solid rgb(34, 34, 34);
border-bottom :1px solid rgb(34, 34, 34)
}
.carousel-control { .carousel-control {
color: #297AB8; color: #297AB8;
filter: alpha(opacity=100); filter: alpha(opacity=100);

View file

@ -591,6 +591,20 @@ h2.day, h2.network {
border-color: #CCC; border-color: #CCC;
} }
.over-layer0 {
background: rgb(61,61,61);
}
.over-layer1 {
background: transparent;
color:white;
border-left: 1px solid rgb(255,255,255);
border-bottom :1px solid rgb(255,255,255)
}
.carousel-control,
.carousel-control:hover,
.carousel-control:focus,
.day-of-week .text .airtime, .day-of-week .text .airtime,
.day-of-week .text .episode, .day-of-week .text .episode,
.day-of-week .text .episode .name { .day-of-week .text .episode .name {
@ -611,15 +625,6 @@ h2.day, h2.network {
color: #666; color: #666;
} }
.carousel-control {
color: #000;
}
.carousel-control:hover,
.carousel-control:focus {
color: #000;
}
.carousel-indicators li { .carousel-indicators li {
background: #555; background: #555;
border: 1px solid #555; border: 1px solid #555;

View file

@ -1401,6 +1401,7 @@ episodeView.tmpl
border-radius: 5px; border-radius: 5px;
} }
.carousel-indicators li.listing-soon,
.listing-default { .listing-default {
background-color: #f5f1e4; background-color: #f5f1e4;
} }
@ -1409,14 +1410,17 @@ episodeView.tmpl
background-color: #dfd; background-color: #dfd;
} }
.carousel-indicators li.listing-overdue,
.listing-overdue { .listing-overdue {
background-color: #fdd; background-color: #fdd;
} }
.carousel-indicators li.listing-default,
.listing-toofar { .listing-toofar {
background-color: #bedeed; background-color: #bedeed;
} }
.carousel-indicators li.listing-soon,
span.listing-default { span.listing-default {
color: #826f30; color: #826f30;
border: 1px solid #826f30; border: 1px solid #826f30;
@ -1427,11 +1431,13 @@ span.listing-current {
border: 1px solid #295730; border: 1px solid #295730;
} }
.carousel-indicators li.listing-overdue,
span.listing-overdue { span.listing-overdue {
color: #890000; color: #890000;
border: 1px solid #890000; border: 1px solid #890000;
} }
.carousel-indicators li.listing-default,
span.listing-toofar { span.listing-toofar {
color: #1d5068; color: #1d5068;
border: 1px solid #1d5068; border: 1px solid #1d5068;
@ -1579,6 +1585,23 @@ h2.day, h2.network {
width: 100% width: 100%
} }
.daybyday-show .state {
height: 3px;
}
.daybyday-show .listing-default {
background-color: transparent;
}
.carousel-indicators li.listing-overdue,
.daybyday-show .listing-overdue {
background-color: #ffb0b0;
}
.daybyday-show .listing-current {
background-color: #aaffaa;
}
.day-of-week .poster img { .day-of-week .poster img {
border: 1px solid; border: 1px solid;
border-radius: 5px; border-radius: 5px;
@ -1631,52 +1654,94 @@ h2.day, h2.network {
margin-left: 0; margin-left: 0;
} }
.over-layer0 {
filter: alpha(opacity=60);
opacity: .6;
}
.over-layer1 {
background: transparent;
}
.over-layer0,
.over-layer1 {
position: absolute;
top: 0;
right: 0;
font-size: 10px;
padding: 4px 6px 2px 2px;
}
.on-air0,
.on-air1 {
text-align: right;
}
.on-air0 {
background-color: #dfd !important;
filter: alpha(opacity=75);
opacity: .75;
}
.on-air1 {
color: #295730 !important;
border-left: 1px solid #295730 !important;
border-bottom: 1px solid #295730 !important;
}
.daybydayCarouselContainer { .daybydayCarouselContainer {
min-height: 20px; min-height: 20px;
padding: 19px; margin: 19px 0;
margin-bottom: 20px;
} }
.controlsBlock { .controlsBlock {
position: relative; position: relative;
display: block; display: block;
width: 220px; width: 180px;
margin: 0 auto; margin: 0 auto;
height: 45px; height: 35px;
text-align: center; text-align: center;
} }
.carousel-control { .carousel-control {
top: -24px;
background: none !important; background: none !important;
text-align: center; text-align: center;
opacity: 0.75; opacity: 0.75;
height: 20px;
width: 20px;
top:1px
} }
.carousel-indicators { .carousel-indicators {
position: absolute; top: 1px;
bottom: 12px;
} }
.carousel-indicators li { .carousel-indicators li {
border-radius: 0; border-radius: 0;
width: 12px; width: 12px;
height: 12px; height: 18px;
} }
.carousel-indicators .active { .carousel-indicators .active {
width: 14px; width: 14px;
height: 14px; height: 20px;
} }
@media screen and (min-width: 768px) { .carousel-control.right {
right: 4px
}
.carousel-control .glyphicon-chevron-left {
margin-left: -10px;
}
.carousel-control .glyphicon-chevron-right {
margin-right: -10px;
}
.carousel-control .glyphicon-chevron-left, .carousel-control .glyphicon-chevron-left,
.carousel-control .glyphicon-chevron-right { .carousel-control .glyphicon-chevron-right {
width: 30px; width: 20px;
height: 30px; height: 20px;
margin-top: 0; margin-top: 0;
font-size: 20px; font-size: 20px;
} top:0;
} }
/* ======================================================================= /* =======================================================================

View file

@ -108,6 +108,19 @@
\$(this).removeClass(sortdir).addClass(newdir); \$(this).removeClass(sortdir).addClass(newdir);
uiSortBy(\$('#sort').val()); uiSortBy(\$('#sort').val());
}); });
\$('.carousel').on('slide.bs.carousel', function () {
imagesLoaded('.daybyday-show', function() {
jQuery.each(\$container, function(j) {
this.isotope('layout');
});
});
});
\$('div[title!=""], span[title!=""]').qtip({style: {classes: 'qtip-rounded qtip-shadow'},
position: {viewport: \$(window), my: 'left center', adjust: {y: -10, x: 0}},
show: {solo: true}
});
}); });
//--> //-->
</script> </script>
@ -133,7 +146,7 @@
</style> </style>
<div class="h2footer pull-right"> <div class="h2footer pull-right">
<span>Layout: <span>Layout
<select name="layout" class="form-control form-control-inline input-sm" onchange="location = this.options[this.selectedIndex].value;"> <select name="layout" class="form-control form-control-inline input-sm" onchange="location = this.options[this.selectedIndex].value;">
<option value="$sbRoot/setEpisodeViewLayout/?layout=banner" #if 'banner' == $sickbeard.EPISODE_VIEW_LAYOUT then 'selected="selected"' else ''#>Banner</option> <option value="$sbRoot/setEpisodeViewLayout/?layout=banner" #if 'banner' == $sickbeard.EPISODE_VIEW_LAYOUT then 'selected="selected"' else ''#>Banner</option>
<option value="$sbRoot/setEpisodeViewLayout/?layout=daybyday" #if 'daybyday' == $sickbeard.EPISODE_VIEW_LAYOUT then 'selected="selected"' else ''#>Day by Day</option> <option value="$sbRoot/setEpisodeViewLayout/?layout=daybyday" #if 'daybyday' == $sickbeard.EPISODE_VIEW_LAYOUT then 'selected="selected"' else ''#>Day by Day</option>
@ -161,7 +174,7 @@
</select> </select>
</span> </span>
&nbsp; &nbsp;
<span>View Paused: <span>View Paused
<select name="viewpaused" class="form-control form-control-inline input-sm" onchange="location = this.options[this.selectedIndex].value;"> <select name="viewpaused" class="form-control form-control-inline input-sm" onchange="location = this.options[this.selectedIndex].value;">
<option value="$sbRoot/toggleEpisodeViewDisplayPaused"<%= (' selected="selected"', '')[True == sickbeard.EPISODE_VIEW_DISPLAY_PAUSED] %>>Hidden</option> <option value="$sbRoot/toggleEpisodeViewDisplayPaused"<%= (' selected="selected"', '')[True == sickbeard.EPISODE_VIEW_DISPLAY_PAUSED] %>>Hidden</option>
<option value="$sbRoot/toggleEpisodeViewDisplayPaused"<%= ('', ' selected="selected"')[True == sickbeard.EPISODE_VIEW_DISPLAY_PAUSED] %>>Shown</option> <option value="$sbRoot/toggleEpisodeViewDisplayPaused"<%= ('', ' selected="selected"')[True == sickbeard.EPISODE_VIEW_DISPLAY_PAUSED] %>>Shown</option>
@ -313,8 +326,9 @@
#end if #end if
#end if #end if
#set $show_id = '%s_%sx%s' % (str($cur_result['showid']), str($cur_result['season']), str($cur_result['episode']))
<!-- start $cur_result['show_name'] //--> <!-- start $cur_result['show_name'] //-->
<tr class="$show_div"> <tr id="show-${show_id}" class="$show_div" data-rawname="$cur_result['show_name']">
## forced to use a div to wrap airdate, the column sort went crazy with a span ## forced to use a div to wrap airdate, the column sort went crazy with a span
<td align="center" class="nowrap"> <td align="center" class="nowrap">
<div class="${fuzzydate}">$sbdatetime.sbdatetime.sbfdatetime($cur_result['localtime']).decode($sickbeard.SYS_ENCODING)</div><span class="sort_data">$time.mktime($cur_result['localtime'].timetuple())</span> <div class="${fuzzydate}">$sbdatetime.sbdatetime.sbfdatetime($cur_result['localtime']).decode($sickbeard.SYS_ENCODING)</div><span class="sort_data">$time.mktime($cur_result['localtime'].timetuple())</span>
@ -332,7 +346,7 @@
<td> <td>
#if $cur_result['description']: #if $cur_result['description']:
<img alt="" src="$sbRoot/images/info32.png" height="16" width="16" class="plotInfo" id="plot_info_<%= '%s_%s_%s' % (str(cur_result['showid']), str(cur_result['season']), str(cur_result['episode'])) %>" /> <img alt="" src="$sbRoot/images/info32.png" height="16" width="16" class="plotInfo" id="plot-${show_id}" />
#else: #else:
<img alt="" src="$sbRoot/images/info32.png" width="16" height="16" class="plotInfoNone" /> <img alt="" src="$sbRoot/images/info32.png" width="16" height="16" class="plotInfoNone" />
#end if #end if
@ -592,9 +606,54 @@
#if 'daybyday' == $layout: #if 'daybyday' == $layout:
#set $today = datetime.date.today() #set $shows_overdue = []
#set $dates = [$today + datetime.timedelta(days = $i) for $i in range(7)] #set $shows_soon = []
#set $tbl_day = 0 #set $shows_future = []
#set $state_overdue = 'listing-overdue'
#set $state_current = 'listing-current'
#set $state_soon = 'listing-soon'
#set $state_future = 'listing-default'
#for $cur_result in $sql_results:
#if int($cur_result['paused']) and not $sickbeard.EPISODE_VIEW_DISPLAY_PAUSED:
#continue
#end if
#if $cur_result['runtime']:
#set $air_date = $cur_result['localtime'].date()
#set $end_datetime = $cur_result['localtime'] + datetime.timedelta(minutes = $cur_result['runtime'])
#if $air_date >= $next_week.date():
#set $cur_result['state'] = ''
$shows_future.append($cur_result)
#elif $cur_result['localtime'] > $today
#set $cur_result['state'] = ''
$shows_soon.append($cur_result)
#elif $end_datetime > $today
#set $cur_result['state'] = $state_current
#set $cur_result['state-title'] = 'Currently On Air'
$shows_soon.append($cur_result)
#elif $air_date == $today.date():
#set $cur_result['state'] = $state_overdue
#set $cur_result['state-title'] = 'Overdue'
$shows_soon.append($cur_result)
#else
#set $cur_result['state'] = $state_overdue
#set $cur_result['state-title'] = 'Overdue'
$shows_overdue.append($cur_result)
#end if
#else
#set $cur_result['state'] = $state_soon
$shows_soon.append($cur_result)
#end if
#end for
##set $state_init = [int(bool($shows_overdue)), ($state_soon, $state_overdue)[0 < len($shows_overdue)]] ## default overdue
#set $state_init = [int(bool($shows_overdue)), $state_soon] ## default soon
#set $dates_future = sorted({$i['localtime'].date():$i for $i in $shows_future})
#set $rounded_week = len($dates_future)/7*7 + int(bool(len($dates_future)%7))*7
#set $dates_future += [$dates_future[-1] + datetime.timedelta(days = 1 + $i) for $i in range($rounded_week - len($dates_future))]
#set $num_weeks = $rounded_week/7
<input type="hidden" id="sbRoot" value="$sbRoot" /> <input type="hidden" id="sbRoot" value="$sbRoot" />
@ -605,22 +664,51 @@
<a class="left carousel-control" href="#Carousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a> <a class="left carousel-control" href="#Carousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#Carousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a> <a class="right carousel-control" href="#Carousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
<div class="carousel-indicators"> <div class="carousel-indicators">
<li data-target="#Carousel" data-slide-to="0" class="active"></li>
<li data-target="#Carousel" data-slide-to="1"></li> #set $slide_id = 0
<li data-target="#Carousel" data-slide-to="2"></li> #if len($shows_overdue)
<li data-target="#Carousel" data-slide-to="$slide_id" class="$state_overdue#if $state_init[1] == $state_overdue then ' active' else ''#"></li>
#set $slide_id = 1
#end if
<li data-target="#Carousel" data-slide-to="$slide_id" class="$state_soon#if $state_init[1] == $state_soon then ' active' else ''#"></li>
#set $slide_id += 1
#for $i in range($slide_id, $slide_id + $num_weeks)
<li data-target="#Carousel" data-slide-to="${i}" class="$state_future#if $state_init[1] == $state_future and $state_init[0] == $i then ' active' else ''#"></li>
#end for
</div> </div>
</div> </div>
<div class="carousel-inner"> <div class="carousel-inner">
<div class="item active"> <!-- page 1 --> #for $shows, $state in [[$shows_overdue, $state_overdue], [$shows_soon, $state_soon], [$shows_future, $state_future]]
#if 0 == len($shows) and ($state_overdue == $state or $state_future == $state)
#continue
#end if
#set $week_num = 0
#set $num_weeks = 1
#while ($num_weeks)
#if $state_future == $state
#set $dates = $dates_future[$week_num*7:$week_num*7+7]
#if 0 == $week_num
#set $num_weeks = $rounded_week/7
#end if
#set $week_num += 1
#else
#set $dates = [($today + datetime.timedelta(days = ($i, -7+$i)[$state_overdue == $state])).date() for $i in range(7)]
#end if
#set $num_weeks -= 1
<div class="daybydayWrapper"> <!-- style="width:1600px" --> <div class="item#if $state_init[1] == $state then ' active' else ''#"> <!-- start $state -->
<div class="daybydayWrapper">
#set $tbl_day = 0
#for $day in $dates #for $day in $dates
#set $tbl_day += 1 #set $tbl_day += 1
#set $col_class = '' #set $col_class = ''
#if 1 == $tbl_day #if 1 == $tbl_day and $state_soon == $state
#set $col_class = 'today' #set $col_class = 'today'
#end if #end if
#set $col_class = '%s %s' % ($col_class, ('even', 'odd')[1 == tbl_day % 2]) #set $col_class = '%s %s' % ($col_class, ('even', 'odd')[1 == tbl_day % 2])
@ -637,36 +725,27 @@
<span class="hidden-lg">$sbdatetime.sbdatetime.sbfdate($day, '%b').decode($sickbeard.SYS_ENCODING).capitalize()</span> <span class="hidden-lg">$sbdatetime.sbdatetime.sbfdate($day, '%b').decode($sickbeard.SYS_ENCODING).capitalize()</span>
</div> </div>
</div> </div>
<div id="$sbdatetime.sbdatetime.sbfdate($day, 'day%w')">
<div id="$sbdatetime.sbdatetime.sbfdate($day, 'day%j')">
#set $day_has_show = False #set $day_has_show = False
#for $cur_result in $sql_results: #for $cur_result in $shows:
#if int($cur_result['paused']) and not $sickbeard.EPISODE_VIEW_DISPLAY_PAUSED: #if $day == $cur_result['localtime'].date():
#continue
#end if
#set $cur_indexer = int($cur_result['indexer'])
#set $runtime = $cur_result['runtime']
#set $airday = $cur_result['localtime'].date()
#if $airday == $day:
#set $day_has_show = True #set $day_has_show = True
#set $airtime = $sbdatetime.sbdatetime.sbftime($cur_result['localtime'], markup=True).decode($sickbeard.SYS_ENCODING) #set $airtime = $sbdatetime.sbdatetime.sbftime($cur_result['localtime'], markup=True).decode($sickbeard.SYS_ENCODING)
#set $img_tag = '<img' #set $img_id = ''
#set $plot_class = 'class="img-responsive' #set $plot_class = ''
#set $title_text = '' #set $title_text = ''
#if $cur_result['description']: #set $show_id = '%s_%sx%s' % (str($cur_result['showid']), str($cur_result['season']), str($cur_result['episode']))
#set $img_tag += ' id="plot_info_%s_%s_%s"' % (str($cur_result['showid']), str($cur_result['season']), str($cur_result['episode'])) #set $img_id = ' id="plot-%s"' % $show_id
#set $plot_class += ' plot-daybyday' #set $plot_class = ' plot-daybyday'
#else
#set $title_text = $cur_result['show_name']
#end if
<div id="show-$cur_result['showid']" class="daybyday-show" data-name="$cur_result['data_show_name']" data-season="$cur_result['season']" data-episode="$cur_result['episode']" data-network="$cur_result['data_network']" data-time="$time.mktime($cur_result['localtime'].timetuple())"> <div id="show-${show_id}" class="daybyday-show" data-name="$cur_result['data_show_name']" data-season="$cur_result['season']" data-episode="$cur_result['episode']" data-network="$cur_result['data_network']" data-time="$time.mktime($cur_result['localtime'].timetuple())" data-rawname="$cur_result['show_name']">
<div class="poster"> <div class="poster">
<a title="${title_text}" href="$sbRoot/home/displayShow?show=${cur_result['showid']}"> <a${title_text} href="$sbRoot/home/displayShow?show=${cur_result['showid']}">
${img_tag} ${plot_class}" alt="" src="$sbRoot/showPoster/?show=${cur_result['showid']}&amp;which=poster_thumb" /></a> <img${img_id} class="img-responsive${plot_class}" alt="" src="$sbRoot/showPoster/?show=${cur_result['showid']}&amp;which=poster_thumb" /></a>
</div> </div>
<div class="state#if len($cur_result['state']) then ' %s" title="%s"' % ($cur_result['state'], $cur_result['state-title']) else '"' #></div>
<div class="text"> <div class="text">
<div class="airtime"> <div class="airtime">
<span class="time">${airtime}</span> <span class="network pull-right grey-text">$cur_result['network']</span> <span class="time">${airtime}</span> <span class="network pull-right grey-text">$cur_result['network']</span>
@ -674,35 +753,33 @@
<div class="episode" title="$cur_result['name']"> <div class="episode" title="$cur_result['name']">
<span class="season"><%= '%i' % int(cur_result['season']) %></span>x<span class="number"><%= '%02i' % int(cur_result['episode']) %></span> <span class="season"><%= '%i' % int(cur_result['season']) %></span>x<span class="number"><%= '%02i' % int(cur_result['episode']) %></span>
<span class="name">$cur_result['name']</span> <span class="name">$cur_result['name']</span>
</div>
</div>
#if int($cur_result['paused']): #if int($cur_result['paused']):
<span class="pause">[paused]</span> <span class="over-layer0">[paused]</span>
<span class="over-layer1">[paused]</span>
#elif $state_current == $cur_result['state']
#set $endtime = $sbdatetime.sbdatetime.sbftime($cur_result['localtime'] + datetime.timedelta(minutes = $cur_result['runtime']), markup=True).decode($sickbeard.SYS_ENCODING)
<span class="over-layer0 on-air0">On Air until<br />$endtime</span>
<span class="over-layer1 on-air1">On Air until<br />$endtime</span>
#end if #end if
</div>
</div>
</div><!-- end show-$cur_result['showid'] //--> </div><!-- end show-$cur_result['showid'] //-->
#end if #end if
#end for #end for
#if not $day_has_show: #if not $day_has_show:
<div class="daybyday-show"> <div class="daybyday-show">
<span class="episode-blank">No shows for this day</span> #set $theday = ('this ', 'to')[1 == $tbl_day and $state_soon == $state]
<span class="episode-blank">No shows ${theday}day</span>
</div> </div>
#end if #end if
</div> </div>
</div> </div>
#end for #end for
</div> </div> <!-- end daybydayWrapper //-->
</div> <!-- end $state //-->
</div> <!-- end page 1 //--> #end while
#end for
<div class="item">
Page 2
</div>
<div class="item">
Page 3
</div>
</div> <!-- end carouselinner //--> </div> <!-- end carouselinner //-->
</div> <!-- end Carousel //--> </div> <!-- end Carousel //-->

View file

@ -1,6 +1,7 @@
$(function () { $(function () {
$('.plotInfo, .plot-daybyday').each(function () { $('.plotInfo, .plot-daybyday').each(function () {
var match = $(this).attr('id').match(/^plot_info_(\d+)_(\d+)_(\d+)$/); var match = $(this).attr('id').match(/^plot(?:_info_|-)((\d+)_(\d+)[_x](\d+))$/);
var showName = $('#show-' + match[1]).attr('data-rawname');
$(this).qtip({ $(this).qtip({
content: { content: {
text: function(event, api) { text: function(event, api) {
@ -9,14 +10,16 @@ $(function () {
url: $('#sbRoot').val() + '/home/plotDetails', url: $('#sbRoot').val() + '/home/plotDetails',
type: 'GET', type: 'GET',
data: { data: {
show: match[1], show: match[2],
episode: match[3], episode: match[4],
season: match[2] season: match[3]
} }
}) })
.then(function(content) { .then(function(content) {
// Set the tooltip content upon successful retrieval // Set the tooltip content upon successful retrieval
api.set('content.text', content); api.set('content.text', ('undefined' === typeof(showName) ? ''
: ('' !== content ? '<b class="boldest">' + showName + '</b>' : showName))
+ ('' !== content ? ' ' + content : ''));
}, function(xhr, status, error) { }, function(xhr, status, error) {
// Upon failure... set the tooltip content to the status and error value // Upon failure... set the tooltip content to the status and error value
api.set('content.text', status + ': ' + error); api.set('content.text', status + ': ' + error);
@ -32,7 +35,7 @@ $(function () {
my: 'left center', my: 'left center',
adjust: { adjust: {
y: -10, y: -10,
x: 2 x: 0
} }
}, },
style: { style: {

View file

@ -367,35 +367,31 @@ class MainHandler(RequestHandler):
tomorrow = (datetime.date.today() + datetime.timedelta(days=1)).toordinal() tomorrow = (datetime.date.today() + datetime.timedelta(days=1)).toordinal()
next_week_dt = (datetime.date.today() + datetime.timedelta(days=7)) next_week_dt = (datetime.date.today() + datetime.timedelta(days=7))
next_week = (next_week_dt + datetime.timedelta(days=1)).toordinal() next_week = (next_week_dt + datetime.timedelta(days=1)).toordinal()
if not (layout and layout in 'daybyday') and not (sickbeard.EPISODE_VIEW_LAYOUT and sickbeard.EPISODE_VIEW_LAYOUT in 'daybyday'):
recently = (yesterday_dt - datetime.timedelta(days=sickbeard.EPISODE_VIEW_MISSED_RANGE)).toordinal() recently = (yesterday_dt - datetime.timedelta(days=sickbeard.EPISODE_VIEW_MISSED_RANGE)).toordinal()
else:
recently = yesterday
done_show_list = [] done_show_list = []
qualList = Quality.DOWNLOADED + Quality.SNATCHED + [ARCHIVED, IGNORED] qualities = Quality.DOWNLOADED + Quality.SNATCHED + [ARCHIVED, IGNORED]
myDB = db.DBConnection() myDB = db.DBConnection()
sql_results = myDB.select( sql_results = myDB.select(
"SELECT *, tv_shows.status as show_status FROM tv_episodes, tv_shows WHERE season != 0 AND airdate >= ? AND airdate <= ? AND tv_shows.indexer_id = tv_episodes.showid AND tv_episodes.status NOT IN (" + ','.join( 'SELECT *, tv_shows.status as show_status FROM tv_episodes, tv_shows WHERE season != 0 AND airdate >= ? AND airdate <= ? AND tv_shows.indexer_id = tv_episodes.showid AND tv_episodes.status NOT IN (%s)'
['?'] * len(qualList)) + ")", [yesterday, next_week] + qualList) % ','.join(['?'] * len(qualities)),
[yesterday, next_week] + qualities)
for cur_result in sql_results: for cur_result in sql_results:
done_show_list.append(int(cur_result["showid"])) done_show_list.append(int(cur_result['showid']))
if not (layout and layout in 'daybyday') and not (sickbeard.EPISODE_VIEW_LAYOUT and sickbeard.EPISODE_VIEW_LAYOUT in 'daybyday'): sql_results += myDB.select(
more_sql_results = myDB.select( 'SELECT *, tv_shows.status as show_status FROM tv_episodes outer_eps, tv_shows WHERE season != 0 AND showid NOT IN (%s)'
"SELECT *, tv_shows.status as show_status FROM tv_episodes outer_eps, tv_shows WHERE season != 0 AND showid NOT IN (" + ','.join( % ','.join(['?'] * len(done_show_list))
['?'] * len( + ' AND tv_shows.indexer_id = outer_eps.showid AND airdate = (SELECT airdate FROM tv_episodes inner_eps WHERE inner_eps.season != 0 AND inner_eps.showid = outer_eps.showid AND inner_eps.airdate >= ? ORDER BY inner_eps.airdate ASC LIMIT 1) AND outer_eps.status NOT IN (%s)'
done_show_list)) + ") AND tv_shows.indexer_id = outer_eps.showid AND airdate = (SELECT airdate FROM tv_episodes inner_eps WHERE inner_eps.season != 0 AND inner_eps.showid = outer_eps.showid AND inner_eps.airdate >= ? ORDER BY inner_eps.airdate ASC LIMIT 1) AND outer_eps.status NOT IN (" + ','.join( % ','.join(['?'] * len(Quality.DOWNLOADED + Quality.SNATCHED)),
['?'] * len(Quality.DOWNLOADED + Quality.SNATCHED)) + ")",
done_show_list + [next_week] + Quality.DOWNLOADED + Quality.SNATCHED) done_show_list + [next_week] + Quality.DOWNLOADED + Quality.SNATCHED)
sql_results += more_sql_results
more_sql_results = myDB.select( sql_results += myDB.select(
"SELECT *, tv_shows.status as show_status FROM tv_episodes, tv_shows WHERE season != 0 AND tv_shows.indexer_id = tv_episodes.showid AND airdate <= ? AND airdate >= ? AND tv_episodes.status = ? AND tv_episodes.status NOT IN (" + ','.join( 'SELECT *, tv_shows.status as show_status FROM tv_episodes, tv_shows WHERE season != 0 AND tv_shows.indexer_id = tv_episodes.showid AND airdate <= ? AND airdate >= ? AND tv_episodes.status = ? AND tv_episodes.status NOT IN (%s)'
['?'] * len(qualList)) + ")", [tomorrow, recently, WANTED] + qualList) % ','.join(['?'] * len(qualities)),
sql_results += more_sql_results [tomorrow, recently, WANTED] + qualities)
sql_results = list(set(sql_results)) sql_results = list(set(sql_results))
@ -429,7 +425,7 @@ class MainHandler(RequestHandler):
sql_results.sort(sorts[sickbeard.EPISODE_VIEW_SORT]) sql_results.sort(sorts[sickbeard.EPISODE_VIEW_SORT])
t = PageTemplate(headers=self.request.headers, file="episodeView.tmpl") t = PageTemplate(headers=self.request.headers, file='episodeView.tmpl')
t.next_week = datetime.datetime.combine(next_week_dt, datetime.time(tzinfo=network_timezones.sb_timezone)) t.next_week = datetime.datetime.combine(next_week_dt, datetime.time(tzinfo=network_timezones.sb_timezone))
t.today = datetime.datetime.now(network_timezones.sb_timezone) t.today = datetime.datetime.now(network_timezones.sb_timezone)
t.sql_results = sql_results t.sql_results = sql_results