#import sickgear
#import datetime
#import re
#from sickgear.common import *
#from sickgear.helpers import anon_url
#from sickgear.indexers.indexer_config import TVINFO_TVDB, TVINFO_IMDB
#from sickgear.sgdatetime import SGDatetime
#from _23 import decode_str
<% def sg_var(varname, default=False): return getattr(sickgear, varname, default) %>#slurp#
<% def sg_str(varname, default=''): return getattr(sickgear, varname, default) %>#slurp#
<% def view_paused(result): return ((int(result['paused']) and sg_var('EPISODE_VIEW_DISPLAY_PAUSED'))
or (not int(result['paused']) and 2 != sg_var('EPISODE_VIEW_DISPLAY_PAUSED'))) %>
#slurp#
##
#set global $title = 'Daily Schedule'
#set global $header = 'Daily Schedule'
#set global $sbPath = '..'
#set global $topmenu = 'home'
#set $css = $getVar('css', '')
#set $has_art = $getVar('has_art', None)
#set $restart = 'Restart SickGear for new features on this page'
#set $show_message = (None, $restart)[not $varExists('fanart')]
#set global $page_body_attr = 'episode-view" class="' + $css
#set theme_suffix = ('', '-dark')['dark' == $sg_str('THEME_NAME', 'dark')]
##
#import os.path
#include $os.path.join($sg_str('PROG_DIR'), 'gui/slick/interfaces/default/inc_top.tmpl')
#set $sort = $sg_var('EPISODE_VIEW_SORT')
#set $table_sort_header_codes = {'time': 0, 'show': 1, 'network': 4}
#if $sort not in $table_sort_header_codes
#set $sort = 'time'
#end if
#if $layout in ['daybyday', 'list']
#end if
#if 'daybyday' != $layout
#else
#end if
#if $show_message
$show_message
#end if
#if $varExists('header')
#else
$title
#end if
#set $selected = ' selected="selected"'
Layout
Banner
Day by Day
List
Poster
Sort
#if 'daybyday' == $layout
#end if
By
#if 'daybyday' == $layout
Network
Show
Time
#else
Date/Time
Network
Show
#end if
View Paused
Hidden
Shown
Only
#if 'list' == $layout
#set $show_div = 'listing-default'
Airdate
Show
Next Ep
Next Ep Name
Network
Quality
TV Info
Search
#for $cur_result in $sql_results
#set $tvid = int($cur_result['indexer'])
#set $runtime = $cur_result['runtime']
#set $display_name = (re.sub(r'^((?:A(?!\s+to)n?)|The)\s(\w)', r'\1 \2', $cur_result['show_name']), $cur_result['show_name'])[$sg_var('SORT_ARTICLE')]
#if not view_paused($cur_result)
#continue
#end if
#set $cur_ep_airdate = $cur_result['localtime'].date()
#if $runtime
#set $cur_ep_enddate = $cur_result['localtime'] + datetime.timedelta(minutes = $runtime)
#if $cur_ep_enddate < $today
#set $show_div = 'listing-overdue'
#elif $cur_ep_airdate >= $next_week.date()
#set $show_div = 'listing-toofar'
#elif $cur_ep_airdate >= $today.date() and $cur_ep_airdate < $next_week.date()
#if $cur_ep_airdate == $today.date()
#set $show_div = 'listing-current'
#else
#set $show_div = 'listing-default'
#end if
#end if
#end if
#set $show_id = '%s_%sx%s' % ($cur_result['tvid_prodid'], $cur_result['season'], $cur_result['episode'])
#set $id_sxe = '%s_%s_%sx%s' % ($cur_result['indexer'], $cur_result['showid'], $cur_result['season'], $cur_result['episode'])
## forced to use a div to wrap airdate, the column sort went crazy with a span
$decode_str($SGDatetime.sbfdatetime($cur_result['localtime']), $sickgear.SYS_ENCODING)
$cur_result['localtime'].strftime('%Y%m%d%H%M')
$display_name
#if int($cur_result['paused'])
[paused]
#end if
<%= 'S%02iE%02i' % (int(cur_result['season']), int(cur_result['episode'])) %>
#if $cur_result['description']
#else
#end if
$cur_result['name']
$cur_result['network']
#if int($cur_result['quality']) in $qualityPresets
$qualityPresetStrings[int($cur_result['quality'])]
#else
Custom
#end if
#if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_url']
#end if
#end for
 
