Initial implementation of homepage top lists

* Top lists for all stats, default max 5 items
This commit is contained in:
Jonathan Wong 2015-08-24 12:13:38 -07:00
parent ff0ed1abe4
commit 8ae2f718f4
6 changed files with 585 additions and 162 deletions

View file

@ -1350,40 +1350,27 @@ a .season-episodes-card-overlay:hover {
list-style: none; list-style: none;
margin: 0; margin: 0;
} }
.home-platforms-instance-poster { .home-platforms-instance {
margin-left: 0px; background-color: #282828;
position: relative;
float: left;
width: 300px;
padding: 10px;
margin-right: 20px;
margin-bottom: 20px;
webkit-box-sizing: content-box;
box-sizing: content-box;
z-index: 0;
} }
.home-platforms-instance-poster .poster-face { .home-platforms-instance li {
position: relative;
}
.home-platforms-instance-info {
float: left;
position: relative;
padding-left: 80px;
width: 100%;
height: 120px; height: 120px;
width: 80px;
}
.home-platforms-instance-box {
background-size: contain;
position: absolute;
left: 10px;
bottom: 35px;
height: 80px;
width: 80px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
webkit-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
-moz-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
}
.home-platforms-instance-oval {
background-size: contain;
position: absolute;
left: 10px;
bottom: 35px;
height: 80px;
width: 80px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
webkit-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
-moz-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
} }
.home-platforms-instance-name { .home-platforms-instance-name {
float: left; float: left;
@ -1395,64 +1382,214 @@ a .season-episodes-card-overlay:hover {
line-height: 15px; line-height: 15px;
font-weight: bold; font-weight: bold;
width: 100%; width: 100%;
padding: 10px 0 0 10px; padding: 0 0 0 20px;
}
.home-platforms-instance-name h5 {
font-size: 16px;
margin: 20px 0 2px 0;
} }
.home-platforms-instance-playcount { .home-platforms-instance-playcount {
float: left; float: left;
width: 180px;
}
.home-platforms-instance-mediainfo {
float: left;
background-color: #282828;
position: absolute;
bottom: 0;
left: 0;
padding-left: 170px;
width: 100%;
height: 175px;
}
.home-platforms-instance-media {
position: relative; position: relative;
float: left; padding: 6px 0 0 20px;
width: 375px; width: 100%;
height: 225px;
padding-bottom: 10px;
margin-right: 25px;
margin-bottom: 25px;
webkit-box-sizing: content-box;
box-sizing: content-box;
} }
.home-platforms-instance-info { .home-platforms-instance-playcount h3 {
float: left; font-size: 30px;
background-color: #282828; font-weight: bold;
position: absolute; color: #F9AA03;
line-height: 22px;
position: relative;
top: 5px; top: 5px;
left: 0; margin: 0 5px 0 0;
padding-left: 100px;
width: 100%;
height: 120px;
}
.home-platforms-instance {
background-color: #282828;
position: relative;
float: left; float: left;
width: 300px; }
.home-platforms-instance-playcount p {
color: #aaa;
font-size: 12px;
float: left;
position: relative;
top: 14px;
left: 0px;
margin-right: 5px;
}
.home-platforms-instance-poster {
margin-left: 0px;
position: absolute;
}
.home-platforms-instance-poster .home-platforms-poster-face {
background-position: center;
background-size: cover;
height: 120px; height: 120px;
padding: 10px; width: 80px;
margin-right: 20px;
margin-bottom: 20px;
webkit-box-sizing: content-box;
box-sizing: content-box;
} }
a .home-platforms-instance-oval:hover { .home-platforms-instance-box {
background-position: center;
background-size: cover;
margin: 20px 0 0 0px;
height: 80px;
width: 80px;
position: relative;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
webkit-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
-moz-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
overflow: hidden;
}
.home-platforms-instance-oval {
background-position: center;
background-size: cover;
margin: 20px 0 0 0px;
height: 80px;
width: 80px;
position: relative;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
webkit-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
-moz-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
overflow: hidden;
}
.home-platforms-instance-list {
float: left;
position: relative;
width: 100%;
padding: 0 10px 20px 10px;
}
.home-platforms-instance-list li {
margin-top: 25px;
position: relative;
height: 60px;
}
.home-platforms-instance-list-number {
background-color: #e9a049;
float: left;
position: absolute;
top: -10px;
left: 10px;
height: 20px;
width: 20px;
display: block;
text-align: center;
padding-top: 1px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
.home-platforms-instance-list-number h4 {
color: #000;
font-size: 15px;
font-weight: bold;
margin: 0;
}
.home-platforms-instance-list-info {
float: left;
position: relative;
padding-left: 75px;
width: 100%;
height: 60px;
}
.home-platforms-instance-list-name {
float: left;
color: #fff;
text-overflow: ellipsis;
overflow: hidden;
position: relative;
font-size: 13px;
line-height: 15px;
font-weight: bold;
width: 100%;
padding: 2px 0 0 10px;
}
.home-platforms-instance-list-name h5 {
margin: 5px 0px;
}
.home-platforms-instance-list-playcount {
float: left;
position: relative;
padding: 4px 0 0 10px;
width: 100%;
}
.home-platforms-instance-list-playcount h3 {
font-size: 20px;
font-weight: bold;
color: #F9AA03;
line-height: 22px;
position: relative;
margin: 0 5px 0 0;
float: left;
}
.home-platforms-instance-list-playcount p {
color: #aaa;
font-size: 12px;
float: left;
position: relative;
top: 5px;
left: 0px;
margin-right: 5px;
}
.home-platforms-instance-list-poster {
position: absolute;
left: 20px;
}
.home-platforms-instance-list-poster .home-platforms-list-poster-face {
background-position: center;
background-size: cover;
height: 60px;
width: 40px;
}
.home-platforms-instance-list-box {
background-position: center;
background-size: cover;
margin: 10px 0 0 20px;
height: 40px;
width: 40px;
position: relative;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
webkit-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
-moz-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
overflow: hidden;
}
.home-platforms-instance-list-oval {
background-position: center;
background-size: cover;
margin: 10px 0 0 20px;
height: 40px;
width: 40px;
position: relative;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
webkit-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
-moz-box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.3),inset 0 0 0 1px rgba(255,255,255,.1);
overflow: hidden;
}
a .home-platforms-instance-box:hover,
a .home-platforms-instance-oval:hover,
a .home-platforms-instance-list-box:hover,
a .home-platforms-instance-list-oval:hover,
.home-platforms-poster-face:hover,
.home-platforms-list-poster-face:hover
{
webkit-box-shadow: inset 0 0 0 2px #e9a049; webkit-box-shadow: inset 0 0 0 2px #e9a049;
-moz-box-shadow: inset 0 0 0 2px #e9a049; -moz-box-shadow: inset 0 0 0 2px #e9a049;
box-shadow: inset 0 0 0 2px #e9a049; box-shadow: inset 0 0 0 2px #e9a049;
} }
a .home-platforms-instance-box:hover { .home-platforms-instance .slider {
webkit-box-shadow: inset 0 0 0 2px #e9a049; background-color: #282828;
-moz-box-shadow: inset 0 0 0 2px #e9a049; width: 320px;
box-shadow: inset 0 0 0 2px #e9a049; display: none;
position: absolute;
top: 130px;
left: -10px;
z-index: 2;
} }
.history-table-title { .history-table-title {
text-overflow: ellipsis; text-overflow: ellipsis;

View file

@ -48,7 +48,7 @@ DOCUMENTATION :: END
def hd(minutes): def hd(minutes):
if int(minutes) > 60: if int(minutes) > 60:
hours = int(helpers.cast_to_float(minutes) / 60) hours = int(helpers.cast_to_float(minutes) / 60)
minutes = int(helpers.cast_to_float(minutes) % hours) minutes = int(helpers.cast_to_float(minutes) % 60 )
if minutes > 0: if minutes > 0:
return "<h3>" + str(hours) + "</h3><p>hrs</p><h3>" + str(minutes) + "</h3><p>mins</p>" return "<h3>" + str(hours) + "</h3><p>hrs</p><h3>" + str(minutes) + "</h3><p>mins</p>"
else: else:
@ -58,199 +58,479 @@ DOCUMENTATION :: END
%> %>
% if data: % if data:
% if data[0]['rows'] or data[2]['rows']: % if data[0]['rows'] or data[1]['rows'] or data[2]['rows'] or data[3]['rows'] or data[4]['rows'] or data[5]['rows']:
<ul class="list-unstyled"> <ul class="list-unstyled">
% for a in data: % for top_stat in data:
% if a['stat_id'] == 'top_tv' and a['rows']: % if top_stat['stat_id'] == 'top_tv' and top_stat['rows']:
<div class="home-platforms-instance"> <div class="home-platforms-instance">
<li> <li>
<div class="home-platforms-instance-info"> <div class="home-platforms-instance-info">
<div class="home-platforms-instance-name"> <div class="home-platforms-instance-name">
<h4>Most Watched TV</h4> <h4>Most Watched TV</h4>
<h5><a href="info?item_id=${a['rows'][0]['rating_key']}"> <h5>
${a['rows'][0]['title']} <a href="info?item_id=${top_stat['rows'][0]['rating_key']}">
</a></h5> ${top_stat['rows'][0]['title']}
</a>
</h5>
</div> </div>
<div class="user-platforms-instance-playcount"> <div class="home-platforms-instance-playcount">
% if a['stat_type'] == 'total_plays': % if top_stat['stat_type'] == 'total_plays':
<h3>${a['rows'][0]['total_plays']}</h3> <h3>${top_stat['rows'][0]['total_plays']}</h3>
<p> plays</p> <p> plays</p>
% else: % else:
${a['rows'][0]['total_duration'] | hd} ${top_stat['rows'][0]['total_duration'] | hd}
% endif % endif
</div> </div>
</div> </div>
<a href="info?item_id=${a['rows'][0]['rating_key']}"> <a href="info?item_id=${top_stat['rows'][0]['rating_key']}">
% if a['rows'][0]['grandparent_thumb']: % if top_stat['rows'][0]['grandparent_thumb']:
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="poster-face" style="background-image: url(pms_image_proxy?img=${a['rows'][0]['grandparent_thumb']}&width=300&height=450&fallback=poster);"></div> <div class="home-platforms-poster-face" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][0]['grandparent_thumb']}&width=300&height=450&fallback=poster);"></div>
</div> </div>
% else: % else:
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div> <div class="home-platforms-poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div>
</div> </div>
% endif % endif
</a> </a>
%if len(top_stat['rows']) > 1:
<ul class="list-unstyled">
<div class="slider">
<div class="home-platforms-instance-list">
% for row in top_stat['rows']:
%if loop.index > 0:
<li>
<div class="home-platforms-instance-list-info">
<div class="home-platforms-instance-list-name">
<h5>
<a href="info?item_id=${top_stat['rows'][loop.index]['rating_key']}">
${top_stat['rows'][loop.index]['title']}
</a>
</h5>
</div>
<div class="home-platforms-instance-list-playcount">
% if top_stat['stat_type'] == 'total_plays':
<h3>${top_stat['rows'][loop.index]['total_plays']}</h3>
<p> plays</p>
% else:
${top_stat['rows'][loop.index]['total_duration'] | hd}
% endif
</div>
</div>
<a href="info?item_id=${top_stat['rows'][loop.index]['rating_key']}">
% if top_stat['rows'][loop.index]['grandparent_thumb']:
<div class="home-platforms-instance-list-poster">
<div class="home-platforms-list-poster-face" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][loop.index]['grandparent_thumb']}&width=300&height=450&fallback=poster);"></div>
</div>
% else:
<div class="home-platforms-instance-poster2">
<div class="home-platforms-list-poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div>
</div>
% endif
</a>
<div class="home-platforms-instance-list-number">
<h4>${loop.index + 1}</h4>
</div>
</li>
% endif
% endfor
</div>
</div>
</ul>
% endif
</li> </li>
</div> </div>
% elif a['stat_id'] == 'popular_tv' and a['rows']: % elif top_stat['stat_id'] == 'popular_tv' and top_stat['rows']:
<div class="home-platforms-instance"> <div class="home-platforms-instance">
<li> <li>
<div class="home-platforms-instance-info"> <div class="home-platforms-instance-info">
<div class="home-platforms-instance-name"> <div class="home-platforms-instance-name">
<h4>Most Popular TV</h4> <h4>Most Popular TV</h4>
<h5><a href="info?item_id=${a['rows'][0]['rating_key']}"> <h5>
${a['rows'][0]['title']} <a href="info?item_id=${top_stat['rows'][0]['rating_key']}">
</a></h5> ${top_stat['rows'][0]['title']}
</a>
</h5>
</div> </div>
<div class="user-platforms-instance-playcount"> <div class="home-platforms-instance-playcount">
<h3>${a['rows'][0]['users_watched']}</h3> <h3>${top_stat['rows'][0]['users_watched']}</h3>
<p> users</p> <p> users</p>
</div> </div>
</div> </div>
<a href="info?item_id=${a['rows'][0]['rating_key']}"> <a href="info?item_id=${top_stat['rows'][0]['rating_key']}">
% if a['rows'][0]['grandparent_thumb'] != '': % if top_stat['rows'][0]['grandparent_thumb'] != '':
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="poster-face" style="background-image: url(pms_image_proxy?img=${a['rows'][0]['grandparent_thumb']}&width=300&height=450&fallback=poster);"></div> <div class="home-platforms-poster-face" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][0]['grandparent_thumb']}&width=300&height=450&fallback=poster);"></div>
</div> </div>
% else: % else:
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div> <div class="home-platforms-poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div>
</div> </div>
% endif % endif
</a> </a>
%if len(top_stat['rows']) > 1:
<ul class="list-unstyled">
<div class="slider">
<div class="home-platforms-instance-list">
% for row in top_stat['rows']:
%if loop.index > 0:
<li>
<div class="home-platforms-instance-list-info">
<div class="home-platforms-instance-list-name">
<h5>
<a href="info?item_id=${top_stat['rows'][loop.index]['rating_key']}">
${top_stat['rows'][loop.index]['title']}
</a>
</h5>
</div>
<div class="home-platforms-instance-list-playcount">
<h3>${top_stat['rows'][loop.index]['users_watched']}</h3>
<p> users</p>
</div>
</div>
<a href="info?item_id=${top_stat['rows'][loop.index]['rating_key']}">
% if top_stat['rows'][loop.index]['grandparent_thumb']:
<div class="home-platforms-instance-list-poster">
<div class="home-platforms-list-poster-face" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][loop.index]['grandparent_thumb']}&width=300&height=450&fallback=poster);"></div>
</div>
% else:
<div class="home-platforms-instance-poster2">
<div class="home-platforms-list-poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div>
</div>
% endif
</a>
<div class="home-platforms-instance-list-number">
<h4>${loop.index + 1}</h4>
</div>
</li>
% endif
% endfor
</div>
</div>
</ul>
% endif
</li> </li>
</div> </div>
% elif a['stat_id'] == 'top_movies' and a['rows']: % elif top_stat['stat_id'] == 'top_movies' and top_stat['rows']:
<div class="home-platforms-instance"> <div class="home-platforms-instance">
<li> <li>
<div class="home-platforms-instance-info"> <div class="home-platforms-instance-info">
<div class="home-platforms-instance-name"> <div class="home-platforms-instance-name">
<h4>Most Watched Movie</h4> <h4>Most Watched Movie</h4>
<h5><a href="info?item_id=${a['rows'][0]['rating_key']}"> <h5>
${a['rows'][0]['title']} <a href="info?item_id=${top_stat['rows'][0]['rating_key']}">
</a></h5> ${top_stat['rows'][0]['title']}
</a>
</h5>
</div> </div>
<div class="user-platforms-instance-playcount"> <div class="home-platforms-instance-playcount">
% if a['stat_type'] == 'total_plays': % if top_stat['stat_type'] == 'total_plays':
<h3>${a['rows'][0]['total_plays']}</h3> <h3>${top_stat['rows'][0]['total_plays']}</h3>
<p> plays</p> <p> plays</p>
% else: % else:
${a['rows'][0]['total_duration'] | hd} ${top_stat['rows'][0]['total_duration'] | hd}
% endif % endif
</div> </div>
</div> </div>
<a href="info?item_id=${a['rows'][0]['rating_key']}"> <a href="info?item_id=${top_stat['rows'][0]['rating_key']}">
% if a['rows'][0]['thumb']: % if top_stat['rows'][0]['thumb']:
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="poster-face" style="background-image: url(pms_image_proxy?img=${a['rows'][0]['thumb']}&width=300&height=450&fallback=poster);"></div> <div class="home-platforms-poster-face" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][0]['thumb']}&width=300&height=450&fallback=poster);"></div>
</div> </div>
% else: % else:
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div> <div class="home-platforms-poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div>
</div> </div>
% endif % endif
</a> </a>
%if len(top_stat['rows']) > 1:
<ul class="list-unstyled">
<div class="slider">
<div class="home-platforms-instance-list">
% for row in top_stat['rows']:
%if loop.index > 0:
<li>
<div class="home-platforms-instance-list-info">
<div class="home-platforms-instance-list-name">
<h5>
<a href="info?item_id=${top_stat['rows'][loop.index]['rating_key']}">
${top_stat['rows'][loop.index]['title']}
</a>
</h5>
</div>
<div class="home-platforms-instance-list-playcount">
% if top_stat['stat_type'] == 'total_plays':
<h3>${top_stat['rows'][loop.index]['total_plays']}</h3>
<p> plays</p>
% else:
${top_stat['rows'][loop.index]['total_duration'] | hd}
% endif
</div>
</div>
<a href="info?item_id=${top_stat['rows'][loop.index]['rating_key']}">
% if top_stat['rows'][loop.index]['thumb']:
<div class="home-platforms-instance-list-poster">
<div class="home-platforms-list-poster-face" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][loop.index]['thumb']}&width=300&height=450&fallback=poster);"></div>
</div>
% else:
<div class="home-platforms-instance-poster2">
<div class="home-platforms-list-poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div>
</div>
% endif
</a>
<div class="home-platforms-instance-list-number">
<h4>${loop.index + 1}</h4>
</div>
</li>
% endif
% endfor
</div>
</div>
</ul>
% endif
</li> </li>
</div> </div>
% elif a['stat_id'] == 'popular_movies' and a['rows']: % elif top_stat['stat_id'] == 'popular_movies' and top_stat['rows']:
<div class="home-platforms-instance"> <div class="home-platforms-instance">
<li> <li>
<div class="home-platforms-instance-info"> <div class="home-platforms-instance-info">
<div class="home-platforms-instance-name"> <div class="home-platforms-instance-name">
<h4>Most Popular Movie</h4> <h4>Most Popular Movie</h4>
<h5><a href="info?item_id=${a['rows'][0]['rating_key']}"> <h5>
${a['rows'][0]['title']} <a href="info?item_id=${top_stat['rows'][0]['rating_key']}">
</a></h5> ${top_stat['rows'][0]['title']}
</a>
</h5>
</div> </div>
<div class="user-platforms-instance-playcount"> <div class="home-platforms-instance-playcount">
<h3>${a['rows'][0]['users_watched']}</h3> <h3>${top_stat['rows'][0]['users_watched']}</h3>
<p> users</p> <p> users</p>
</div> </div>
</div> </div>
<a href="info?item_id=${a['rows'][0]['rating_key']}"> <a href="info?item_id=${top_stat['rows'][0]['rating_key']}">
% if a['rows'][0]['thumb']: % if top_stat['rows'][0]['thumb']:
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="poster-face" style="background-image: url(pms_image_proxy?img=${a['rows'][0]['thumb']}&width=300&height=450&fallback=poster);"></div> <div class="home-platforms-poster-face" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][0]['thumb']}&width=300&height=450&fallback=poster);"></div>
</div> </div>
% else: % else:
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div> <div class="home-platforms-poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div>
</div> </div>
% endif % endif
</a> </a>
%if len(top_stat['rows']) > 1:
<ul class="list-unstyled">
<div class="slider">
<div class="home-platforms-instance-list">
% for row in top_stat['rows']:
%if loop.index > 0:
<li>
<div class="home-platforms-instance-list-info">
<div class="home-platforms-instance-list-name">
<h5>
<a href="info?item_id=${top_stat['rows'][loop.index]['rating_key']}">
${top_stat['rows'][loop.index]['title']}
</a>
</h5>
</div>
<div class="home-platforms-instance-list-playcount">
<h3>${top_stat['rows'][loop.index]['users_watched']}</h3>
<p> users</p>
</div>
</div>
<a href="info?item_id=${top_stat['rows'][loop.index]['rating_key']}">
% if top_stat['rows'][loop.index]['thumb']:
<div class="home-platforms-instance-list-poster">
<div class="home-platforms-list-poster-face" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][loop.index]['thumb']}&width=300&height=450&fallback=poster);"></div>
</div>
% else:
<div class="home-platforms-instance-poster2">
<div class="home-platforms-list-poster-face" style="background-image: url(interfaces/default/images/poster.png);"></div>
</div>
% endif
</a>
<div class="home-platforms-instance-list-number">
<h4>${loop.index + 1}</h4>
</div>
</li>
% endif
% endfor
</div>
</div>
</ul>
% endif
</li> </li>
</div> </div>
% elif a['stat_id'] == 'top_users' and a['rows']: % elif top_stat['stat_id'] == 'top_users' and top_stat['rows']:
<div class="home-platforms-instance"> <div class="home-platforms-instance">
<li> <li>
<div class="home-platforms-instance-info"> <div class="home-platforms-instance-info">
<div class="home-platforms-instance-name"> <div class="home-platforms-instance-name">
<h4>Most Active User</h4> <h4>Most Active User</h4>
<h5> <h5>
% if a['rows'][0]['user_id']: % if top_stat['rows'][0]['user_id']:
<a href="user?user_id=${a['rows'][0]['user_id']}"> <a href="user?user_id=${top_stat['rows'][0]['user_id']}">
% else: % else:
<a href="user?user=${a['rows'][0]['user']}"> <a href="user?user=${top_stat['rows'][0]['user']}">
% endif % endif
${a['rows'][0]['friendly_name']} ${top_stat['rows'][0]['friendly_name']}
</a> </a>
</h5> </h5>
</div> </div>
<div class="user-platforms-instance-playcount"> <div class="home-platforms-instance-playcount">
% if a['stat_type'] == 'total_plays': % if top_stat['stat_type'] == 'total_plays':
<h3>${a['rows'][0]['total_plays']}</h3> <h3>${top_stat['rows'][0]['total_plays']}</h3>
<p> plays</p> <p> plays</p>
% else: % else:
${a['rows'][0]['total_duration'] | hd} ${top_stat['rows'][0]['total_duration'] | hd}
% endif % endif
</div> </div>
</div> </div>
% if a['rows'][0]['user_id']: % if top_stat['rows'][0]['user_id']:
<a href="user?user_id=${a['rows'][0]['user_id']}"> <a href="user?user_id=${top_stat['rows'][0]['user_id']}">
% else: % else:
<a href="user?user=${a['rows'][0]['user']}"> <a href="user?user=${top_stat['rows'][0]['user']}">
% endif % endif
% if a['rows'][0]['thumb'] != '': % if top_stat['rows'][0]['thumb'] != '':
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="home-platforms-instance-oval" style="background-image: url(${a['rows'][0]['thumb']});"> <div class="home-platforms-instance-oval" style="background-image: url(${top_stat['rows'][0]['thumb']});"></div>
</div> </div>
% else: % else:
<div class="home-platforms-instance-poster"> <div class="home-platforms-instance-poster">
<div class="home-platforms-instance-oval" style="background-image: url(interfaces/default/images/gravatar-default.png);"> <div class="home-platforms-instance-oval" style="background-image: url(interfaces/default/images/gravatar-default.png);"></div>
</div> </div>
% endif % endif
</a> </a>
%if len(top_stat['rows']) > 1:
<ul class="list-unstyled">
<div class="slider">
<div class="home-platforms-instance-list">
% for row in top_stat['rows']:
%if loop.index > 0:
<li>
<div class="home-platforms-instance-list-info">
<div class="home-platforms-instance-list-name">
<h5>
% if top_stat['rows'][loop.index]['user_id']:
<a href="user?user_id=${top_stat['rows'][loop.index]['user_id']}">
% else:
<a href="user?user=${top_stat['rows'][loop.index]['user']}">
% endif
${top_stat['rows'][loop.index]['friendly_name']}
</a>
</h5>
</div>
<div class="home-platforms-instance-list-playcount">
% if top_stat['stat_type'] == 'total_plays':
<h3>${top_stat['rows'][loop.index]['total_plays']}</h3>
<p> plays</p>
% else:
${top_stat['rows'][loop.index]['total_duration'] | hd}
% endif
</div>
</div>
% if top_stat['rows'][loop.index]['user_id']:
<a href="user?user_id=${top_stat['rows'][loop.index]['user_id']}">
% else:
<a href="user?user=${top_stat['rows'][loop.index]['user']}">
% endif
% if top_stat['rows'][loop.index]['thumb'] != '':
<div class="home-platforms-instance-poster">
<div class="home-platforms-instance-list-oval" style="background-image: url(${top_stat['rows'][loop.index]['thumb']});"></div>
</div>
% else:
<div class="home-platforms-instance-poster">
<div class="home-platforms-instance-list-oval" style="background-image: url(interfaces/default/images/gravatar-default.png);"></div>
</div>
% endif
</a>
<div class="home-platforms-instance-list-number">
<h4>${loop.index + 1}</h4>
</div>
</li>
% endif
% endfor
</div>
</div>
</ul>
% endif
</li> </li>
</div> </div>
% elif a['stat_id'] == 'top_platforms' and a['rows']: % elif top_stat['stat_id'] == 'top_platforms' and top_stat['rows']:
<div class="home-platforms-instance"> <div class="home-platforms-instance">
<li> <li>
<div class="home-platforms-instance-info"> <div class="home-platforms-instance-info">
<div class="home-platforms-instance-name"> <div class="home-platforms-instance-name">
<h4>Most Active Platform</h4> <h4>Most Active Platform</h4>
<h5>${a['rows'][0]['platform_type']}</h5> <h5>${top_stat['rows'][0]['platform_type']}</h5>
</div> </div>
<div class="user-platforms-instance-playcount"> <div class="home-platforms-instance-playcount">
% if a['stat_type'] == 'total_plays': % if top_stat['stat_type'] == 'total_plays':
<h3>${a['rows'][0]['total_plays']}</h3> <h3>${top_stat['rows'][0]['total_plays']}</h3>
<p> plays</p> <p> plays</p>
% else: % else:
${a['rows'][0]['total_duration'] | hd} ${top_stat['rows'][0]['total_duration'] | hd}
% endif % endif
</div> </div>
</div> </div>
<div id="platform-stat" class="home-platforms-instance-poster"> <div id="platform-stat" class="home-platforms-instance-poster">
<div class="home-platforms-instance-box" style="background-image: url(interfaces/default/images/platforms/default.png);"> <div class="home-platforms-instance-box" style="background-image: url(interfaces/default/images/platforms/default.png);"></div>
</div> </div>
%if len(top_stat['rows']) > 1:
<ul class="list-unstyled">
<div class="slider">
<div class="home-platforms-instance-list">
% for row in top_stat['rows']:
%if loop.index > 0:
<li>
<div class="home-platforms-instance-list-info">
<div class="home-platforms-instance-list-name">
<h5>
${top_stat['rows'][loop.index]['platform_type']}
</h5>
</div>
<div class="home-platforms-instance-list-playcount">
% if top_stat['stat_type'] == 'total_plays':
<h3>${top_stat['rows'][loop.index]['total_plays']}</h3>
<p> plays</p>
% else:
${top_stat['rows'][loop.index]['total_duration'] | hd}
% endif
</div>
</div>
<div class="home-platforms-instance-poster" id="home-platforms-instance-poster-${loop.index + 1}">
<script>
$("#home-platforms-instance-poster-${loop.index + 1}").html("<div class='home-platforms-instance-list-box' style='background-image: url(" + getPlatformImagePath('${top_stat['rows'][loop.index]['platform_type']}') + ");'>");
</script>
</div>
<div class="home-platforms-instance-list-number">
<h4>${loop.index + 1}</h4>
</div>
</li>
% endif
% endfor
</div>
</div>
</ul>
% endif
</li> </li>
</div> </div>
<script> <script>
$("#platform-stat").html("<div class='home-platforms-instance-box' style='background-image: url(" + getPlatformImagePath('${a['rows'][0]['platform_type']}') + ");'>"); $("#platform-stat").html("<div class='home-platforms-instance-box' style='background-image: url(" + getPlatformImagePath('${top_stat['rows'][0]['platform_type']}') + ");'>");
</script> </script>
% endif % endif
% endfor % endfor
</ul> </ul>
<script>
$('.home-platforms-instance').hover(function() {
$(this).css('z-index', 1);
$(this).find('.slider').stop().slideDown(500);
}, function() {
$(this).find('.slider').stop().slideUp(500, function() {
$(this).parents('.home-platforms-instance').css('z-index', 0);
});
});
</script>
% else: % else:
<div class="text-muted">No stats for selected period.</div><br> <div class="text-muted">No stats for selected period.</div><br>
% endif % endif

