From 04b290173cc6ae0b7317bc9d3ddc14e2a6a6cb8a Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 16 Jun 2015 17:35:52 +0200 Subject: [PATCH] Added restart and shutdown links in settings. No longer exposing passwords in html forms. Removed some old headphones js. Minor styling adjustments. Current activity on home screen now works. Some history table fixes and additions. Info screen for video items now works. --- data/interfaces/default/config.html | 20 +- data/interfaces/default/css/plexwatch.css | 4 +- data/interfaces/default/current_activity.html | 99 ++++ .../default/current_activity_header.html | 9 + data/interfaces/default/history.html | 20 +- data/interfaces/default/index.html | 57 ++- data/interfaces/default/info.html | 162 ++++++ .../default/js/jquery.rateit.min.js | 2 + data/interfaces/default/js/script.js | 275 ++--------- data/interfaces/default/logs.html | 1 - data/interfaces/default/shutdown.html | 17 +- plexpy/config.py | 1 + plexpy/helpers.py | 21 +- plexpy/plextv.py | 112 +++++ plexpy/pmsconnect.py | 466 ++++++++++++++++++ plexpy/webserve.py | 154 +++++- 16 files changed, 1163 insertions(+), 257 deletions(-) create mode 100644 data/interfaces/default/current_activity.html create mode 100644 data/interfaces/default/current_activity_header.html create mode 100644 data/interfaces/default/info.html create mode 100644 data/interfaces/default/js/jquery.rateit.min.js create mode 100644 plexpy/plextv.py create mode 100644 plexpy/pmsconnect.py diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 5d18a549..92a92e14 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -5,14 +5,7 @@ %> <%def name="headerIncludes()"> - + <%def name="body()"> @@ -22,7 +15,15 @@
-

Settings

+
+

Settings

