#import datetime
#import sickbeard
#from sickbeard import network_timezones, sbdatetime, subtitles
#from sickbeard.common import Overview, Quality, statusStrings, ARCHIVED, UNAIRED, SUBTITLED, SNATCHED_ANY, DOWNLOADED
#from lib import subliminal
<% def sg_var(varname, default=False): return getattr(sickbeard, varname, default) %>#slurp#
<% def sg_str(varname, default=''): return getattr(sickbeard, varname, default) %>#slurp#
#######
#set $network_timezone = $network_timezones.get_network_timezone($show.network)
#set $network_time = $network_timezones.parse_time($show.airs)
#set $odd = 0
#set $fuzzydate = 'airdate'
#set $scene, $scene_anime = (False, False)
#if not $show.air_by_date and not $show.is_sports and not $show.is_anime and $show.is_scene
#set $scene = True
#elif not $show.air_by_date and not $show.is_sports and $show.is_anime and $show.is_scene
#set $scene_anime = True
#end if
#set $attr_title_ep = ('', ' (Anime #)')[$show.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'])
#if $UNAIRED != int($ep['status'])
#end if
#set $nfo, $nfo_img = (('No', '-no'), ('Yes', ''))[int($ep['hasnfo'])]
#set $tbn, $tbn_img = (('No', '-no'), ('Yes', ''))[int($ep['hastbn'])]
#if $epLoc and $show._location and $epLoc.lower().startswith($show._location.lower())
#set $epLoc = $epLoc[len($show._location)+1:]
#elif $epLoc and (not $epLoc.lower().startswith($show._location.lower()) or not $show._location)
#set $epLoc = $epLoc
#end if
#set $episode = str($ep['episode']) + ('', ' (%s)' % $ep['absolute_number'])[$show.is_anime]
#set $downloaded = ('', 'file %ssize %s' % ($epLoc, $sickbeard.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#
#if 1 == int($ep['airdate']) then 'never' else $sbdatetime.sbdatetime.sbfdate($sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($ep['airdate'], $network_time, $network_timezone)))#
#if $sg_var('USE_SUBTITLES') and $show.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# $Quality.get_quality_ui($curQuality)
#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.subtitles and len(set(str($ep['subtitles']).split(',')).intersection(set($subtitles.wantedLanguages()))) < len($subtitles.wantedLanguages()) and $ep['location']
#end if
#end for