View file

@ -45,12 +45,12 @@
<script src="interfaces/default/js/moment-with-locale.js"></script> <script src="interfaces/default/js/moment-with-locale.js"></script>
<script> <script>
function getHomeStats(days, plays) { function getHomeStats(days, stat_type, stat_count) {
$.ajax({ $.ajax({
url: 'home_stats', url: 'home_stats',
cache: false, cache: false,
async: true, async: true,
data: {time_range: days, stat_type: plays}, data: {time_range: days, stat_type: stat_type, stat_count: stat_count},
complete: function(xhr, status) { complete: function(xhr, status) {
$("#home-stats").html(xhr.responseText); $("#home-stats").html(xhr.responseText);
} }
@ -110,7 +110,7 @@
}); });
}); });
getHomeStats(${config['home_stats_length']}, ${config['home_stats_type']}); getHomeStats(${config['home_stats_length']}, ${config['home_stats_type']}, ${config['home_stats_count']});
</script> </script>

View file

@ -1,4 +1,4 @@
import plexpy.logger import plexpy.logger
import itertools import itertools
import os import os
import re import re
@ -84,6 +84,7 @@ _CONFIG_DEFINITIONS = {
'GROWL_ON_WATCHED': (int, 'Growl', 0), 'GROWL_ON_WATCHED': (int, 'Growl', 0),
'HOME_STATS_LENGTH': (int, 'General', 30), 'HOME_STATS_LENGTH': (int, 'General', 30),
'HOME_STATS_TYPE': (int, 'General', 0), 'HOME_STATS_TYPE': (int, 'General', 0),
'HOME_STATS_COUNT': (int, 'General', 5),
'HTTPS_CERT': (str, 'General', ''), 'HTTPS_CERT': (str, 'General', ''),
'HTTPS_KEY': (str, 'General', ''), 'HTTPS_KEY': (str, 'General', ''),
'HTTP_HOST': (str, 'General', '0.0.0.0'), 'HTTP_HOST': (str, 'General', '0.0.0.0'),

View file

@ -129,7 +129,7 @@ class DataFactory(object):
return dict return dict
def get_home_stats(self, time_range='30', stat_type='0'): def get_home_stats(self, time_range='30', stat_type='0', stat_count='5'):
monitor_db = database.MonitorDatabase() monitor_db = database.MonitorDatabase()
if not time_range.isdigit(): if not time_range.isdigit():
@ -137,6 +137,9 @@ class DataFactory(object):
sort_type = 'total_plays' if stat_type == '0' else 'total_duration' sort_type = 'total_plays' if stat_type == '0' else 'total_duration'
if not time_range.isdigit():
stat_count = '5'
# This actually determines the output order in the home page # This actually determines the output order in the home page
stats_queries = ["top_tv", "popular_tv", "top_movies", "popular_movies", "top_users", "top_platforms"] stats_queries = ["top_tv", "popular_tv", "top_movies", "popular_movies", "top_users", "top_platforms"]
home_stats = [] home_stats = []
@ -161,7 +164,7 @@ class DataFactory(object):
'>= datetime("now", "-%s days", "localtime") ' \ '>= datetime("now", "-%s days", "localtime") ' \
'AND session_history_metadata.media_type = "episode" ' \ 'AND session_history_metadata.media_type = "episode" ' \
'GROUP BY session_history_metadata.grandparent_title ' \ 'GROUP BY session_history_metadata.grandparent_title ' \
'ORDER BY %s DESC LIMIT 10' % (time_range, sort_type) 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stat_count)
result = monitor_db.select(query) result = monitor_db.select(query)
except: except:
logger.warn("Unable to execute database query.") logger.warn("Unable to execute database query.")
@ -207,7 +210,7 @@ class DataFactory(object):
'>= datetime("now", "-%s days", "localtime") ' \ '>= datetime("now", "-%s days", "localtime") ' \
'AND session_history_metadata.media_type = "movie" ' \ 'AND session_history_metadata.media_type = "movie" ' \
'GROUP BY session_history_metadata.full_title ' \ 'GROUP BY session_history_metadata.full_title ' \
'ORDER BY %s DESC LIMIT 10' % (time_range, sort_type) 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stat_count)
result = monitor_db.select(query) result = monitor_db.select(query)
except: except:
logger.warn("Unable to execute database query.") logger.warn("Unable to execute database query.")
@ -251,7 +254,7 @@ class DataFactory(object):
'AND session_history_metadata.media_type = "episode" ' \ 'AND session_history_metadata.media_type = "episode" ' \
'GROUP BY session_history_metadata.grandparent_title ' \ 'GROUP BY session_history_metadata.grandparent_title ' \
'ORDER BY users_watched DESC, total_plays DESC ' \ 'ORDER BY users_watched DESC, total_plays DESC ' \
'LIMIT 10' % time_range 'LIMIT %s' % (time_range, stat_count)
result = monitor_db.select(query) result = monitor_db.select(query)
except: except:
logger.warn("Unable to execute database query.") logger.warn("Unable to execute database query.")
@ -293,7 +296,7 @@ class DataFactory(object):
'AND session_history_metadata.media_type = "movie" ' \ 'AND session_history_metadata.media_type = "movie" ' \
'GROUP BY session_history_metadata.full_title ' \ 'GROUP BY session_history_metadata.full_title ' \
'ORDER BY users_watched DESC, total_plays DESC ' \ 'ORDER BY users_watched DESC, total_plays DESC ' \
'LIMIT 10' % time_range 'LIMIT %s' % (time_range, stat_count)
result = monitor_db.select(query) result = monitor_db.select(query)
except: except:
logger.warn("Unable to execute database query.") logger.warn("Unable to execute database query.")
@ -338,7 +341,7 @@ class DataFactory(object):
'WHERE datetime(session_history.stopped, "unixepoch", "localtime") >= ' \ 'WHERE datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
'datetime("now", "-%s days", "localtime") '\ 'datetime("now", "-%s days", "localtime") '\
'GROUP BY session_history.user_id ' \ 'GROUP BY session_history.user_id ' \
'ORDER BY %s DESC LIMIT 10' % (time_range, sort_type) 'ORDER BY %s DESC LIMIT %s' % (time_range, sort_type, stat_count)
result = monitor_db.select(query) result = monitor_db.select(query)
except: except:
logger.warn("Unable to execute database query.") logger.warn("Unable to execute database query.")
@ -386,7 +389,7 @@ class DataFactory(object):
'WHERE datetime(session_history.stopped, "unixepoch", "localtime") ' \ 'WHERE datetime(session_history.stopped, "unixepoch", "localtime") ' \
'>= datetime("now", "-%s days", "localtime") ' \ '>= datetime("now", "-%s days", "localtime") ' \
'GROUP BY session_history.platform ' \ 'GROUP BY session_history.platform ' \
'ORDER BY total_plays DESC' % time_range 'ORDER BY total_plays DESC LIMIT %s' % (time_range, stat_count)
result = monitor_db.select(query) result = monitor_db.select(query)
except: except:
logger.warn("Unable to execute database query.") logger.warn("Unable to execute database query.")