#else if $layout in ['banner', 'poster']
#set $cur_segment = None
#set $too_late_header = False
#set $missed_header = False
#set $today_header = False
#set $show_div = 'ep_listing listing-default'
#for $x, $cur_result in $enumerate($sql_results)
#set $add_space = ('', ' add-space')[bool($x)]
#set $tvid = int($cur_result['indexer'])
#set $display_name = (re.sub(r'^((?:A(?!\s+to)n?)|The)\s(\w)', r'
\1 \2', $cur_result['show_name']), $cur_result['show_name'])[$sg_var('SORT_ARTICLE')]
##
#if not view_paused($cur_result)
#continue
#end if
##
#set $runtime = $cur_result['runtime']
##
#if 'network' == $sort
##
#set $show_network = $cur_result['network'] if $cur_result['network'] else 'no network'
#if $cur_segment != $show_network
#set $cur_segment = $cur_result['network']
$show_network
#end if
#set $cur_ep_airdate = $cur_result['localtime'].date()
##
#if $runtime
#set $cur_ep_enddate = $cur_result['localtime'] + datetime.timedelta(minutes = $runtime)
#if $cur_ep_enddate < $today
#set $show_div = 'ep_listing listing-overdue'
#elif $cur_ep_airdate >= $next_week.date()
#set $show_div = 'ep_listing listing-toofar'
#elif $cur_ep_enddate >= $today and $cur_ep_airdate < $next_week.date()
#if $cur_ep_airdate == $today.date()
#set $show_div = 'ep_listing listing-current'
#else
#set $show_div = 'ep_listing listing-default'
#end if
#end if
#end if
#elif 'time' == $sort
##
#set $cur_ep_airdate = $cur_result['localtime'].date()
##
#if $cur_segment != $cur_ep_airdate
#if $runtime
#set $cur_ep_enddate = $cur_result['localtime'] + datetime.timedelta(minutes = $runtime)
#if $cur_ep_enddate < $today and $cur_ep_airdate != $today.date() and not $missed_header
Missed
#set $missed_header = True
#elif $cur_ep_airdate >= $next_week.date() and not $too_late_header
Later
#set $too_late_header = True
#elif $cur_ep_enddate >= $today and $cur_ep_airdate < $next_week.date()
#if $cur_ep_airdate == $today.date()
$decode_str($SGDatetime.sbfdate($cur_ep_airdate, '%A'), $sickgear.SYS_ENCODING).capitalize() [Today]
#set $today_header = True
#else
$decode_str($SGDatetime.sbfdate($cur_ep_airdate, '%A'), $sickgear.SYS_ENCODING).capitalize()
#end if
#end if
#end if
#set $cur_segment = $cur_ep_airdate
#end if
##
#if $cur_ep_airdate == $today.date() and not $today_header
$decode_str($SGDatetime.sbfdate($cur_ep_airdate, '%A'), $sickgear.SYS_ENCODING).capitalize() [Today]
#set $today_header = True
#end if
##
#if $runtime
#set $cur_ep_enddate = $cur_result['localtime'] + datetime.timedelta(minutes = $runtime)
#if $cur_ep_enddate < $today
#set $show_div = 'ep_listing listing-overdue'
#elif $cur_ep_airdate >= $next_week.date()
#set $show_div = 'ep_listing listing-toofar'
#elif $cur_ep_enddate >= $today and $cur_ep_airdate < $next_week.date()
#if $cur_ep_airdate == $today.date()
#set $show_div = 'ep_listing listing-current'
#else
#set $show_div = 'ep_listing listing-default'
#end if
#end if
#end if
#elif 'show' == $sort
#set $cur_ep_airdate = $cur_result['localtime'].date()
#slurp
#if $runtime
#set $cur_ep_enddate = $cur_result['localtime'] + datetime.timedelta(minutes = $runtime)
#if $cur_ep_enddate < $today
#set $show_div = 'ep_listing listing-overdue listingradius'
#elif $cur_ep_airdate >= $next_week.date()
#set $show_div = 'ep_listing listing-toofar listingradius'
#elif $cur_ep_enddate >= $today and $cur_ep_airdate < $next_week.date()
#if $cur_ep_airdate == $today.date()
#set $show_div = 'ep_listing listing-current listingradius'
#else
#set $show_div = 'ep_listing listing-default listingradius'
#end if
#end if
#end if
#end if
#slurp
#set $id_sxe = '%s_%s_%sx%s' % ($cur_result['indexer'], $cur_result['showid'], $cur_result['season'], $cur_result['episode'])
#if 'banner' == $layout
#end if
Next Episode: <%= 'S%02iE%02i' % (int(cur_result['season']), int(cur_result['episode'])) %> - $cur_result['name']
Airdate: $decode_str($SGDatetime.sbfdatetime($cur_result['localtime']), $sickgear.SYS_ENCODING) <%= ('', ' on %s ' % str(cur_result['network']))[None is not cur_result['network']] %>
Quality:
#if int($cur_result['quality']) in $qualityPresets
$qualityPresetStrings[int($cur_result['quality'])]
#else
Custom
#end if
#if $cur_result['description']
Plot:
$cur_result['description']
#else
Plot:
#end if
#end for
#end if
##
#if 'daybyday' == $layout
##
#set $shows_overdue = []
#set $shows_soon = []
#set $shows_future = []
#set $onair = []
#set $backart = []
#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 not view_paused($cur_result)
#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)
#set $dif = $cur_result['localtime'] - $today
#set $until_hrs = (divmod($dif.days * 86400 + $dif.seconds, 60)[0]) / 60
#if 24 >= $until_hrs and $cur_result['tvid_prodid'] not in $backart
$backart.append($cur_result['tvid_prodid'])
#end if
#elif $end_datetime > $today
#set $cur_result['state'] = $state_current
#set $cur_result['state-title'] = 'Currently On Air'
$shows_soon.append($cur_result)
#if $cur_result['tvid_prodid'] not in $onair
$onair.append($cur_result['tvid_prodid'])
#end if
#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
#set $cur_result['state-title'] = ''
$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 = int(len($dates_future)/7*7 + int(bool(len($dates_future)%7))*7)
<% dates_future += [dates_future[-1] + datetime.timedelta(days = 1 + i) for i in range(rounded_week - len(dates_future))] %>
#set $num_weeks = int($rounded_week/7)
#slurp
#if $varExists('fanart')
#set $backlist = $backart
#if $onair
#import random
$random.shuffle($onair)
#set $backlist = $onair
#end if
#if len($backlist)
#set $start_image = True
#for $show_id in $backlist
#for ($image, $rating) in $fanart.get($show_id, [])
#set $start_image = False
#end for
#end for
#end if
#end if
#set $wide = int(0 < len($shows_overdue)) + $num_weeks
#if $wide
#set $slide_id = 0
#if len($shows_overdue)
#set $slide_id = 1
#end if
#set $slide_id += 1
#for $i in range($slide_id, $slide_id + $num_weeks)
#end for
#end if
#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 = int($rounded_week/7)
#end if
#set $week_num += 1
#else
## hack to make var available in local context
#set $today = $today
<% dates = [(today + datetime.timedelta(days = (i, -7+i)[state_overdue == state])).date() for i in range(7)] %>
#end if
#set $num_weeks -= 1
#set $tbl_day = 0
#for $day in $dates
##
#set $tbl_day += 1
##
#set $col_class = ''
#if 1 == $tbl_day and $state_soon == $state
#set $col_class = 'today '
#end if
#set $col_class = '%s%s' % ($col_class, ('even', 'odd')[1 == tbl_day % 2])
$decode_str($SGDatetime.sbfdate($day, ' %d'), $sickgear.SYS_ENCODING).replace(' 0', ' ')
$decode_str($SGDatetime.sbfdate($day, '%A'), $sickgear.SYS_ENCODING).capitalize()
$decode_str($SGDatetime.sbfdate($day, '%a'), $sickgear.SYS_ENCODING).capitalize()
$decode_str($SGDatetime.sbfdate($day, '%B'), $sickgear.SYS_ENCODING).capitalize()
$decode_str($SGDatetime.sbfdate($day, '%b'), $sickgear.SYS_ENCODING).capitalize()
#set $day_has_show = False
#for $cur_result in $shows
#if $day == $cur_result['localtime'].date()
#set $day_has_show = True
#set $airtime = $decode_str($SGDatetime.sbftime($cur_result['localtime'], markup=True), $sickgear.SYS_ENCODING)
#set $img_id = ''
#set $plot_class = ''
#set $title_text = ''
#set $show_id = '%s_%sx%s' % ($cur_result['tvid_prodid'], str($cur_result['season']), str($cur_result['episode']))
#set $img_id = ' id="plot-%s"' % $show_id
#set $plot_class = ' plot-daybyday'
#set $match = None if not $cur_result['network'] else re.search(r'(.*)\s(\(\w+\))$', $cur_result['network'], re.I | re.M)
${airtime} %s' % $cur_result['network'] if None is $match else ' title="%s">%s' % ($match.group(2), $match.group(1))#
<%= '%i' % int(cur_result['season']) %> x<%= '%02i' % int(cur_result['episode']) %>
$cur_result['name']
#if int($cur_result['paused'])
[paused]
[paused]
#elif $state_current == $cur_result['state']
#set $endtime = $decode_str($SGDatetime.sbftime($cur_result['localtime'] + datetime.timedelta(minutes = $cur_result['runtime']), markup=True), $sickgear.SYS_ENCODING)
On Air until $endtime
On Air until $endtime
#end if
#end if
#end for
#if not $day_has_show
#set $theday = ('this ', 'to')[1 == $tbl_day and $state_soon == $state]
No shows ${theday}day
#end if
#end for
#end while
#end for
#end if
#raw
#end raw
#if $varExists('fanart') and $layout in 'daybyday'
#include $os.path.join($sg_str('PROG_DIR'), 'gui/slick/interfaces/default/inc_livepanel.tmpl')
#end if
#include $os.path.join($sg_str('PROG_DIR'), 'gui/slick/interfaces/default/inc_bottom.tmpl')