#import datetime
#import sickgear
#from sickgear import network_timezones, subtitles
#from sickgear.common import Overview, Quality, statusStrings, ARCHIVED, UNAIRED, SUBTITLED, SNATCHED_ANY, DOWNLOADED
#from sickgear.sgdatetime import SGDatetime
#from lib import subliminal
<% def sg_var(varname, default=False): return getattr(sickgear, varname, default) %>#slurp#
<% def sg_str(varname, default=''): return getattr(sickgear, varname, default) %>#slurp#
#######
#set $network_timezone = $network_timezones.get_network_timezone($show_obj.network)
#set $network_time = $network_timezones.parse_time($show_obj.airs)
#set $odd = 0
#set $fuzzydate = 'airdate'
#set $scene, $scene_anime = (False, False)
#if not $show_obj.air_by_date and not $show_obj.is_sports and not $show_obj.is_anime and $show_obj.is_scene
#set $scene = True
#elif not $show_obj.air_by_date and not $show_obj.is_sports and $show_obj.is_anime and $show_obj.is_scene
#set $scene_anime = True
#end if
#set $attr_title_ep = ('', ' (Anime #)')[$show_obj.is_anime]
##
#set $eps = $getVar('episodes', None) or [$episode]
#for $ep in $eps
#set $ep_key = ($ep['season'], $ep['episode'])
#set $ep_str = '%sx%s' % $ep_key
#set $epLoc = $ep['location']
#set never_aired = 0 < int($ep['season']) and 1 == int($ep['airdate'])
#set $nfo, $nfo_img = (('No', '-no'), ('Yes', ''))[int($ep['hasnfo'])]
#set $tbn, $tbn_img = (('No', '-no'), ('Yes', ''))[int($ep['hastbn'])]
#if $epLoc and $show_obj._location and $epLoc.lower().startswith($show_obj._location.lower())
#set $epLoc = $epLoc[len($show_obj._location)+1:]
#elif $epLoc and (not $epLoc.lower().startswith($show_obj._location.lower()) or not $show_obj._location)
#set $epLoc = $epLoc
#end if
#set $episode = str($ep['episode']) + ('', ' (%s)' % $ep['absolute_number'])[$show_obj.is_anime]
#set $downloaded = ('', 'file %ssize %s' % ($epLoc, $sickgear.helpers.human($ep['file_size'])))['' != $epLoc and None != $epLoc]
#set $attr=(('', 'Ep # %s' % $attr_title_ep)[bool($attr_title_ep)], $downloaded)[any($downloaded)]
$episode
#slurp
#if $scene
#set $dfltSeas, $dfltEpis = $xem_numbering.get($ep_key, (0, 0))
#elif $scene_anime
#set $dfltAbsolute = $xem_absolute_numbering.get($ep_key, 0)
#end if
#slurp
#set $cls = (' class="tba grey-text"', '')['good' == $Overview.overviewStrings[$ep_cats[$ep_str]]]
#if not $ep['name'] or 'TBA' == $ep['name']#TBA #else#$ep['name']#end if#
#set $ep_dt = $network_timezones.get_episode_time($ep['airdate'], $network_time, $show_obj.network, $show_obj.airtime, $network_timezone, $ep['timestamp'], $ep['network'], $ep['airtime'], $ep['timezone'])
#if 1 == int($ep['airdate']) then 'never' else $SGDatetime.sbfdate($SGDatetime.convert_to_setting($ep_dt))#
#if $sg_var('USE_SUBTITLES') and $show_obj.subtitles
#if $ep['subtitles']
#for $sub_lang in subliminal.language.language_list($ep['subtitles'].split(','), strict=False)
#if '' != sub_lang.alpha2
#elif 'und' == sub_lang.alpha3
#end if
#end for
#end if
#end if
#slurp
#set $curStatus, $curQuality = $Quality.splitCompositeStatus(int($ep['status']))
#if Quality.NONE != $curQuality
#if $SUBTITLED == $curStatus# #else#$statusStrings[$curStatus].replace('Downloaded', '')#end if# #if 'Unknown' != $statusStrings[$curStatus]#$Quality.get_quality_ui($curQuality) #end if#
#else
$statusStrings[$curStatus].replace('SD DVD', 'SD DVD/BR/BD')
#end if
#if 0 != int($ep['season'])
#set $status = $Quality.splitCompositeStatus(int($ep['status']))[0]
#if ($status in $SNATCHED_ANY + [$DOWNLOADED, $ARCHIVED]) and $sg_var('USE_FAILED_DOWNLOADS')
#else
#end if
#end if
#slurp
#if $sg_var('USE_SUBTITLES') and $show_obj.subtitles and len(set(str($ep['subtitles']).split(',')).intersection(set($subtitles.wanted_languages()))) < len($subtitles.wanted_languages()) and $ep['location']
#end if
#end for