1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-18 07:15:13 -05:00
SickRage/gui/slick/interfaces/default/home.tmpl

613 lines
20 KiB
Cheetah
Raw Normal View History

#import sickbeard
#import datetime
#from sickbeard.common import *
#from sickbeard import db, sbdatetime, network_timezones
#set global $title="Home"
#set global $header="Show List"
#set global $sbPath = ".."
#set global $topmenu="home"#
#import os.path
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_top.tmpl")
#set $myDB = $db.DBConnection()
#set $today = str($datetime.date.today().toordinal())
#set $layout = $sickbeard.HOME_LAYOUT
#set status_quality = '(' + ','.join([str(x) for x in $Quality.SNATCHED + $Quality.SNATCHED_PROPER]) + ')'
#set status_download = '(' + ','.join([str(x) for x in $Quality.DOWNLOADED + [$ARCHIVED]]) + ')'
#set $sql_statement = 'SELECT showid, '
#set $sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 AND status IN ' + $status_quality + ') AS ep_snatched, '
#set $sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 AND status IN ' + $status_download + ') AS ep_downloaded, '
#set $sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 '
#set $sql_statement += ' AND ((airdate <= ' + $today + ' AND (status = ' + str($SKIPPED) + ' OR status = ' + str($WANTED) + ')) '
#set $sql_statement += ' OR (status IN ' + status_quality + ') OR (status IN ' + status_download + '))) AS ep_total, '
#set $sql_statement += ' (SELECT airdate FROM tv_episodes WHERE showid=tv_eps.showid AND airdate >= ' + $today + ' AND (status = ' + str($UNAIRED) + ' OR status = ' + str($WANTED) + ') ORDER BY airdate ASC LIMIT 1) AS ep_airs_next '
#set $sql_statement += ' FROM tv_episodes tv_eps GROUP BY showid'
#set $sql_result = $myDB.select($sql_statement)
#set $show_stat = {}
#set $max_download_count = 1000
#for $cur_result in $sql_result:
#set $show_stat[$cur_result['showid']] = $cur_result
#if $cur_result['ep_total'] > $max_download_count:
#set $max_download_count = $cur_result['ep_total']
#end if
#end for
#set $max_download_count = $max_download_count * 100
<style type="text/css">
.sort_data {display:none}
</style>
<script type="text/javascript" charset="utf-8">
2014-09-30 18:20:37 -04:00
\$(document).ready(function(){
var \$container = [\$('#container'), \$('#container-anime')];
jQuery.each(\$container, function (j) {
this.isotope({
sortBy : \$.cookie('sortby'),
itemSelector : '.show',
getSortData : {
name : function( \$elem ) {
return \$elem.attr('data-name');
},
network : function( \$elem ) {
return \$elem.attr('data-network');
},
date: function( \$elem ) {
return parseInt( \$elem.attr('data-date'), 10 ) || Number.POSITIVE_INFINITY;
},
progress : function( \$elem ) {
return parseInt( \$elem.attr('data-progress'), 10) * -1 || Number.POSITIVE_INFINITY;
}
}
});
});
var \$optionSets = \$('.option-set'),
\$optionLinks = \$optionSets.find('a');
\$optionLinks.click(function(){
var \$this = \$(this);
// don't proceed if already selected
if ( \$this.hasClass('selected') ) {
return false;
}
var \$optionSet = \$this.parents('.option-set');
\$optionSet.find('.selected').removeClass('selected');
\$this.addClass('selected');
// make option object dynamically, i.e. { filter: '.my-filter-class' }
var options = {},
key = \$optionSet.attr('data-option-key'),
value = \$this.attr('data-option-value');
// parse 'false' as false boolean
value = value === 'false' ? false : value;
options[ key ] = value;
if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
// changes in layout modes need extra logic
changeLayoutMode( \$this, options )
} else {
// otherwise apply new options & save sort cookie
\$('#container').isotope( options );
\$('#container-anime').isotope( options );
\$.cookie('sortby', value, { expires: 365 });
}
return false;
});
});
sortFlipper = true;
function invertSort(){
sortFlipper = !sortFlipper;
\$('#container').isotope({sortAscending: sortFlipper});
\$('#container-anime').isotope({sortAscending: sortFlipper});
}
<!--
\$.tablesorter.addParser({
id: 'loadingNames',
is: function(s) {
return false;
},
format: function(s) {
if (s.indexOf('Loading...') == 0)
return s.replace('Loading...','000');
else
#if not $sickbeard.SORT_ARTICLE:
return (s || '').replace(/^(The|A|An)\s/i,'');
#else:
return (s || '');
#end if
},
type: 'text'
});
\$.tablesorter.addParser({
id: 'cDate',
is: function(s) {
return false;
},
format: function(s) {
return s;
},
type: 'numeric'
});
\$.tablesorter.addParser({
id: 'quality',
is: function(s) {
return false;
},
format: function(s) {
return s.replace('HD1080p',5).replace('HD720p',4).replace('HD',3).replace('SD',2).replace('Any',1).replace('Best',0).replace('Custom',7);
},
type: 'numeric'
});
\$.tablesorter.addParser({
id: 'eps',
is: function(s) {
return false;
},
format: function(s) {
match = s.match(/^(.*)/);
if (match == null || match[1] == "?")
return -10;
var nums = match[1].split(" / ");
if (nums[0].indexOf("+") != -1) {
var num_parts = nums[0].split("+");
nums[0] = num_parts[0];
}
nums[0] = parseInt(nums[0])
nums[1] = parseInt(nums[1])
if (nums[0] === 0)
return nums[1];
var finalNum = parseInt($max_download_count*nums[0]/nums[1]);
if (finalNum > 0)
finalNum += nums[0];
return finalNum;
},
type: 'numeric'
});
\$(document).ready(function(){
\$("img#network").on('error', function(){
\$(this).parent().text(\$(this).attr('alt'));
\$(this).remove();
});
\$("#showListTableShows:has(tbody tr)").tablesorter({
2014-09-30 18:20:37 -04:00
sortList: [[6,1],[1,0]],
textExtraction: {
0: function(node) { return \$(node).find("span").text().toLowerCase(); },
#if ( $layout != 'simple'):
2014-09-30 18:20:37 -04:00
2: function(node) { return \$(node).find("img").attr("alt"); },
#end if
2014-09-30 18:20:37 -04:00
3: function(node) { return \$(node).find("span").text(); },
2014-10-02 06:30:06 -04:00
5: function(node) { return \$(node).find("img").attr("alt"); }
},
widgets: ['saveSort', 'zebra'],
headers: {
0: { sorter: 'cDate' },
2014-09-30 18:20:37 -04:00
1: { sorter: 'loadingNames' },
2: { sorter: 'network' },
3: { sorter: 'quality' },
4: { sorter: 'eps' },
2014-10-02 06:30:06 -04:00
5: { sorter: 'active' },
6: { sorter: 'status' },
}
});
\$("#showListTableAnime:has(tbody tr)").tablesorter({
2014-09-30 18:20:37 -04:00
sortList: [[6,1],[1,0]],
textExtraction: {
2014-09-30 18:20:37 -04:00
0: function(node) { return \$(node).find("span").text().toLowerCase(); },
#if ( $layout != 'simple'):
2014-09-30 18:20:37 -04:00
2: function(node) { return \$(node).find("img").attr("alt"); },
#end if
2014-09-30 18:20:37 -04:00
3: function(node) { return \$(node).find("span").text(); },
2014-10-02 06:30:06 -04:00
5: function(node) { return \$(node).find("img").attr("alt"); }
},
widgets: ['saveSort', 'zebra'],
headers: {
0: { sorter: 'cDate' },
2014-09-30 18:20:37 -04:00
1: { sorter: 'loadingNames' },
2: { sorter: 'network' },
3: { sorter: 'quality' },
4: { sorter: 'eps' },
2014-10-02 06:30:06 -04:00
5: { sorter: 'active' },
6: { sorter: 'status' },
}
});
#set $fuzzydate = 'airdate'
#if $sickbeard.FUZZY_DATING:
fuzzyMoment({
containerClass : '.${fuzzydate}',
dateHasTime : false,
dateFormat : '${sickbeard.DATE_PRESET}',
timeFormat : '${sickbeard.TIME_PRESET}',
trimZero : #if $sickbeard.TRIM_ZERO then "true" else "false"#
});
#end if
});
//-->
</script>
#if $varExists('header')
<h1 class="header">$header</h1>
#else
<h1 class="title">$title</h1>
#end if
<div id="HomeLayout" style="float: right; margin-top: -25px;">
2014-09-30 18:20:37 -04:00
<span>Layout:
<a class="inner" href="$sbRoot/setHomeLayout/?layout=poster">Poster</a> &middot;
<a class="inner" href="$sbRoot/setHomeLayout/?layout=banner">Banner</a> &middot;
<a class="inner" href="$sbRoot/setHomeLayout/?layout=simple">Simple</a>
</span>
2014-09-30 18:20:37 -04:00
#if $layout == 'poster':
<ul id="sort-by" class="option-set" data-option-key="sortBy">
2014-09-30 18:20:37 -04:00
Sort By:
<li><a href="#sortBy=name" data-option-value="name">Name</a></li> &middot;
<li><a href="#sortBy=date" data-option-value="date">Next Episode</a></li> &middot;
<li><a href="#sortBy=network" data-option-value="network">Network</a></li> &middot;
<li><a href="#sortBy=progress" data-option-value="progress">Progress</a></li> &middot;
2014-09-30 18:20:37 -04:00
</ul>
&nbsp;<a style="display: inline-block; float: right;" class="clearfix" href="javascript:invertSort();">Flip</a>
2014-09-30 18:20:37 -04:00
#end if
</div>
2014-06-12 14:30:59 -04:00
#for $curShowlist in $showlists:
#set $curListType = $curShowlist[0]
#set $myShowList = $list($curShowlist[1])
#if $curListType == "Anime":
2014-09-30 18:20:37 -04:00
<h1 class="header">Anime List</h1>
#end if
2014-09-30 18:20:37 -04:00
#if $layout == 'poster':
<link rel="stylesheet" type="text/css" href="$sbRoot/css/posterlist.css?$sbPID" />
<div id=#if $curListType == "Anime" and $layout == 'poster' then "container-anime" else "container"# class="clearfix">
#for $curLoadingShow in $sickbeard.showQueueScheduler.action.loadingShowList:
#if $curLoadingShow.show != None and $curLoadingShow.show in $sickbeard.showList:
#continue
#end if
#if $curLoadingShow.show == None:
<div class="show" data-name="0" data-date="010101" data-network="0" data-progress="101">
<img alt="" title="$curLoadingShow.show_name" class="show-image" style="border-bottom: 1px solid #111;" src="$sbRoot/images/poster.png" />
<div class="show-details">
<div class="show-add">Loading... ($curLoadingShow.show_name)</div>
</div>
</div>
#end if
#end for
$myShowList.sort(lambda x, y: cmp(x.name, y.name))
#for $curShow in $myShowList:
#set $cur_airs_next = ''
#set $cur_snatched = 0
#set $cur_downloaded = 0
#set $cur_total = 0
#set $download_stat_tip = ''
#if $curShow.indexerid in $show_stat:
#set $cur_airs_next = $show_stat[$curShow.indexerid]['ep_airs_next']
2014-09-30 18:20:37 -04:00
#set $cur_snatched = $show_stat[$curShow.indexerid]['ep_snatched']
#if not $cur_snatched:
#set $cur_snatched = 0
#end if
#set $cur_downloaded = $show_stat[$curShow.indexerid]['ep_downloaded']
#if not $cur_downloaded:
#set $cur_downloaded = 0
#end if
#set $cur_total = $show_stat[$curShow.indexerid]['ep_total']
#if not $cur_total:
#set $cur_total = 0
#end if
#end if
#if $cur_total != 0:
#set $download_stat = str($cur_downloaded)
#set $download_stat_tip = "Downloaded: " + str($cur_downloaded)
#if $cur_snatched > 0:
2014-10-01 19:36:55 -04:00
#set $download_stat = download_stat
2014-09-30 18:20:37 -04:00
#set $download_stat_tip = download_stat_tip + "&#013;" + "Snatched: " + str($cur_snatched)
#end if
#set $download_stat = download_stat + " / " + str($cur_total)
#set $download_stat_tip = download_stat_tip + "&#013;" + "Total: " + str($cur_total)
#else
#set $download_stat = '?'
#set $download_stat_tip = "no data"
#end if
#set $nom = $cur_downloaded
#set $den = $cur_total
#if $den == 0:
#set $den = 1
#end if
#set $progressbar_percent = $nom * 100 / $den
2014-10-01 19:36:55 -04:00
#if "a" in sickbeard.DATE_PRESET:
#set $showheight = "344px"
#set $tableheight = "62px"
#else if "B" in sickbeard.DATE_PRESET:
#set $showheight = "374px"
#set $tableheight = "92px"
#else if "A" in sickbeard.DATE_PRESET:
#set $showheight = "344px"
#set $tableheight = "62px"
#else
#set $showheight = "323px"
#set $tableheight = "42px"
#end if
2014-09-30 18:20:37 -04:00
2014-10-01 19:36:55 -04:00
<div class="show" style="height: $showheight" id="show$curShow.indexerid" data-name="$curShow.name" data-date="#if $cur_airs_next then $time.mktime($network_timezones.parse_date_time($cur_airs_next,$curShow.airs,$curShow.network).timetuple()) else ""#" data-network="$curShow.network" data-progress="$progressbar_percent">
2014-09-30 18:20:37 -04:00
<div class="show-image">
<a href="$sbRoot/home/displayShow?show=$curShow.indexerid"><img alt="" class="show-image" src="$sbRoot/showPoster/?show=$curShow.indexerid&amp;which=poster_thumb" /></a>
<div class="show-image-slide">
<p>$curShow.name</p>
</div>
</div>
<div id="progressbar$curShow.indexerid"></div>
<script type="text/javascript">
<!--
\$(function() {
\$("\#progressbar$curShow.indexerid").progressbar({
value: $progressbar_percent });
classvalue = $progressbar_percent
if (classvalue<20) {
classtoadd = "progress-20"
}
if (classvalue>20 && classvalue<60) {
classtoadd = "progress-40"
}
if (classvalue>40 && classvalue<80) {
classtoadd = "progress-60"
}
if (classvalue>80) {
classtoadd = "progress-80"
}
\$("\#progressbar$curShow.indexerid > .ui-progressbar-value").addClass(classtoadd);
});
//-->
</script>
2014-10-01 19:36:55 -04:00
<table width="184px" height="$tableheight" cellspacing="1" border="0" cellpadding="0" style="padding-left: 2px; cursor: default;">
<col width="60px" />
<col width="59px" />
<col width="60px" />
<tr>
<td style="text-align:center; vertical-align:middle;">
#if $cur_airs_next
#set $ldatetime = $network_timezones.parse_date_time($cur_airs_next,$curShow.airs,$curShow.network)
<div class="show-date">Next Ep: $sbdatetime.sbdatetime.sbfdate($ldatetime)</div>
#else if $curShow.status != "Ended" and int($curShow.paused) == 1:
<div class="show-status">Paused</div>
#else if $curShow.status:
<div class="show-status">$curShow.status</div>
#else
<div class="show-status">?</div>
#end if
</td>
<td style="text-align:center; vertical-align:middle;">
#if $curShow.network:
<img class="show-network-image" src="$sbRoot/images/network/${curShow.network.lower()}.png" alt="$curShow.network" title="$curShow.network" />
#else:
$curShow.network
#end if
</td>
<td style="text-align:center; vertical-align:middle;">
<span class="show-dlstats" title="$download_stat_tip">$download_stat</span>
<div class="float-right">
#if $curShow.quality in $qualityPresets:
<span class="show-dlstats">$qualityPresetStrings[$curShow.quality]</span>
#else:
<span class="show-dlstats">Custom</span>
#end if
</td>
</tr>
</table>
2014-09-30 18:20:37 -04:00
</div>
#end for
</div>
#else
<table id="showListTable$curListType" class="tablesorter" cellspacing="1" border="0" cellpadding="0">
<thead><tr><th class="nowrap">Next Ep</th><th>$curListType</th><th>Network</th><th>Quality</th><th>Downloads</th><th>Active</th><th>Status</th></tr></thead>
<tfoot>
<tr>
<th rowspan="1" colspan="1" align="center"><a href="$sbRoot/home/addShows/">&nbsp Add Show</a></th>
<th rowspan="1" colspan="7"></th>
</tr>
</tfoot>
<tbody>
#for $curLoadingShow in $sickbeard.showQueueScheduler.action.loadingShowList:
#if $curLoadingShow.show != None and $curLoadingShow.show in $sickbeard.showList:
#continue
#end if
<tr>
<td align="center">(loading)</td>
<td></td>
<td>
#if $curLoadingShow.show == None:
Loading... ($curLoadingShow.show_name)
#else:
<a href="displayShow?show=$curLoadingShow.show.indexerid">$curLoadingShow.show.name</a>
#end if
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
#end for
$myShowList.sort(lambda x, y: cmp(x.name, y.name))
#for $curShow in $myShowList:
#set $cur_airs_next = ''
#set $cur_snatched = 0
#set $cur_downloaded = 0
#set $cur_total = 0
#set $download_stat_tip = ''
#if $curShow.indexerid in $show_stat:
#set $cur_airs_next = $show_stat[$curShow.indexerid]['ep_airs_next']
#set $cur_snatched = $show_stat[$curShow.indexerid]['ep_snatched']
#if not $cur_snatched:
#set $cur_snatched = 0
#end if
#set $cur_downloaded = $show_stat[$curShow.indexerid]['ep_downloaded']
#if not $cur_downloaded:
#set $cur_downloaded = 0
#end if
#set $cur_total = $show_stat[$curShow.indexerid]['ep_total']
#if not $cur_total:
#set $cur_total = 0
#end if
#end if
#if $cur_total != 0:
#set $download_stat = str($cur_downloaded)
#set $download_stat_tip = "Downloaded: " + str($cur_downloaded)
#if $cur_snatched > 0:
#set $download_stat = download_stat + "+" + str($cur_snatched)
#set $download_stat_tip = download_stat_tip + "&#013;" + "Snatched: " + str($cur_snatched)
#end if
#set $download_stat = download_stat + " / " + str($cur_total)
#set $download_stat_tip = download_stat_tip + "&#013;" + "Total: " + str($cur_total)
#else
#set $download_stat = '?'
#set $download_stat_tip = "no data"
#end if
#set $nom = $cur_downloaded
#set $den = $cur_total
#if $den == 0:
#set $den = 1
#end if
#set $progressbar_percent = $nom * 100 / $den
<tr>
2014-09-30 18:20:37 -04:00
#if $cur_airs_next
#set $ldatetime = $network_timezones.parse_date_time($cur_airs_next,$curShow.airs,$curShow.network)
2014-09-30 18:20:37 -04:00
<td align="center" class="nowrap" style="color: #FFFFFF;"><div class="${fuzzydate}">$sbdatetime.sbdatetime.sbfdate($ldatetime)</div><span class="sort_data">$time.mktime($ldatetime.timetuple())</span> </td>
#else:
2014-09-30 18:20:37 -04:00
<td align="center" class="nowrap" style="color: #FFFFFF;"></td>
#end if
2014-09-30 18:20:37 -04:00
#if $layout == 'banner':
<td>
<span style="display: none;">$curShow.name</span>
2014-09-30 18:20:37 -04:00
<div class="imgbanner $layout">
<a href="$sbRoot/home/displayShow?show=$curShow.indexerid">
2014-09-30 18:20:37 -04:00
<img src="$sbRoot/showPoster/?show=$curShow.indexerid&amp;which=banner" class="$layout" alt="$curShow.indexerid" title="$curShow.name"/>
</div>
</td>
#else if $layout == 'simple':
<td class="tvShow"><a href="$sbRoot/home/displayShow?show=$curShow.indexerid">$curShow.name</a></td>
#end if
<!--<td align="center">$curShow.network</td>//-->
2014-09-30 18:20:37 -04:00
<td align="center" style="color: #FFFFFF;">
#if $layout != 'simple':
#if $curShow.network:
2014-09-30 18:20:37 -04:00
<img id="network" width="54" height="27" src="$sbRoot/images/network/${curShow.network.lower()}.png" alt="$curShow.network" title="$curShow.network" />
#else:
2014-09-30 18:20:37 -04:00
<img id="network" width="54" height="27" src="$sbRoot/images/network/nonetwork.png" alt="No Network" title="No Network" />
#end if
#else:
$curShow.network
#end if
</td>
#if $curShow.quality in $qualityPresets:
<td align="center"><span class="quality $qualityPresetStrings[$curShow.quality]">$qualityPresetStrings[$curShow.quality]</span></td>
#else:
<td align="center"><span class="quality Custom">Custom</span></td>
#end if
<td align="center"><span style="display: none;">$download_stat</span><div id="progressbar$curShow.indexerid" style="position:relative;"></div>
<script type="text/javascript">
2014-09-30 18:20:37 -04:00
<!--
\$(function() {
\$("\#progressbar$curShow.indexerid").progressbar({
value: $progressbar_percent });
\$("\#progressbar$curShow.indexerid").append( "<div class='progressbarText' title='$download_stat_tip'>$download_stat</div>" )
classvalue = $progressbar_percent
if (classvalue<20) {
classtoadd = "progress-20"
}
if (classvalue>20 && classvalue<60) {
classtoadd = "progress-40"
}
if (classvalue>40 && classvalue<80) {
classtoadd = "progress-60"
}
if (classvalue>80) {
classtoadd = "progress-80"
}
\$("\#progressbar$curShow.indexerid > .ui-progressbar-value").addClass(classtoadd);
});
//-->
</script>
</td>
<td align="center"><img src="$sbRoot/images/#if int($curShow.paused) == 0 and $curShow.status != "Ended" then "yes16.png\" alt=\"Y\"" else "no16.png\" alt=\"N\""# width="16" height="16" /></td>
2014-09-30 18:20:37 -04:00
<td align="center" style="color: #FFFFFF;">$curShow.status</td>
</tr>
#end for
</tbody>
</table>
2014-09-30 18:20:37 -04:00
#end if
#end for
#include $os.path.join($sickbeard.PROG_DIR,"gui/slick/interfaces/default/inc_bottom.tmpl")