View file

@ -1,4 +1,4 @@
# This file is part of PlexPy. # This file is part of PlexPy.
# #
# PlexPy is free software: you can redistribute it and/or modify # PlexPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -66,7 +66,8 @@ class WebInterface(object):
def home(self): def home(self):
config = { config = {
"home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH, "home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH,
"home_stats_type": plexpy.CONFIG.HOME_STATS_TYPE "home_stats_type": plexpy.CONFIG.HOME_STATS_TYPE,
"home_stats_count": plexpy.CONFIG.HOME_STATS_COUNT
} }
return serve_template(templatename="index.html", title="Home", config=config) return serve_template(templatename="index.html", title="Home", config=config)
@ -119,9 +120,9 @@ class WebInterface(object):
return json.dumps(formats) return json.dumps(formats)
@cherrypy.expose @cherrypy.expose
def home_stats(self, time_range='30', stat_type='0', **kwargs): def home_stats(self, time_range='30', stat_type='0', stat_count='5', **kwargs):
data_factory = datafactory.DataFactory() data_factory = datafactory.DataFactory()
stats_data = data_factory.get_home_stats(time_range=time_range, stat_type=stat_type) stats_data = data_factory.get_home_stats(time_range=time_range, stat_type=stat_type, stat_count=stat_count)
return serve_template(templatename="home_stats.html", title="Stats", data=stats_data) return serve_template(templatename="home_stats.html", title="Stats", data=stats_data)
@ -453,6 +454,7 @@ class WebInterface(object):
"notify_on_watched_body_text": plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT, "notify_on_watched_body_text": plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT,
"home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH, "home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH,
"home_stats_type": checked(plexpy.CONFIG.HOME_STATS_TYPE), "home_stats_type": checked(plexpy.CONFIG.HOME_STATS_TYPE),
"home_stats_count": checked(plexpy.CONFIG.HOME_STATS_COUNT),
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD, "buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
"buffer_wait": plexpy.CONFIG.BUFFER_WAIT "buffer_wait": plexpy.CONFIG.BUFFER_WAIT
} }