+
+ +
+
@@ -898,7 +899,6 @@ } }); - initActions(); initConfigCheckbox("#api_enabled"); initConfigCheckbox("#enable_https"); diff --git a/data/interfaces/default/css/plexwatch.css b/data/interfaces/default/css/plexwatch.css index 661fbae1..6a676997 100644 --- a/data/interfaces/default/css/plexwatch.css +++ b/data/interfaces/default/css/plexwatch.css @@ -6650,7 +6650,7 @@ button.close { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; - width: 82%; + width: 80%; margin-right: 5px; float: left; } @@ -6665,7 +6665,7 @@ button.close { overflow: hidden; white-space: nowrap; font-size: 14px; - width: 82%; + width: 80%; margin-right: 5px; color: #fff; float: left; diff --git a/data/interfaces/default/current_activity.html b/data/interfaces/default/current_activity.html new file mode 100644 index 00000000..7890c3e7 --- /dev/null +++ b/data/interfaces/default/current_activity.html @@ -0,0 +1,99 @@ +% if activity is not None: + % if activity['stream_count'] != '0': + % for a in activity['sessions']: +
+
+ % if a['type'] == 'track-to-do': +
+ % elif a['type'] == 'movie': +
+ +
+ % else: +
+ +
+ % endif + +
+
+ +
+
+ + % endfor + % else: +
Nothing is currently being watched.

+ % endif +% else: +
There was an error communicating with your Plex Server. Please check your settings.

+% endif \ No newline at end of file diff --git a/data/interfaces/default/current_activity_header.html b/data/interfaces/default/current_activity_header.html new file mode 100644 index 00000000..72ae4050 --- /dev/null +++ b/data/interfaces/default/current_activity_header.html @@ -0,0 +1,9 @@ +% if activity != None: + % if activity == '0': +

Activity

+ % else: +

Activity ${activity} stream(s)

+ % endif +% else: +

Activity

+% endif \ No newline at end of file diff --git a/data/interfaces/default/history.html b/data/interfaces/default/history.html index fe9bf072..0117a62d 100644 --- a/data/interfaces/default/history.html +++ b/data/interfaces/default/history.html @@ -38,6 +38,7 @@ Stopped Duration Completed + RatingKey @@ -158,11 +159,21 @@ }, { "targets": [4], - "data":"ip_address" + "data":"ip_address", + "createdCell": function (td, cellData, rowData, row, col) { + if ((cellData == '') || (cellData == '0')) { + $(td).html('n/a'); + } + } }, { "targets": [5], - "data":"title" + "data":"title", + "createdCell": function (td, cellData, rowData, row, col) { + if (cellData !== '') { + $(td).html('' + cellData + ''); + } + } }, { "targets": [6], @@ -203,6 +214,11 @@ return '100%'; } } + }, + { + "targets": [11], + "data":"rating_key", + "visible": false } ], "drawCallback": function (settings) { diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index ec931905..61715071 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -3,16 +3,61 @@ from plexpy import helpers %> -<%def name="body()"> -
- -
- - <%def name="headIncludes()"> +<%def name="body()"> +
+ +
+
+
+
+
+
+

Activity

+
+
+
+
+
Checking for activity...

+
+
+
+
+ +
+ + <%def name="javascriptIncludes()"> + diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html new file mode 100644 index 00000000..eefb9e76 --- /dev/null +++ b/data/interfaces/default/info.html @@ -0,0 +1,162 @@ +<%inherit file="base.html"/> +<%! + from plexpy import helpers +%> + +<%def name="headIncludes()"> + + + +<%def name="body()"> + % if metadata: +
+
+ +
+
+ + +
+ +
+
+
+ +
+ +
+ % if metadata['type'] == 'episode': + + % else: + + % endif +
+
+
+ % if metadata['type'] == 'movie': +

${metadata['title']} (${metadata['year']})

+ % elif metadata['type'] == 'season': +

${metadata['parentTitle']} (${metadata['title']})

+ % elif metadata['type'] == 'episode': +

${metadata['grandparentTitle']} (Season ${metadata['parentIndex']}, Episode ${metadata['index']}) "${metadata['title']}"

+ % else: +

${metadata['title']}

+ % endif +
+ % if metadata['type'] == 'movie': +
+ % endif +
+
+ % if metadata['type'] == 'episode' or metadata['type'] == 'movie': + % if metadata['directors']: + Directed by ${metadata['directors'][0]} + % else: + Directed by unknown + % endif + % elif metadata['type'] == 'show': + Studio ${metadata['studio']} + % endif +
+
+ % if metadata['type'] == 'episode' or metadata['type'] == 'movie' or metadata['type'] == 'show': + Runtime ${metadata['duration']} mins + % endif +
+
+ % if metadata['type'] == 'episode' or metadata['type'] == 'movie' or metadata['type'] == 'show': + Rated ${metadata['contentRating']} + % endif +
+
+
+ % if metadata['type'] == 'episode' or metadata['type'] == 'movie' or metadata['type'] == 'show': +

${metadata['summary']}

+ % endif +
+
+
+ % if metadata['type'] == 'episode': +
+
+
+
Written by
+
    + % for writer in metadata['writers']: + % if loop.index < 5: +
  • + ${writer} +
  • + % endif + % endfor +
+
+
+
+ % elif metadata['type'] == 'movie' or metadata['type'] == 'show': +
+
+
+
Genres
+
    + % for genre in metadata['genres']: + % if loop.index < 5: +
  • + ${genre} +
  • + % endif + % endfor +
+
+
+
+
Starring
+
    + % for actor in metadata['actors']: + % if loop.index < 5: +
  • + ${actor} +
  • + % endif + % endfor +
+
+
+
+
+ % elif metadata['type'] == 'season': +
+ % endif +
+
+
+
+ +
+
+ +
+ % else: +
+
+
+
+

Error retrieving item metadata. This media may not be available in the Plex Media Server database anymore.

+
+
+
+ % endif + + +<%def name="javascriptIncludes()"> + + % if metadata['type'] == 'movie': + + % endif + diff --git a/data/interfaces/default/js/jquery.rateit.min.js b/data/interfaces/default/js/jquery.rateit.min.js new file mode 100644 index 00000000..16296e44 --- /dev/null +++ b/data/interfaces/default/js/jquery.rateit.min.js @@ -0,0 +1,2 @@ +(function(n){function t(n){var u=n.originalEvent.changedTouches,t=u[0],i="",r;switch(n.type){case"touchmove":i="mousemove";break;case"touchend":i="mouseup";break;default:return}r=document.createEvent("MouseEvent"),r.initMouseEvent(i,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,!1,!1,!1,!1,0,null),t.target.dispatchEvent(r),n.preventDefault()}n.rateit={aria:{resetLabel:"reset rating",ratingLabel:"rating"}},n.fn.rateit=function(i,r){var e=1,u={},o="init",s=function(n){return n.charAt(0).toUpperCase()+n.substr(1)},f;if(this.length==0)return this;if(f=n.type(i),f=="object"||i===undefined||i==null)u=n.extend({},n.fn.rateit.defaults,i);else{if(f=="string"&&r===undefined)return this.data("rateit"+s(i));f=="string"&&(o="setvalue")}return this.each(function(){var c=n(this),f=function(n,t){if(t!=null){var i="aria-value"+(n=="value"?"now":n),r=c.find(".rateit-range");r.attr(i)!=undefined&&r.attr(i,t)}return arguments[0]="rateit"+s(n),c.data.apply(c,arguments)},v,h,b,k,l,y,p,a;if(c.hasClass("rateit")||c.addClass("rateit"),v=c.css("direction")!="rtl",o=="setvalue"){if(!f("init"))throw"Can't set value before init";i!="readonly"||r!=!0||f("readonly")||(c.find(".rateit-range").unbind(),f("wired",!1)),i=="value"&&(r=r==null?f("min"):Math.max(f("min"),Math.min(f("max"),r))),f("backingfld")&&(h=n(f("backingfld")),i=="value"&&h.val(r),i=="min"&&h[0].min&&(h[0].min=r),i=="max"&&h[0].max&&(h[0].max=r),i=="step"&&h[0].step&&(h[0].step=r)),f(i,r)}f("init")||(f("min",f("min")||u.min),f("max",f("max")||u.max),f("step",f("step")||u.step),f("readonly",f("readonly")!==undefined?f("readonly"):u.readonly),f("resetable",f("resetable")!==undefined?f("resetable"):u.resetable),f("backingfld",f("backingfld")||u.backingfld),f("starwidth",f("starwidth")||u.starwidth),f("starheight",f("starheight")||u.starheight),f("value",Math.max(f("min"),Math.min(f("max"),f("value")||u.value||u.min))),f("ispreset",f("ispreset")!==undefined?f("ispreset"):u.ispreset),f("backingfld")&&(h=n(f("backingfld")),f("value",h.hide().val()),(h.attr("disabled")||h.attr("readonly"))&&f("readonly",!0),h[0].nodeName=="INPUT"&&(h[0].type=="range"||h[0].type=="text")&&(f("min",parseInt(h.attr("min"))||f("min")),f("max",parseInt(h.attr("max"))||f("max")),f("step",parseInt(h.attr("step"))||f("step"))),h[0].nodeName=="SELECT"&&h[0].options.length>1&&(f("min",Number(h[0].options[0].value)),f("max",Number(h[0].options[h[0].length-1].value)),f("step",Number(h[0].options[1].value)-Number(h[0].options[0].value)))),b=c[0].nodeName=="DIV"?"div":"span",e++,k='