Compare commits

...

47 Commits

Author SHA1 Message Date
JonnyWong16
a8a676b794 v2.1.18 2018-07-27 13:53:45 -07:00
JonnyWong16
2f40850100 Fix search bar width (Fixes Tautulli/Tautulli-Issues#104) 2018-07-26 17:25:31 -07:00
JonnyWong16
f16560cb40 Fix activity progress bar showing incorrect 100% 2018-07-25 18:48:33 -07:00
JonnyWong16
ab92e48d2e Fix auto resizing textareas scrolling to the top on focus 2018-07-25 18:39:40 -07:00
JonnyWong16
ce2982d948 Skip formatting bad parameters in notification text 2018-07-25 16:23:01 -07:00
JonnyWong16
89d1a5782a v2.1.17-beta 2018-07-22 17:45:02 -07:00
JonnyWong16
97cf2ebe19 Make monitor websocket ping/pong an advanced config option 2018-07-22 17:39:21 -07:00
JonnyWong16
4ef36a464a Set datatables save state duration to indefinitely 2018-07-22 17:35:10 -07:00
JonnyWong16
54ec9ad7da Remove unused libs 2018-07-22 13:54:07 -07:00
JonnyWong16
bfdfdaaad1 Image alt text to Tautulli 2018-07-17 09:44:00 -07:00
JonnyWong16
5bd51b2a17 Don't join empty paths 2018-07-16 09:36:13 -07:00
JonnyWong16
35778cfe72 Use os.pathsep for PYTHONPATH 2018-07-16 09:02:17 -07:00
JonnyWong16
f81649c4d3 Update nullrefer to HTTPS 2018-07-10 15:46:01 -07:00
JonnyWong16
59162713e7 Fix ajax loader message refresh icon spacing 2018-07-10 08:51:55 -07:00
JonnyWong16
188b728dd0 Fix save settings loader 2018-07-10 08:50:56 -07:00
JonnyWong16
3446f5543d Check local server directly 2018-07-10 08:12:12 -07:00
JonnyWong16
ab5384cfdf Discover localhost server 2018-07-09 19:31:11 -07:00
JonnyWong16
e567134ee1 Use default selected stream for media info in notifications 2018-07-06 19:41:03 -07:00
JonnyWong16
98b5cb67ca v2.1.16-beta 2018-07-06 19:06:02 -07:00
JonnyWong16
26db7f1984 Update API docs with rating_image and audience_rating_image 2018-07-06 19:04:06 -07:00
JonnyWong16
e1afbd4eff Remove white text on accordion hover 2018-07-06 18:52:19 -07:00
JonnyWong16
f6090bcdf0 Fix accordion icon colours 2018-07-06 18:44:20 -07:00
JonnyWong16
0950ff7ecf Fix incorrect stream_duration parameter for playback start notifications 2018-07-06 18:43:57 -07:00
JonnyWong16
e766cb6093 Add critic_rating to notification parameters 2018-07-06 18:34:50 -07:00
JonnyWong16
8982ae83ac Percent helper round before trunc 2018-07-06 18:15:18 -07:00
JonnyWong16
2b395a7ad9 Fix API get_logs (Fixes Tautulli/Tautulli-Issues#100) 2018-07-05 18:50:04 -07:00
JonnyWong16
a9b5c91f84 Fix OAuth popup loader 2018-07-05 18:23:10 -07:00
JonnyWong16
c0b960bccf Refactor Plex OAuth code 2018-07-05 09:06:03 -07:00
JonnyWong16
8514cf1975 Reset pong count 2018-07-04 12:25:32 -07:00
JonnyWong16
c5e37badd8 Fix infinite websocket connection loop 2018-07-03 20:06:37 -07:00
JonnyWong16
c0f1079b4e Remove connection attempts from inital websocket connection 2018-07-03 19:58:58 -07:00
JonnyWong16
1da4b8ecb4 Add ping/pong to websocket 2018-07-03 18:10:52 -07:00
JonnyWong16
c2ba2b4e98 Add popup OAuth window to wizard and settings 2018-07-03 09:49:11 -07:00
JonnyWong16
d9ea781462 Center Discord chat popout window 2018-07-03 09:46:37 -07:00
JonnyWong16
5ee5ca7dbf Popup window for Plex OAuth 2018-07-03 09:46:12 -07:00
JonnyWong16
176392d837 Fix typo in newlsetter with single reminaing season 2018-07-02 16:16:05 -07:00
JonnyWong16
b65e6a39a0 Accordion for login methods on login page 2018-07-02 15:56:24 -07:00
JonnyWong16
5c7a3a12e9 Add OAuth to token refresh in settings 2018-07-02 12:28:34 -07:00
JonnyWong16
e7072edbd1 Add OAuth to setup wizard 2018-07-02 12:04:12 -07:00
JonnyWong16
2711597ffb Pass OAuth client headers to server 2018-07-02 11:20:25 -07:00
JonnyWong16
24458bd23c Log login method 2018-07-02 09:55:41 -07:00
JonnyWong16
3fd0708d21 Use client headers for OAuth 2018-07-02 09:55:28 -07:00
JonnyWong16
434cb89ba8 Correct client ID 2018-07-02 09:00:25 -07:00
JonnyWong16
745d398527 Improve Plex OAuth 2018-07-02 08:51:51 -07:00
JonnyWong16
16bfcade8c Log failed OAuth attempts 2018-07-02 00:45:47 -07:00
JonnyWong16
f69f5a79d9 Merge branch 'beta' into nightly 2018-07-01 23:40:03 -07:00
JonnyWong16
3bd1b03faf Add Plex OAuth to login page 2018-07-01 22:55:13 -07:00
47 changed files with 1017 additions and 3453 deletions

4
API.md
View File

@@ -373,6 +373,7 @@ Returns:
"art": "/library/metadata/1219/art/1503306930", "art": "/library/metadata/1219/art/1503306930",
"aspect_ratio": "1.78", "aspect_ratio": "1.78",
"audience_rating": "", "audience_rating": "",
"audience_rating_image": "rottentomatoes://image.rating.upright",
"audio_bitrate": "384", "audio_bitrate": "384",
"audio_bitrate_mode": "", "audio_bitrate_mode": "",
"audio_channel_layout": "5.1(side)", "audio_channel_layout": "5.1(side)",
@@ -449,6 +450,7 @@ Returns:
"progress_percent": "0", "progress_percent": "0",
"quality_profile": "Original", "quality_profile": "Original",
"rating": "7.8", "rating": "7.8",
"rating_image": "rottentomatoes://image.rating.ripe",
"rating_key": "153037", "rating_key": "153037",
"relay": 0, "relay": 0,
"section_id": "2", "section_id": "2",
@@ -1084,6 +1086,7 @@ Returns:
"added_at": "1461572396", "added_at": "1461572396",
"art": "/library/metadata/1219/art/1462175063", "art": "/library/metadata/1219/art/1462175063",
"audience_rating": "8", "audience_rating": "8",
"audience_rating_image": "rottentomatoes://image.rating.upright",
"banner": "/library/metadata/1219/banner/1462175063", "banner": "/library/metadata/1219/banner/1462175063",
"collections": [], "collections": [],
"content_rating": "TV-MA", "content_rating": "TV-MA",
@@ -1181,6 +1184,7 @@ Returns:
"parent_thumb": "/library/metadata/153036/thumb/1462175062", "parent_thumb": "/library/metadata/153036/thumb/1462175062",
"parent_title": "", "parent_title": "",
"rating": "7.8", "rating": "7.8",
"rating_image": "rottentomatoes://image.rating.ripe",
"rating_key": "153037", "rating_key": "153037",
"section_id": "2", "section_id": "2",
"sort_title": "Game of Thrones", "sort_title": "Game of Thrones",

View File

@@ -1,5 +1,42 @@
# Changelog # Changelog
## v2.1.18 (2018-07-27)
* Monitoring:
* Fix: Progress bar on activity cards showing incorrect 100% when starting a stream.
* Notifications:
* Fix: Notification text boxes scrolling to top when inputting text.
* Change: Skip formatting invalid notification parameters instead of returning default text.
* UI:
* Fix: Padding around search bar causing the navigation bar to break on smaller screens.
## v2.1.17-beta (2018-07-22)
* Notifications:
* Change: Use default selected stream for media info in notifications.
* UI:
* New: Automatically discover localhost Plex servers in server selection dropdown.
* Change: Save Datatables state indefinitely.
## v2.1.16-beta (2018-07-06)
* Monitoring:
* Fix: Plex server not detected as down during sudden network loss.
* Notifications:
* Fix: Incorrect rounding of percentages in some cases.
* Fix: Incorrect stream duration value for playback start notifications.
* New: Added critic rating parameter for Rotten Tomatoes ratings.
* Newsletters:
* Fix: Typo in "seasons" when there is only one additional season.
* UI:
* New: Added ability to use Plex OAuth to login to Tautulli.
* API:
* Fix: Unicode characters causing get_logs command to return bad data.
* New: Added rating_image and audience_rating_image to get_activity and get_metadata commands.
## v2.1.15-beta (2018-07-01) ## v2.1.15-beta (2018-07-01)
* Monitoring: * Monitoring:

View File

@@ -75,7 +75,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="home" title="Tautulli"> <a class="navbar-brand" href="home" title="Tautulli">
<img src="${http_root}images/logo-tautulli-45.png" height="45" alt="PlexPy"> <img src="${http_root}images/logo-tautulli-45.png" height="45" alt="Tautulli">
</a> </a>
</div> </div>
<div class="collapse navbar-collapse navbar-right" id="navbar-collapse-1"> <div class="collapse navbar-collapse navbar-right" id="navbar-collapse-1">
@@ -291,6 +291,7 @@ ${next.modalIncludes()}
<script src="${http_root}js/bootstrap.min.js"></script> <script src="${http_root}js/bootstrap.min.js"></script>
<script src="${http_root}js/bootstrap-hover-dropdown.min.js"></script> <script src="${http_root}js/bootstrap-hover-dropdown.min.js"></script>
<script src="${http_root}js/pnotify.custom.min.js"></script> <script src="${http_root}js/pnotify.custom.min.js"></script>
<script src="${http_root}js/platform.min.js"></script>
<script src="${http_root}js/script.js${cache_param}"></script> <script src="${http_root}js/script.js${cache_param}"></script>
<script src="${http_root}js/jquery.qrcode.min.js"></script> <script src="${http_root}js/jquery.qrcode.min.js"></script>
<script src="${http_root}js/jquery.tripleclick.min.js"></script> <script src="${http_root}js/jquery.tripleclick.min.js"></script>

View File

@@ -22,11 +22,11 @@ DOCUMENTATION :: END
% if plexpy.CURRENT_VERSION: % if plexpy.CURRENT_VERSION:
<tr> <tr>
<td>Git Branch:</td> <td>Git Branch:</td>
<td><a class="no-highlight" href="${anon_url('https://github.com/%s/%s/tree/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CONFIG.GIT_BRANCH))}">${plexpy.CONFIG.GIT_BRANCH}</a></td> <td><a class="no-highlight" href="${anon_url('https://github.com/%s/%s/tree/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CONFIG.GIT_BRANCH))}" target="_blank">${plexpy.CONFIG.GIT_BRANCH}</a></td>
</tr> </tr>
<tr> <tr>
<td>Git Commit Hash:</td> <td>Git Commit Hash:</td>
<td><a class="no-highlight" href="${anon_url('https://github.com/%s/%s/commit/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CURRENT_VERSION))}">${plexpy.CURRENT_VERSION}</a></td> <td><a class="no-highlight" href="${anon_url('https://github.com/%s/%s/commit/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CURRENT_VERSION))}" target="_blank">${plexpy.CURRENT_VERSION}</a></td>
</tr> </tr>
% endif % endif
<tr> <tr>

View File

@@ -101,6 +101,9 @@ select.form-control {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.wizard-input-section p.welcome-message {
margin: 20px 0;
}
.wizard-input-section .selectize-control.form-control.selectize-pms-ip .selectize-input > div { .wizard-input-section .selectize-control.form-control.selectize-pms-ip .selectize-input > div {
max-width: 360px; max-width: 360px;
overflow: hidden; overflow: hidden;
@@ -2970,10 +2973,13 @@ a .home-platforms-list-cover-face:hover
-o-transition: all 0.3s ease; -o-transition: all 0.3s ease;
transition: all 0.3s ease; transition: all 0.3s ease;
} }
.accordion li .link:hover { .accordion li .link:hover,
color: #fff; .accordion li .link:hover i.fa {
background: #2f2f2f; background: #2f2f2f;
} }
.accordion li .link i.fa {
color: #999;
}
.accordion li .link span.toggle-right { .accordion li .link span.toggle-right {
float: right; float: right;
padding-left: 10px; padding-left: 10px;
@@ -2987,7 +2993,8 @@ a .home-platforms-list-cover-face:hover
-o-transition: all 0.3s ease; -o-transition: all 0.3s ease;
transition: all 0.3s ease; transition: all 0.3s ease;
} }
.accordion li.open .link { .accordion li.open .link,
.accordion li.open .link i.fa {
color: #f9be03; color: #f9be03;
} }
.accordion li.open .fa-chevron-down { .accordion li.open .fa-chevron-down {
@@ -3281,7 +3288,7 @@ pre::-webkit-scrollbar-thumb {
} }
} }
#search_form { #search_form {
width: 300px; width: 270px;
padding: 8px 15px; padding: 8px 15px;
} }
#search_form span.input-textbox { #search_form span.input-textbox {
@@ -3470,6 +3477,9 @@ a.no-highlight:hover {
max-width: 1170px; max-width: 1170px;
} }
} }
.login-body-container {
margin: 50px 0;
}
.login-container { .login-container {
margin-right: auto; margin-right: auto;
margin-left: auto; margin-left: auto;
@@ -3483,6 +3493,11 @@ a.no-highlight:hover {
margin: 0 auto 50px auto; margin: 0 auto 50px auto;
text-align: center; text-align: center;
} }
.login-container .login-method-header {
text-align: center;
font-weight: 600;
text-transform: uppercase;
}
.login-container .form-group { .login-container .form-group {
margin-bottom: 20px; margin-bottom: 20px;
} }
@@ -3503,8 +3518,9 @@ a.no-highlight:hover {
text-shadow: 0 -1px 1px rgba(0,0,0,.4),0 0 15px rgba(0,0,0,.2); text-shadow: 0 -1px 1px rgba(0,0,0,.4),0 0 15px rgba(0,0,0,.2);
} }
.login-container .remember-group { .login-container .remember-group {
float: left;
color: #999; color: #999;
display: inline-block;
margin-top: 7.5px;
} }
.login-container .remember-group .control-label { .login-container .remember-group .control-label {
display: inline; display: inline;
@@ -3512,6 +3528,33 @@ a.no-highlight:hover {
font-weight: 400; font-weight: 400;
cursor: pointer; cursor: pointer;
} }
.login-divider {
text-align: center;
border-bottom: 1px solid #555;
line-height: 0.1em;
margin: 50px auto;
max-width: 400px;
text-transform: uppercase;
}
.login-divider span {
background: #1f1f1f;
padding: 0 15px;
color: #999;
}
.login-button-plex {
text-align: center;
}
.login-button-plex .remember-group {
margin-top: 20px;
}
.login-button-plex button#sign-in-plex {
float: none;
}
.login-alert {
text-align: center;
padding: 8px;
display: none;
}
#admin-login-modal .form-group label { #admin-login-modal .form-group label {
font-weight: 400; font-weight: 400;
color: #999; color: #999;

View File

@@ -617,7 +617,8 @@
if ($(this).data('state') === 'playing' && $(this).data('view_offset') >= 0) { if ($(this).data('state') === 'playing' && $(this).data('view_offset') >= 0) {
var view_offset = parseInt($(this).data('view_offset')); var view_offset = parseInt($(this).data('view_offset'));
var stream_duration = parseInt($(this).data('stream_duration')); var stream_duration = parseInt($(this).data('stream_duration'));
var progress_percent = Math.min(Math.floor(view_offset / stream_duration * 100) || 100, 100); var progress_percent = Math.floor(view_offset / stream_duration * 100);
progress_percent = (progress_percent >= 0) ? Math.min(progress_percent, 100) : 100;
$(this).width(progress_percent - 3 + '%').html(progress_percent + '%') $(this).width(progress_percent - 3 + '%').html(progress_percent + '%')
.attr('data-original-title', 'Stream Progress ' + progress_percent + '%') .attr('data-original-title', 'Stream Progress ' + progress_percent + '%')
.data('view_offset', Math.min(view_offset + 1000, stream_duration)); .data('view_offset', Math.min(view_offset + 1000, stream_duration));

File diff suppressed because one or more lines are too long

View File

@@ -37,7 +37,7 @@ function showMsg(msg, loader, timeout, ms, error) {
} }
var message = $("<div class='msg'>" + msg + "</div>"); var message = $("<div class='msg'>" + msg + "</div>");
if (loader) { if (loader) {
message = $("<div class='msg'><i class='fa fa-refresh fa-spin'></i> " + msg + "</div>"); message = $("<div class='msg'><i class='fa fa-refresh fa-spin'></i>&nbsp; " + msg + "</div>");
feedback.css("padding", "14px 10px"); feedback.css("padding", "14px 10px");
} }
if (error) { if (error) {
@@ -73,9 +73,9 @@ function confirmAjaxCall(url, msg, data, loader_msg, callback) {
var result = $.parseJSON(xhr.responseText); var result = $.parseJSON(xhr.responseText);
var msg = result.message; var msg = result.message;
if (result.result == 'success') { if (result.result == 'success') {
showMsg('<i class="fa fa-check"></i> ' + msg, false, true, 5000); showMsg('<i class="fa fa-check"></i>&nbsp; ' + msg, false, true, 5000);
} else { } else {
showMsg('<i class="fa fa-times"></i> ' + msg, false, true, 5000, true); showMsg('<i class="fa fa-times"></i>&nbsp; ' + msg, false, true, 5000, true);
} }
if (typeof callback === "function") { if (typeof callback === "function") {
callback(result); callback(result);
@@ -103,7 +103,7 @@ function doAjaxCall(url, elem, reload, form, showMsg, callback) {
dataString = $(formID).serialize(); dataString = $(formID).serialize();
} }
// Loader Image // Loader Image
var loader = $("<i class='fa fa-refresh fa-spin ajaxLoader-" + url +"></i>"); var loader = $("<div class='msg ajaxLoader-" + url +"'><i class='fa fa-refresh fa-spin'></i>&nbsp; Saving...</div>");
// Data Success Message // Data Success Message
var dataSucces = $(elem).data('success'); var dataSucces = $(elem).data('success');
if (typeof dataSucces === "undefined") { if (typeof dataSucces === "undefined") {
@@ -117,8 +117,8 @@ function doAjaxCall(url, elem, reload, form, showMsg, callback) {
dataError = "There was an error"; dataError = "There was an error";
} }
// Get Success & Error message from inline data, else use standard message // Get Success & Error message from inline data, else use standard message
var succesMsg = $("<div class='msg'><i class='fa fa-check'></i> " + dataSucces + "</div>"); var succesMsg = $("<div class='msg'><i class='fa fa-check'></i>&nbsp; " + dataSucces + "</div>");
var errorMsg = $("<div class='msg'><i class='fa fa-exclamation-triangle'></i> " + dataError + "</div>"); var errorMsg = $("<div class='msg'><i class='fa fa-exclamation-triangle'></i>&nbsp; " + dataError + "</div>");
// Check if checkbox is selected // Check if checkbox is selected
if (form) { if (form) {
if ($('td#select input[type=checkbox]').length > 0 && !$('td#select input[type=checkbox]').is(':checked') || if ($('td#select input[type=checkbox]').length > 0 && !$('td#select input[type=checkbox]').is(':checked') ||
@@ -187,7 +187,7 @@ function doAjaxCall(url, elem, reload, form, showMsg, callback) {
}, },
complete: function (jqXHR, textStatus) { complete: function (jqXHR, textStatus) {
// Remove loaders and stuff, ajax request is complete! // Remove loaders and stuff, ajax request is complete!
feedback.remove('.ajaxLoader-' + url); $('.ajaxLoader-' + url).remove();
if (typeof callback === "function") { if (typeof callback === "function") {
callback(jqXHR); callback(jqXHR);
} }
@@ -351,21 +351,26 @@ function getCookie(cname) {
} }
return ""; return "";
} }
var Accordion = function (el, multiple) { var Accordion = function (el, multiple, close) {
this.el = el || {}; this.el = el || {};
this.multiple = multiple || false; this.multiple = multiple || false;
this.close = (close === undefined) ? true : close;
// Variables privadas // Variables privadas
var links = this.el.find('.link'); var links = this.el.find('.link');
// Evento // Evento
links.on('click', { links.on('click', {
el: this.el, el: this.el,
multiple: this.multiple multiple: this.multiple,
close: this.close
}, this.dropdown); }, this.dropdown);
}; };
Accordion.prototype.dropdown = function (e) { Accordion.prototype.dropdown = function (e) {
var $el = e.data.el; var $el = e.data.el;
$this = $(this); $this = $(this);
$next = $this.next(); $next = $this.next();
if (!e.data.close && $this.parent().hasClass('open')) {
return
}
$next.slideToggle(); $next.slideToggle();
$this.parent().toggleClass('open'); $this.parent().toggleClass('open');
if (!e.data.multiple) { if (!e.data.multiple) {
@@ -465,3 +470,168 @@ function openPlexXML(endpoint, plextv, params) {
window.open(xml_url, '_blank'); window.open(xml_url, '_blank');
}); });
} }
function PopupCenter(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus();
}
return newWindow;
}
if (!localStorage.getItem('Tautulli_ClientId')) {
localStorage.setItem('Tautulli_ClientId', uuidv4());
}
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
var x_plex_headers = {
'Accept': 'application/json',
'X-Plex-Product': 'Tautulli',
'X-Plex-Version': 'Plex OAuth',
'X-Plex-Client-Identifier': localStorage.getItem('Tautulli_ClientId'),
'X-Plex-Platform': platform.name,
'X-Plex-Platform-Version': platform.version,
'X-Plex-Device': platform.os.toString(),
'X-Plex-Device-Name': platform.name
};
var plex_oauth_window = null;
const plex_oauth_loader = '<style>' +
'.login-loader-container {' +
'font-family: "Open Sans", Arial, sans-serif;' +
'position: absolute;' +
'top: 0;' +
'right: 0;' +
'bottom: 0;' +
'left: 0;' +
'}' +
'.login-loader-message {' +
'color: #282A2D;' +
'text-align: center;' +
'position: absolute;' +
'left: 50%;' +
'top: 25%;' +
'transform: translate(-50%, -50%);' +
'}' +
'.login-loader {' +
'border: 5px solid #ccc;' +
'-webkit-animation: spin 1s linear infinite;' +
'animation: spin 1s linear infinite;' +
'border-top: 5px solid #282A2D;' +
'border-radius: 50%;' +
'width: 50px;' +
'height: 50px;' +
'position: relative;' +
'left: calc(50% - 25px);' +
'}' +
'@keyframes spin {' +
'0% { transform: rotate(0deg); }' +
'100% { transform: rotate(360deg); }' +
'}' +
'</style>' +
'<div class="login-loader-container">' +
'<div class="login-loader-message">' +
'<div class="login-loader"></div>' +
'<br>' +
'Redirecting to the Plex login page...' +
'</div>' +
'</div>';
function closePlexOAuthWindow() {
if (plex_oauth_window) {
plex_oauth_window.close();
}
}
getPlexOAuthPin = function () {
var deferred = $.Deferred();
$.ajax({
url: 'https://plex.tv/api/v2/pins?strong=true',
type: 'POST',
headers: x_plex_headers,
success: function(data) {
plex_oauth_window.location = 'https://app.plex.tv/auth/#!?clientID=' + x_plex_headers['X-Plex-Client-Identifier'] + '&code=' + data.code;
deferred.resolve({pin: data.id, code: data.code});
},
error: function() {
closePlexOAuthWindow();
deferred.reject();
}
});
return deferred;
};
var polling = null;
function PlexOAuth(success, error, pre) {
if (typeof pre === "function") {
pre()
}
clearTimeout(polling);
closePlexOAuthWindow();
plex_oauth_window = PopupCenter('', 'Plex-OAuth', 600, 700);
$(plex_oauth_window.document.body).html(plex_oauth_loader);
getPlexOAuthPin().then(function (data) {
const pin = data.pin;
const code = data.code;
var keep_polling = true;
(function poll() {
polling = setTimeout(function () {
$.ajax({
url: 'https://plex.tv/api/v2/pins/' + pin,
type: 'GET',
headers: x_plex_headers,
success: function (data) {
if (data.authToken){
keep_polling = false;
closePlexOAuthWindow();
if (typeof success === "function") {
success(data.authToken)
}
}
},
error: function () {
keep_polling = false;
closePlexOAuthWindow();
if (typeof error === "function") {
error()
}
},
complete: function () {
if (keep_polling){
poll();
} else {
clearTimeout(polling);
}
},
timeout: 1000
});
}, 1000);
})();
}, function () {
closePlexOAuthWindow();
if (typeof error === "function") {
error()
}
});
}

View File

@@ -24,6 +24,7 @@ history_table_options = {
}, },
"pagingType": "full_numbers", "pagingType": "full_numbers",
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"processing": false, "processing": false,
"serverSide": true, "serverSide": true,
"pageLength": 25, "pageLength": 25,
@@ -289,7 +290,7 @@ history_table_options = {
' (filtered from ' + settings.json.total_duration + ' total)</span>'); ' (filtered from ' + settings.json.total_duration + ' total)</span>');
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0); showMsg(msg, false, false, 0);
$('[data-toggle="tooltip"]').tooltip('destroy'); $('[data-toggle="tooltip"]').tooltip('destroy');
$('[data-toggle="popover"]').popover('destroy'); $('[data-toggle="popover"]').popover('destroy');

View File

@@ -148,7 +148,7 @@ history_table_modal_options = {
}); });
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
} }
} }

View File

@@ -17,6 +17,7 @@ libraries_list_table_options = {
"pageLength": 25, "pageLength": 25,
"order": [ 2, 'asc'], "order": [ 2, 'asc'],
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"pagingType": "full_numbers", "pagingType": "full_numbers",
"autoWidth": false, "autoWidth": false,
"scrollX": true, "scrollX": true,
@@ -238,7 +239,7 @@ libraries_list_table_options = {
} }
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
}, },
"rowCallback": function (row, rowData) { "rowCallback": function (row, rowData) {

View File

@@ -10,6 +10,7 @@ login_log_table_options = {
"loadingRecords": '<i class="fa fa-refresh fa-spin"></i> Loading items...</div>' "loadingRecords": '<i class="fa fa-refresh fa-spin"></i> Loading items...</div>'
}, },
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"pagingType": "full_numbers", "pagingType": "full_numbers",
"processing": false, "processing": false,
"serverSide": true, "serverSide": true,
@@ -110,7 +111,7 @@ login_log_table_options = {
}, },
"preDrawCallback": function (settings) { "preDrawCallback": function (settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
} }
}; };

View File

@@ -6,6 +6,7 @@ var log_table_options = {
"order": [ 0, 'desc'], "order": [ 0, 'desc'],
"pageLength": 50, "pageLength": 50,
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"language": { "language": {
"search": "Search: ", "search": "Search: ",
"lengthMenu": "Show _MENU_ lines per page", "lengthMenu": "Show _MENU_ lines per page",
@@ -39,7 +40,7 @@ var log_table_options = {
$('#ajaxMsg').fadeOut(); $('#ajaxMsg').fadeOut();
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
} }
} }

View File

@@ -25,6 +25,7 @@ media_info_table_options = {
}, },
"pagingType": "full_numbers", "pagingType": "full_numbers",
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"processing": false, "processing": false,
"serverSide": true, "serverSide": true,
"pageLength": 25, "pageLength": 25,
@@ -299,7 +300,7 @@ media_info_table_options = {
' (filtered from ' + humanFileSize(settings.json.total_file_size) + ')</span>'); ' (filtered from ' + humanFileSize(settings.json.total_file_size) + ')</span>');
}, },
"preDrawCallback": function (settings) { "preDrawCallback": function (settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
}, },
"rowCallback": function (row, rowData, rowIndex) { "rowCallback": function (row, rowData, rowIndex) {

View File

@@ -6,6 +6,7 @@ newsletter_log_table_options = {
"order": [ 0, 'desc'], "order": [ 0, 'desc'],
"pageLength": 50, "pageLength": 50,
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"language": { "language": {
"search":"Search: ", "search":"Search: ",
"lengthMenu": "Show _MENU_ lines per page", "lengthMenu": "Show _MENU_ lines per page",
@@ -140,7 +141,7 @@ newsletter_log_table_options = {
}); });
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
} }
}; };

View File

@@ -6,6 +6,7 @@ notification_log_table_options = {
"order": [ 0, 'desc'], "order": [ 0, 'desc'],
"pageLength": 50, "pageLength": 50,
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"language": { "language": {
"search":"Search: ", "search":"Search: ",
"lengthMenu": "Show _MENU_ lines per page", "lengthMenu": "Show _MENU_ lines per page",
@@ -110,7 +111,7 @@ notification_log_table_options = {
}); });
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
} }
}; };

View File

@@ -6,6 +6,7 @@ var plex_log_table_options = {
"order": [ 0, 'desc'], "order": [ 0, 'desc'],
"pageLength": 50, "pageLength": 50,
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"language": { "language": {
"search": "Search: ", "search": "Search: ",
"lengthMenu": "Show _MENU_ lines per page", "lengthMenu": "Show _MENU_ lines per page",
@@ -39,7 +40,7 @@ var plex_log_table_options = {
$('#ajaxMsg').fadeOut(); $('#ajaxMsg').fadeOut();
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
} }
} }

View File

@@ -7,6 +7,7 @@ sync_table_options = {
"order": [ [ 0, 'desc'], [ 1, 'asc'], [2, 'asc'] ], "order": [ [ 0, 'desc'], [ 1, 'asc'], [2, 'asc'] ],
"pageLength": 25, "pageLength": 25,
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"language": { "language": {
"search": "Search: ", "search": "Search: ",
"lengthMenu": "Show _MENU_ lines per page", "lengthMenu": "Show _MENU_ lines per page",
@@ -147,7 +148,7 @@ sync_table_options = {
}, },
"preDrawCallback": function (settings) { "preDrawCallback": function (settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
}, },
"rowCallback": function (row, rowData, rowIndex) { "rowCallback": function (row, rowData, rowIndex) {

View File

@@ -10,6 +10,7 @@ user_ip_table_options = {
"loadingRecords": '<i class="fa fa-refresh fa-spin"></i> Loading items...</div>' "loadingRecords": '<i class="fa fa-refresh fa-spin"></i> Loading items...</div>'
}, },
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"pagingType": "full_numbers", "pagingType": "full_numbers",
"processing": false, "processing": false,
"serverSide": true, "serverSide": true,
@@ -141,7 +142,7 @@ user_ip_table_options = {
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
} }
} }

View File

@@ -34,6 +34,7 @@ users_list_table_options = {
"pageLength": 25, "pageLength": 25,
"order": [ 2, 'asc'], "order": [ 2, 'asc'],
"stateSave": true, "stateSave": true,
"stateDuration": 0,
"pagingType": "full_numbers", "pagingType": "full_numbers",
"autoWidth": false, "autoWidth": false,
"scrollX": true, "scrollX": true,
@@ -240,7 +241,7 @@ users_list_table_options = {
} }
}, },
"preDrawCallback": function(settings) { "preDrawCallback": function(settings) {
var msg = "<i class='fa fa-refresh fa-spin'></i>&nbspFetching rows..."; var msg = "<i class='fa fa-refresh fa-spin'></i>&nbsp; Fetching rows...";
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0)
}, },
"rowCallback": function (row, rowData) { "rowCallback": function (row, rowData) {

View File

@@ -1,4 +1,8 @@
<!doctype html> <%
import plexpy
plex_login = plexpy.CONFIG.HTTP_PLEX_ADMIN or plexpy.CONFIG.ALLOW_GUEST_ACCESS
%>
<!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
@@ -32,20 +36,48 @@
<meta name="msapplication-config" content="${http_root}images/favicon/browserconfig.xml?v=2.0.5"> <meta name="msapplication-config" content="${http_root}images/favicon/browserconfig.xml?v=2.0.5">
</head> </head>
<body> <body style="margin: 0; overflow: auto;">
<div class="body-container"> <div class="login-body-container">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="login-container"> <div class="login-container">
<div class="login-logo"> <div class="login-logo">
<img src="${http_root}images/logo-tautulli-100.png" height="100" alt="PlexPy"> <img src="${http_root}images/logo-tautulli-100.png" height="100" alt="Tautulli">
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-6 col-sm-offset-3"> <div class="col-sm-6 col-sm-offset-3">
<form id="login-form"> <div id="sign-in-alert" class="alert alert-danger login-alert"></div>
<div id="incorrect-login" class="alert alert-danger" style="text-align: center; padding: 8px; display: none;">
Incorrect username or password.
</div> </div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<ul id="login-methods" class="accordion list-unstyled">
% if plex_login:
<li class="open">
<div class="link login-method-header">
Sign In with Plex
</div>
<ul class="submenu login-button-plex" style="display: block;">
<li>
<div>
<button id="sign-in-plex" class="btn btn-bright login-button"><i class="fa fa-sign-in"></i>&nbsp; Sign In</button>
</div>
<div class="remember-group">
<label class="control-label">
<input type="checkbox" id="remember_me_plex" name="remember_me_plex" title="for 30 days" value="1" checked="checked" /> Remember me
</label>
</div>
</li>
</ul>
</li>
% endif
<li class="${'open' if not plex_login else ''}">
<div class="link login-method-header">
Sign In with Tautulli
</div>
<ul class="submenu" style="${'display: block;' if not plex_login else ''}">
<li>
<form id="login-form">
<div class="form-group"> <div class="form-group">
<label for="username" class="control-label"> <label for="username" class="control-label">
Username Username
@@ -58,15 +90,19 @@
</label> </label>
<input type="password" id="password" name="password" class="form-control"> <input type="password" id="password" name="password" class="form-control">
</div> </div>
<div class="form-footer"> <div class="form-group">
<div class="remember-group"> <span class="remember-group">
<label class="control-label"> <label class="control-label">
<input type="checkbox" id="remember_me" name="remember_me" title="for 30 days" value="1" checked="checked" /> Remember me <input type="checkbox" id="remember_me" name="remember_me" title="for 30 days" value="1" checked="checked" /> Remember me
</label> </label>
</div> </span>
<button id="sign-in" type="submit" class="btn btn-bright login-button"><i class="fa fa-sign-in"></i>&nbsp; Sign In</button> <button id="sign-in" type="submit" class="btn btn-bright login-button"><i class="fa fa-sign-in"></i>&nbsp; Sign In</button>
</div> </div>
</form> </form>
</li>
</ul>
</li>
</ul>
</div> </div>
</div> </div>
</div> </div>
@@ -75,29 +111,76 @@
</div> </div>
<script src="${http_root}js/jquery-2.1.4.min.js"></script> <script src="${http_root}js/jquery-2.1.4.min.js"></script>
<script src="${http_root}js/platform.min.js"></script>
<script src="${http_root}js/script.js${cache_param}"></script>
<script> <script>
var login_accordion = new Accordion($('#login-methods'), false, false);
function OAuthSuccessCallback(authToken) {
signIn(true, authToken);
}
function OAuthErrorCallback() {
$('#sign-in-alert').text('Error communicating with Plex.tv.').show();
}
$('#sign-in-plex').click(function() {
PlexOAuth(OAuthSuccessCallback, OAuthErrorCallback);
});
$('#login-form').submit(function(event) { $('#login-form').submit(function(event) {
event.preventDefault(); event.preventDefault();
$('#sign-in').prop('disabled', true).html('<i class="fa fa-refresh fa-spin"></i>&nbsp; Sign In'); signIn(false);
});
function signIn(plex, token) {
$('.login-container button').prop('disabled', true);
if (plex) {
$('#sign-in-plex').html('<i class="fa fa-refresh fa-spin"></i>&nbsp; Sign In');
} else {
$('#sign-in').html('<i class="fa fa-refresh fa-spin"></i>&nbsp; Sign In');
}
const username = plex ? null : $('#username').val();
const password = plex ? null : $('#password').val();
const remember_me = plex ? ($('#remember_me_plex').is(':checked') ? '1' : '0')
: ($('#remember_me').is(':checked') ? '1' : '0');
var data = {
username: username,
password: password,
token: token,
remember_me: remember_me
};
data = $.extend(data, x_plex_headers);
$.ajax({ $.ajax({
url: '${http_root}auth/signin', url: '${http_root}auth/signin',
type: 'POST', type: 'POST',
data: $(this).serialize(), data: data,
dataType: 'json', dataType: 'json',
statusCode: { statusCode: {
200: function() { 200: function() {
window.location = "${redirect_uri or http_root}"; window.location = "${redirect_uri or http_root}";
}, },
401: function() { 401: function() {
$('#incorrect-login').show(); if (plex) {
$('#sign-in-alert').text('Invalid Plex Login.').show();
} else {
$('#sign-in-alert').text('Incorrect username or password.').show();
$('#username').focus(); $('#username').focus();
} }
}
}, },
complete: function() { complete: function() {
$('#sign-in').prop('disabled', false).html('<i class="fa fa-sign-in"></i>&nbsp; Sign In'); $('.login-container button').prop('disabled', false);
if (plex) {
$('#sign-in-plex').html('<i class="fa fa-sign-in"></i>&nbsp; Sign In');
} else {
$('#sign-in').html('<i class="fa fa-sign-in"></i>&nbsp; Sign In');
}
} }
}); });
}); }
</script> </script>
</body> </body>
</html> </html>

View File

@@ -21,7 +21,7 @@
<div class="row"> <div class="row">
<div class="login-container"> <div class="login-container">
<div class="newsletter-logo"> <div class="newsletter-logo">
<img src="${http_root}images/newsletter/newsletter-header.png" height="100" alt="PlexPy"> <img src="${http_root}images/newsletter/newsletter-header.png" height="100" alt="Tautulli">
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-6 col-sm-offset-3"> <div class="col-sm-6 col-sm-offset-3">

View File

@@ -766,9 +766,12 @@
// auto resizing textarea for custom notification message body // auto resizing textarea for custom notification message body
$('textarea[data-autoresize]').each(function () { $('textarea[data-autoresize]').each(function () {
var modal_body = $(this).closest('.modal-body');
var offset = this.offsetHeight - this.clientHeight; var offset = this.offsetHeight - this.clientHeight;
var resizeTextarea = function (el) { var resizeTextarea = function (el) {
var modal_offset = modal_body.scrollTop();
$(el).css('height', 'auto').css('height', el.scrollHeight + offset); $(el).css('height', 'auto').css('height', el.scrollHeight + offset);
modal_body.scrollTop(modal_offset);
}; };
$(this).on('focus keyup input', function () { resizeTextarea(this); }).removeAttr('data-autoresize'); $(this).on('focus keyup input', function () { resizeTextarea(this); }).removeAttr('data-autoresize');
}); });

View File

@@ -811,9 +811,12 @@
// auto resizing textarea for custom notification message body // auto resizing textarea for custom notification message body
$('textarea[data-autoresize]').each(function () { $('textarea[data-autoresize]').each(function () {
var modal_body = $(this).closest('.modal-body');
var offset = this.offsetHeight - this.clientHeight; var offset = this.offsetHeight - this.clientHeight;
var resizeTextarea = function (el) { var resizeTextarea = function (el) {
var modal_offset = modal_body.scrollTop();
$(el).css('height', 'auto').css('height', el.scrollHeight + offset); $(el).css('height', 'auto').css('height', el.scrollHeight + offset);
modal_body.scrollTop(modal_offset);
}; };
$(this).on('focus keyup input', function () { resizeTextarea(this); }).removeAttr('data-autoresize'); $(this).on('focus keyup input', function () { resizeTextarea(this); }).removeAttr('data-autoresize');
}); });

View File

@@ -650,12 +650,20 @@
</div> </div>
<div class="form-group has-feedback" id="pms_ip_group"> <div class="form-group has-feedback" id="pms_ip_group">
<label for="pms_ip">Plex IP Address or Hostname</label> <label for="pms_ip_selectize">Plex IP Address or Hostname</label>
<div class="row"> <div class="row">
<div class="col-md-9" id="selectize-pms-ip-container"> <div class="col-md-9" id="selectize-pms-ip-container">
<div class="input-group"> <div class="input-group">
<select class="form-control pms-settings selectize-pms-ip" id="pms_ip" name="pms_ip" data-parsley-trigger="change" aria-describedby="server-verified" data-parsley-errors-container="#pms_ip_error" required> <select class="form-control pms-settings selectize-pms-ip" id="pms_ip_selectize" data-parsley-trigger="change" aria-describedby="server-verified" data-parsley-errors-container="#pms_ip_error" required>
<option value="${config['pms_ip']}" selected>${config['pms_ip']}</option> <option value="${config['pms_ip']}:${config['pms_port']}"
data-identifier="${config['pms_identifier']}"
data-ip="${config['pms_ip']}"
data-port="${config['pms_port']}"
data-local="${int(not int(config['pms_is_remote']))}"
data-ssl="${config['pms_ssl']}"
data-is_cloud="${config['pms_is_cloud']}"
data-label="${config['pms_name'] or 'Local'}"
selected>${config['pms_ip']}</option>
</select> </select>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-form" type="button" id="verify_server_button">Verify Server</button> <button class="btn btn-form" type="button" id="verify_server_button">Verify Server</button>
@@ -738,6 +746,7 @@
</p> </p>
</div> </div>
<input type="hidden" id="pms_ip" name="pms_ip" value="${config['pms_ip']}">
<input type="hidden" id="pms_is_cloud" name="pms_is_cloud" value="${config['pms_is_cloud']}"> <input type="hidden" id="pms_is_cloud" name="pms_is_cloud" value="${config['pms_is_cloud']}">
<input type="checkbox" name="server_changed" id="server_changed" value="1" style="display: none;"> <input type="checkbox" name="server_changed" id="server_changed" value="1" style="display: none;">
@@ -842,21 +851,23 @@
<h3>Plex.tv Authentication</h3> <h3>Plex.tv Authentication</h3>
</div> </div>
<div class="form-group"> <div class="form-group has-feedback">
<label for="pms_token">Plex.tv Account Token</label> <label for="pms_token">Plex.tv Account Token</label>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" id="pms_token" name="pms_token" value="${config['pms_token']}" data-parsley-trigger="change" data-parsley-errors-container="#pms_token_error" required> <input type="text" class="form-control" id="pms_token" name="pms_token" value="${config['pms_token']}" data-parsley-trigger="change" data-parsley-errors-container="#pms_token_error" required>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-form" type="button" data-toggle="modal" data-target="#pms-auth-modal">Fetch Token</button> <button id="sign-in-plex" class="btn btn-form" type="button">Fetch Token</button>
</span> </span>
</div> </div>
<span class="form-control-feedback" id="token_verify" aria-hidden="true" style="right: 80px;"></span>
</div> </div>
<div id="pms_token_error" class="alert alert-danger settings-alert" role="alert"></div> <div id="pms_token_error" class="alert alert-danger settings-alert" role="alert"></div>
</div> </div>
<p class="help-block">Token for Plex.tv authentication.</p> <p class="help-block">Token for Plex.tv authentication.</p>
</div> </div>
<input type="hidden" id="pms_uuid" name="pms_uuid" value="${config['pms_uuid']}">
<p><input type="button" class="btn btn-bright save-button" value="Save" data-success="Changes saved successfully"></p> <p><input type="button" class="btn btn-bright save-button" value="Save" data-success="Changes saved successfully"></p>
@@ -1366,49 +1377,6 @@
</div> </div>
</div> </div>
</div> </div>
<div id="pms-auth-modal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="ip-info-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
<h4 class="modal-title">Fetch Plex.tv Token</h4>
</div>
<div class="modal-body" id="modal-text">
<div>
<p class="help-block">
This will attempt to fetch a new Plex.tv token for you. Tautulli does not store your username and password.
Note: This will not work on Internet Explorer 9 or lower.
</p>
<div class="form-group">
<label for="pms_username">Plex.tv Username</label>
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control" id="pms_username" name="pms_username" size="30">
</div>
</div>
<p class="help-block">Username for Plex.tv authentication.</p>
</div>
<div class="form-group">
<label for="pms_password">Plex.tv Password</label>
<div class="row">
<div class="col-md-6">
<input type="password" class="form-control" id="pms_password" name="pms_password" size="30">
</div>
</div>
<p class="help-block">Password for Plex.tv authentication.</p>
</div>
</div>
</div>
<div class="modal-footer">
<div style="float: left;">
<strong><span id="pms-token-status"></span></strong>
</div>
<input type="button" id="get-pms-auth-token" class="btn btn-bright" value="Fetch Token">
</div>
</div>
</div>
</div>
<div id="app-import-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="app-import-modal"></div> <div id="app-import-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="app-import-modal"></div>
<div id="add-notifier-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="add-notifier-modal"> <div id="add-notifier-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="add-notifier-modal">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
@@ -2094,7 +2062,7 @@ $(document).ready(function() {
} }
}); });
var $select_pms = $('#pms_ip').selectize({ var $select_pms = $('#pms_ip_selectize').selectize({
createOnBlur: true, createOnBlur: true,
openOnFocus: true, openOnFocus: true,
maxItems: 1, maxItems: 1,
@@ -2105,13 +2073,19 @@ $(document).ready(function() {
dropdownParent: '#selectize-pms-ip-container', dropdownParent: '#selectize-pms-ip-container',
render: { render: {
item: function (item, escape) { item: function (item, escape) {
if (!item.label) {
$.extend(item,
$(this.revertSettings.$children)
.filter('[value=' + item.value + ']').data()
);
}
var label = item.label || item.value; var label = item.label || item.value;
var caption = item.label ? item.value : null; var caption = item.label ? item.ip : null;
return '<div data-ssl="' + item.httpsRequired + return '<div data-identifier="' + item.clientIdentifier +
'" data-local="' + item.local +
'" data-identifier="' + item.clientIdentifier +
'" data-ip="' + item.ip + '" data-ip="' + item.ip +
'" data-port="' + item.port + '" data-port="' + item.port +
'" data-local="' + item.local +
'" data-ssl="' + item.httpsRequired +
'" data-is_cloud="' + item.is_cloud + '" data-is_cloud="' + item.is_cloud +
'" data-label="' + item.label + '">' + '" data-label="' + item.label + '">' +
'<span class="item-text">' + escape(label) + '</span>' + '<span class="item-text">' + escape(label) + '</span>' +
@@ -2121,11 +2095,11 @@ $(document).ready(function() {
option: function (item, escape) { option: function (item, escape) {
var label = item.label || item.value; var label = item.label || item.value;
var caption = item.label ? item.value : null; var caption = item.label ? item.value : null;
return '<div data-ssl="' + item.httpsRequired + return '<div data-identifier="' + item.clientIdentifier +
'" data-local="' + item.local +
'" data-identifier="' + item.clientIdentifier +
'" data-ip="' + item.ip + '" data-ip="' + item.ip +
'" data-port="' + item.port + '" data-port="' + item.port +
'" data-local="' + item.local +
'" data-ssl="' + item.httpsRequired +
'" data-is_cloud="' + item.is_cloud + '" data-is_cloud="' + item.is_cloud +
'" data-label="' + item.label + '">' + '" data-label="' + item.label + '">' +
escape(label) + escape(label) +
@@ -2136,15 +2110,24 @@ $(document).ready(function() {
create: function(input) { create: function(input) {
return {label: '', value: input}; return {label: '', value: input};
}, },
onInitialize: function () {
var s = this;
this.revertSettings.$children.each(function () {
$.extend(s.options[this.value], $(this).data());
});
},
onChange: function (item) { onChange: function (item) {
var pms_ip_selected = this.getItem(item)[0]; var pms_ip_selected = this.getItem(item)[0];
var identifier = $(pms_ip_selected).data('identifier'); var identifier = $(pms_ip_selected).data('identifier');
var ip = $(pms_ip_selected).data('ip');
var port = $(pms_ip_selected).data('port'); var port = $(pms_ip_selected).data('port');
var local = $(pms_ip_selected).data('local'); var local = $(pms_ip_selected).data('local');
var ssl = $(pms_ip_selected).data('ssl'); var ssl = $(pms_ip_selected).data('ssl');
var is_cloud = $(pms_ip_selected).data('is_cloud'); var is_cloud = $(pms_ip_selected).data('is_cloud');
var value = $(pms_ip_selected).data('value');
$("#pms_identifier").val(identifier !== 'undefined' ? identifier : ''); $("#pms_identifier").val(identifier !== 'undefined' ? identifier : '');
$('#pms_ip').val(ip !== 'undefined' ? ip : value);
$('#pms_port').val(port !== 'undefined' ? port : 32400); $('#pms_port').val(port !== 'undefined' ? port : 32400);
$('#pms_is_remote_checkbox').prop('checked', (local !== 'undefined' && local === 0)); $('#pms_is_remote_checkbox').prop('checked', (local !== 'undefined' && local === 0));
$('#pms_is_remote').val(local !== 'undefined' && local === 0 ? 1 : 0); $('#pms_is_remote').val(local !== 'undefined' && local === 0 ? 1 : 0);
@@ -2169,9 +2152,10 @@ $(document).ready(function() {
}, },
success: function (result) { success: function (result) {
if (result) { if (result) {
var existing_value = $('#pms_ip').val(); var existing_ip = $('#pms_ip').val();
var existing_port = $('#pms_port').val();
result.forEach(function (item) { result.forEach(function (item) {
if (item.value === existing_value) { if (item.ip === existing_ip && item.port === existing_port) {
select_pms.updateOption(item.value, item); select_pms.updateOption(item.value, item);
} else { } else {
select_pms.addOption(item); select_pms.addOption(item);
@@ -2296,40 +2280,21 @@ $(document).ready(function() {
window.open(pms_web_url, '_blank'); window.open(pms_web_url, '_blank');
}); });
// Plex.tv auth token fetch function OAuthPreFunction() {
$("#get-pms-auth-token").click(function() { $("#token_verify").html('<i class="fa fa-refresh fa-spin"></i>').fadeIn('fast');
$("#pms-token-status").html('<i class="fa fa-refresh fa-spin"></i> Fetching token...'); }
var pms_username = $.trim($("#pms_username").val()); function OAuthSuccessCallback(authToken) {
var pms_password = $.trim($("#pms_password").val());
if ((pms_username !== '') && (pms_password !== '')) {
$.ajax({
type: 'GET',
url: 'get_plexpy_pms_token',
data: {
username: pms_username,
password: pms_password,
force: true
},
cache: false,
async: true,
complete: function(xhr, status) {
var result = $.parseJSON(xhr.responseText);
var msg = result.message;
if (result.result == 'success') {
var authToken = result.token;
$("#pms-token-status").html('<i class="fa fa-check"></i> ' + msg);
$("#pms_token").val(authToken); $("#pms_token").val(authToken);
$('#pms-auth-modal').modal('hide'); $("#pms_uuid").val(x_plex_headers['X-Plex-Client-Identifier']);
$("#token_verify").html('<i class="fa fa-check"></i>').fadeIn('fast');
getServerOptions(authToken); getServerOptions(authToken);
} else {
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i> ' + msg);
} }
loadUpdateDistros(); function OAuthErrorCallback() {
} $("#token_verify").html('<i class="fa fa-close"></i>').fadeIn('fast');
});
} else {
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i> Username and password required.');
} }
$('#sign-in-plex').click(function() {
PlexOAuth(OAuthSuccessCallback, OAuthErrorCallback, OAuthPreFunction);
}); });
// Load database import modal // Load database import modal

View File

@@ -60,7 +60,7 @@
$('#popout-iframe-button').click(function () { $('#popout-iframe-button').click(function () {
var iframe = $('#support-iframe'); var iframe = $('#support-iframe');
popout_chat = window.open(iframe.data('src'), 'Tautulli-Discord-Support', 'width=1280,height=720'); popout_chat = PopupCenter(iframe.data('src'), 'Tautulli-Discord-Support', 1280, 720);
iframe.attr('src', '').fadeOut(); iframe.attr('src', '').fadeOut();
$('.iframe-overlay').fadeIn(); $('.iframe-overlay').fadeIn();
}); });

View File

@@ -203,8 +203,8 @@ DOCUMENTATION :: END
$('#confirm-modal-update').modal(); $('#confirm-modal-update').modal();
$('#confirm-modal-update').one('click', '#confirm-update', function () { $('#confirm-modal-update').one('click', '#confirm-update', function () {
$(this).prop('disabled', true); $(this).prop('disabled', true);
var msg = '<i class="fa fa-refresh fa-spin"></i>&nbspUpdating database...' var msg = '<i class="fa fa-refresh fa-spin"></i>&nbsp; Updating database...';
showMsg(msg, false, false, 0) showMsg(msg, false, false, 0);
$.ajax({ $.ajax({
url: 'update_metadata_details', url: 'update_metadata_details',

View File

@@ -52,51 +52,53 @@
<form> <form>
<div class="wizard-card" data-cardname="card1"> <div class="wizard-card" data-cardname="card1">
<div style="float: right;"> <div style="float: right;">
<img src="${http_root}images/logo-tautulli-45.png" height="45" alt="PlexPy"> <img src="${http_root}images/logo-tautulli-45.png" height="45" alt="Tautulli">
</div> </div>
<h3 style="line-height: 50px;">Welcome!</h3> <h3 style="line-height: 50px;">Welcome!</h3>
<br /> <div class="wizard-input-section">
<div> <p class="welcome-message">
Thanks for taking the time to try out Tautulli. Hope you find it useful. Thanks for taking the time to try out Tautulli. Hope you find it useful.
<br /><br /> </p>
<p class="welcome-message">
Tautulli requires a permanent internet connection to ensure a reliable experience. Tautulli requires a permanent internet connection to ensure a reliable experience.
<br /><br /> </p>
<p class="welcome-message">
This wizard will help you get set up, to continue press Next. This wizard will help you get set up, to continue press Next.
</p>
</div> </div>
</div> </div>
<div class="wizard-card" data-cardname="card2"> <div class="wizard-card" data-cardname="card2">
<h3>Plex Authentication</h3> <h3>Plex Authentication</h3>
<p class="help-block">Enter your Plex.tv username and password. Tautulli does not store your username or password.</p>
<div class="wizard-input-section"> <div class="wizard-input-section">
<label for="pms_username">Plex.tv Username</label> <p class="help-block">
<div class="row"> Tautulli requires a Plex.tv account. Click the button below to sign in on Plex.tv. You may need to allow popups in your browser.
<div class="col-xs-8"> </p>
<input type="text" class="form-control pms-auth" id="pms_username" placeholder="" required>
</div> </div>
</div> <input type="hidden" class="form-control" name="pms_token" id="pms_token" value="" data-validate="validatePMStoken">
</div> <a class="btn btn-dark" id="sign-in-plex" href="#" role="button">Sign In with Plex</a>
<div class="wizard-input-section"> <span style="margin-left: 10px; display: none;" id="pms-token-status"></span>
<label for="pms_password">Plex.tv Password</label>
<div class="row">
<div class="col-xs-8">
<input type="password" class="form-control pms-auth" id="pms_password" placeholder="" required>
</div>
</div>
</div>
<input type="hidden" class="form-control pms-auth" name="pms_token" id="pms_token" value="" data-validate="validatePMStoken">
<a class="btn btn-dark" id="pms-authenticate" href="#" role="button">Authenticate</a><span style="margin-left: 10px; display: none;" id="pms-token-status"></span>
</div> </div>
<div class="wizard-card" data-cardname="card3"> <div class="wizard-card" data-cardname="card3">
<h3>Plex Media Server</h3> <h3>Plex Media Server</h3>
<div class="wizard-input-section">
<p class="help-block"> <p class="help-block">
Select your Plex Media Server from the dropdown menu or enter an IP address or hostname. Select your Plex Media Server from the dropdown menu or enter an IP address or hostname.
</p> </p>
</div>
<div class="wizard-input-section"> <div class="wizard-input-section">
<label for="pms_ip">Plex IP or Hostname</label> <label for="pms_ip_selectize">Plex IP Address or Hostname</label>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<select class="form-control pms-settings selectize-pms-ip" id="pms_ip" name="pms_ip"> <select class="form-control pms-settings selectize-pms-ip" id="pms_ip_selectize">
<option value="${config['pms_ip']}" selected>${config['pms_ip']}</option> <option value="${config['pms_ip']}:${config['pms_port']}"
data-identifier="${config['pms_identifier']}"
data-ip="${config['pms_ip']}"
data-port="${config['pms_port']}"
data-local="${int(not int(config['pms_is_remote']))}"
data-ssl="${config['pms_ssl']}"
data-is_cloud="${config['pms_is_cloud']}"
data-label="${config['pms_name'] or 'Local'}"
selected>${config['pms_ip']}</option>
</select> </select>
</div> </div>
</div> </div>
@@ -126,15 +128,20 @@
</div> </div>
</div> </div>
<input type="hidden" id="pms_valid" data-validate="validatePMSip" value=""> <input type="hidden" id="pms_valid" data-validate="validatePMSip" value="">
<input type="hidden" id="pms_ip" name="pms_ip" value="${config['pms_ip']}">
<input type="hidden" id="pms_is_cloud" name="pms_is_cloud" value="${config['pms_is_cloud']}"> <input type="hidden" id="pms_is_cloud" name="pms_is_cloud" value="${config['pms_is_cloud']}">
<input type="hidden" id="pms_identifier" name="pms_identifier" value="${config['pms_identifier']}"> <input type="hidden" id="pms_identifier" name="pms_identifier" value="${config['pms_identifier']}">
<a class="btn btn-dark" id="verify-plex-server" href="#" role="button">Verify</a><span style="margin-left: 10px; display: none;" id="pms-verify-status"></span> <a class="btn btn-dark" id="verify-plex-server" href="#" role="button">Verify</a>
<span style="margin-left: 10px; display: none;" id="pms-verify-status"></span>
</div> </div>
<div class="wizard-card" data-cardname="card4"> <div class="wizard-card" data-cardname="card4">
<h3>Activity Logging</h3> <h3>Activity Logging</h3>
<p class="help-block">Tautulli will keep a history of all streaming activity on your Plex server.</p> <div class="wizard-input-section">
<p class="help-block">
Tautulli will keep a history of all streaming activity on your Plex server.
</p>
</div>
<div class="wizard-input-section"> <div class="wizard-input-section">
<label for="logging_ignore_interval">Ignore Interval</label> <label for="logging_ignore_interval">Ignore Interval</label>
<div class="row"> <div class="row">
@@ -145,29 +152,38 @@
</div> </div>
<p class="help-block">The interval (in seconds) an item must be in a playing state before logging it. 0 to disable.</p> <p class="help-block">The interval (in seconds) an item must be in a playing state before logging it. 0 to disable.</p>
</div> </div>
<div class="wizard-input-section">
<p class="help-block"> <p class="help-block">
Additional options to disable history logging for certain libraries or users can be found by editing them Additional options to disable history logging for certain libraries or users can be found by editing them
on the <strong>Libraries</strong> or <strong>Users</strong> pages. on the <strong>Libraries</strong> or <strong>Users</strong> pages.
</p> </p>
</div> </div>
</div>
<div class="wizard-card" data-cardname="card4"> <div class="wizard-card" data-cardname="card4">
<h3>Notifications</h3> <h3>Notifications</h3>
<p class="help-block">Tautulli can send a wide variety of notifications to alert you of activity on your Plex server.</p> <div class="wizard-input-section">
<p class="help-block">
Tautulli can send a wide variety of notifications to alert you of activity on your Plex server.
</p>
<p class="help-block"> <p class="help-block">
To set up a notification agent, navigate to the <strong>Settings</strong> page To set up a notification agent, navigate to the <strong>Settings</strong> page
and to the <strong>Notification Agents</strong> tab after you have completed this setup wizard. and to the <strong>Notification Agents</strong> tab after you have completed this setup wizard.
</p> </p>
</div> </div>
</div>
<div class="wizard-card" data-cardname="card5"> <div class="wizard-card" data-cardname="card5">
<h3>Database Import</h3> <h3>Database Import</h3>
<p class="help-block">If you have an existing PlexWatch/Plexivity database, you can import the data into Tautulli.</p> <div class="wizard-input-section">
<p class="help-block">
If you have an existing PlexWatch/Plexivity database, you can import the data into Tautulli.
</p>
<p class="help-block"> <p class="help-block">
To import a database, navigate to the <strong>Settings</strong> page To import a database, navigate to the <strong>Settings</strong> page
and to the <strong>Import & Backups</strong> tab after you have completed this setup wizard. and to the <strong>Import & Backups</strong> tab after you have completed this setup wizard.
</p> </p>
</div>
<!-- Required fields but hidden --> <!-- Required fields but hidden -->
<div style="display: none;"> <div style="display: none;">
@@ -205,6 +221,7 @@
<script src="${http_root}js/jquery-2.1.4.min.js"></script> <script src="${http_root}js/jquery-2.1.4.min.js"></script>
<script src="${http_root}js/bootstrap.min.js"></script> <script src="${http_root}js/bootstrap.min.js"></script>
<script src="${http_root}js/selectize.min.js"></script> <script src="${http_root}js/selectize.min.js"></script>
<script src="${http_root}js/platform.min.js"></script>
<script src="${http_root}js/script.js${cache_param}"></script> <script src="${http_root}js/script.js${cache_param}"></script>
<script src="${http_root}js/bootstrap-wizard.min.js"></script> <script src="${http_root}js/bootstrap-wizard.min.js"></script>
<script> <script>
@@ -306,7 +323,7 @@ $(document).ready(function() {
} }
}); });
var $select_pms = $('#pms_ip').selectize({ var $select_pms = $('#pms_ip_selectize').selectize({
createOnBlur: true, createOnBlur: true,
openOnFocus: true, openOnFocus: true,
maxItems: 1, maxItems: 1,
@@ -316,13 +333,19 @@ $(document).ready(function() {
inputClass: 'form-control selectize-input', inputClass: 'form-control selectize-input',
render: { render: {
item: function (item, escape) { item: function (item, escape) {
if (!item.label) {
$.extend(item,
$(this.revertSettings.$children)
.filter('[value=' + item.value + ']').data()
);
}
var label = item.label || item.value; var label = item.label || item.value;
var caption = item.label ? item.value : null; var caption = item.label ? item.ip : null;
return '<div data-ssl="' + item.httpsRequired + return '<div data-identifier="' + item.clientIdentifier +
'" data-local="' + item.local +
'" data-identifier="' + item.clientIdentifier +
'" data-ip="' + item.ip + '" data-ip="' + item.ip +
'" data-port="' + item.port + '" data-port="' + item.port +
'" data-local="' + item.local +
'" data-ssl="' + item.httpsRequired +
'" data-is_cloud="' + item.is_cloud + '" data-is_cloud="' + item.is_cloud +
'" data-label="' + item.label + '">' + '" data-label="' + item.label + '">' +
'<span class="item-text">' + escape(label) + '</span>' + '<span class="item-text">' + escape(label) + '</span>' +
@@ -332,11 +355,11 @@ $(document).ready(function() {
option: function (item, escape) { option: function (item, escape) {
var label = item.label || item.value; var label = item.label || item.value;
var caption = item.label ? item.value : null; var caption = item.label ? item.value : null;
return '<div data-ssl="' + item.httpsRequired + return '<div data-identifier="' + item.clientIdentifier +
'" data-local="' + item.local +
'" data-identifier="' + item.clientIdentifier +
'" data-ip="' + item.ip + '" data-ip="' + item.ip +
'" data-port="' + item.port + '" data-port="' + item.port +
'" data-local="' + item.local +
'" data-ssl="' + item.httpsRequired +
'" data-is_cloud="' + item.is_cloud + '" data-is_cloud="' + item.is_cloud +
'" data-label="' + item.label + '">' + '" data-label="' + item.label + '">' +
escape(label) + escape(label) +
@@ -347,18 +370,27 @@ $(document).ready(function() {
create: function(input) { create: function(input) {
return {label: '', value: input}; return {label: '', value: input};
}, },
onInitialize: function () {
var s = this;
this.revertSettings.$children.each(function () {
$.extend(s.options[this.value], $(this).data());
});
},
onChange: function (item) { onChange: function (item) {
var pms_ip_selected = this.getItem(item)[0]; var pms_ip_selected = this.getItem(item)[0];
var identifier = $(pms_ip_selected).data('identifier'); var identifier = $(pms_ip_selected).data('identifier');
var ip = $(pms_ip_selected).data('ip');
var port = $(pms_ip_selected).data('port'); var port = $(pms_ip_selected).data('port');
var local = $(pms_ip_selected).data('local'); var local = $(pms_ip_selected).data('local');
var ssl = $(pms_ip_selected).data('ssl'); var ssl = $(pms_ip_selected).data('ssl');
var is_cloud = $(pms_ip_selected).data('is_cloud'); var is_cloud = $(pms_ip_selected).data('is_cloud');
var value = $(pms_ip_selected).data('value');
$("#pms_valid").val(identifier !== 'undefined' ? 'valid' : ''); $("#pms_valid").val(identifier !== 'undefined' ? 'valid' : '');
$("#pms-verify-status").html(identifier !== 'undefined' ? '<i class="fa fa-check"></i> Server found!' : '').fadeIn('fast'); $("#pms-verify-status").html(identifier !== 'undefined' ? '<i class="fa fa-check"></i>&nbsp; Server found!' : '').fadeIn('fast');
$("#pms_identifier").val(identifier !== 'undefined' ? identifier : ''); $("#pms_identifier").val(identifier !== 'undefined' ? identifier : '');
$('#pms_ip').val(ip !== 'undefined' ? ip : value);
$('#pms_port').val(port !== 'undefined' ? port : 32400); $('#pms_port').val(port !== 'undefined' ? port : 32400);
$('#pms_is_remote_checkbox').prop('checked', (local !== 'undefined' && local === 0)); $('#pms_is_remote_checkbox').prop('checked', (local !== 'undefined' && local === 0));
$('#pms_is_remote').val(local !== 'undefined' && local === 0 ? 1 : 0); $('#pms_is_remote').val(local !== 'undefined' && local === 0 ? 1 : 0);
@@ -391,9 +423,10 @@ $(document).ready(function() {
}, },
success: function (result) { success: function (result) {
if (result) { if (result) {
var existing_value = $('#pms_ip').val(); var existing_ip = $('#pms_ip').val();
var existing_port = $('#pms_port').val();
result.forEach(function (item) { result.forEach(function (item) {
if (item.value === existing_value) { if (item.ip === existing_ip && item.port === existing_port) {
select_pms.updateOption(item.value, item); select_pms.updateOption(item.value, item);
} else { } else {
select_pms.addOption(item); select_pms.addOption(item);
@@ -414,7 +447,7 @@ $(document).ready(function() {
var pms_ssl = $("#pms_ssl").val(); var pms_ssl = $("#pms_ssl").val();
var pms_is_remote = $("#pms_is_remote").val(); var pms_is_remote = $("#pms_is_remote").val();
if ((pms_ip !== '') || (pms_port !== '')) { if ((pms_ip !== '') || (pms_port !== '')) {
$("#pms-verify-status").html('<i class="fa fa-refresh fa-spin"></i> Validating server...'); $("#pms-verify-status").html('<i class="fa fa-refresh fa-spin"></i>&nbsp; Validating server...');
$('#pms-verify-status').fadeIn('fast'); $('#pms-verify-status').fadeIn('fast');
$.ajax({ $.ajax({
url: 'get_server_id', url: 'get_server_id',
@@ -429,7 +462,7 @@ $(document).ready(function() {
async: true, async: true,
timeout: 5000, timeout: 5000,
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
$("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i> This is not a Plex Server!'); $("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i>&nbsp; This is not a Plex Server!');
$('#pms-verify-status').fadeIn('fast'); $('#pms-verify-status').fadeIn('fast');
}, },
success: function(xhr, status) { success: function(xhr, status) {
@@ -437,18 +470,18 @@ $(document).ready(function() {
var identifier = result.identifier; var identifier = result.identifier;
if (identifier) { if (identifier) {
$("#pms_identifier").val(identifier); $("#pms_identifier").val(identifier);
$("#pms-verify-status").html('<i class="fa fa-check"></i> Server found!'); $("#pms-verify-status").html('<i class="fa fa-check"></i>&nbsp; Server found!');
$('#pms-verify-status').fadeIn('fast'); $('#pms-verify-status').fadeIn('fast');
pms_verified = true; pms_verified = true;
$("#pms_valid").val("valid"); $("#pms_valid").val("valid");
} else { } else {
$("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i> This is not a Plex Server!'); $("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i>&nbsp; This is not a Plex Server!');
$('#pms-verify-status').fadeIn('fast'); $('#pms-verify-status').fadeIn('fast');
} }
} }
}); });
} else { } else {
$("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i> Please enter both fields.'); $("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i>&nbsp; Please enter both fields.');
$('#pms-verify-status').fadeIn('fast'); $('#pms-verify-status').fadeIn('fast');
} }
} }
@@ -460,47 +493,22 @@ $(document).ready(function() {
$("#pms-verify-status").html(""); $("#pms-verify-status").html("");
}); });
$( ".pms-auth" ).change(function() { function OAuthPreFunction() {
authenticated = false; $("#pms_token").val('');
$("#pms_token").val(""); $("#pms-token-status").html('<i class="fa fa-refresh fa-spin"></i>&nbsp; Waiting for authentication...').fadeIn('fast');
$("#pms-token-status").html(""); }
}); function OAuthSuccessCallback(authToken) {
// Plex.tv auth token fetch
$("#pms-authenticate").click(function() {
$("#pms-token-status").html('<i class="fa fa-refresh fa-spin"></i> Fetching token...');
$('#pms-token-status').fadeIn('fast');
var pms_username = $("#pms_username").val().trim();
var pms_password = $("#pms_password").val().trim();
if ((pms_username !== '') && (pms_password !== '')) {
$.ajax({
type: 'GET',
url: 'get_plexpy_pms_token',
data: {
username: pms_username,
password: pms_password
},
cache: false,
async: true,
complete: function (xhr, status) {
var result = $.parseJSON(xhr.responseText);
var msg = result.message;
if (result.result == 'success') {
var authToken = result.token;
$("#pms-token-status").html('<i class="fa fa-check"></i> ' + msg);
$('#pms-token-status').fadeIn('fast');
$("#pms_token").val(authToken); $("#pms_token").val(authToken);
$("#pms-token-status").html('<i class="fa fa-check"></i>&nbsp; Authentication successful.').fadeIn('fast');
authenticated = true; authenticated = true;
getServerOptions(authToken) getServerOptions(authToken);
} else {
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i> ' + msg);
} }
function OAuthErrorCallback() {
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i>&nbsp; Error communicating with Plex.tv.').fadeIn('fast');
} }
});
} else { $('#sign-in-plex').click(function() {
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i> Username and password required.'); PlexOAuth(OAuthSuccessCallback, OAuthErrorCallback, OAuthPreFunction);
$('#pms-token-status').fadeIn('fast');
}
}); });
}); });
</script> </script>

View File

@@ -759,7 +759,8 @@
% if i < min(show['season_count'], 7): % if i < min(show['season_count'], 7):
<br> <br>
% elif i == 7 and show['season_count'] > 8: % elif i == 7 and show['season_count'] > 8:
...plus ${show['season_count'] - 8} more seasons! <% remaining_seasons = show['season_count'] - 8 %>
...plus ${remaining_seasons} more season${'s' if remaining_seasons > 1 else ''}!
% endif % endif
% endfor % endfor
</p> </p>

View File

@@ -760,7 +760,8 @@
% if i < min(show['season_count'], 7): % if i < min(show['season_count'], 7):
<br> <br>
% elif i == 7 and show['season_count'] > 8: % elif i == 7 and show['season_count'] > 8:
...plus ${show['season_count'] - 8} more seasons! <% remaining_seasons = show['season_count'] - 8 %>
...plus ${remaining_seasons} more season${'s' if remaining_seasons > 1 else ''}!
% endif % endif
% endfor % endfor
</p> </p>

View File

@@ -1,127 +0,0 @@
# Copyright (c) 2009 Raymond Hettinger
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
from UserDict import DictMixin
class OrderedDict(dict, DictMixin):
def __init__(self, *args, **kwds):
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
self.__end
except AttributeError:
self.clear()
self.update(*args, **kwds)
def clear(self):
self.__end = end = []
end += [None, end, end] # sentinel node for doubly linked list
self.__map = {} # key --> [key, prev, next]
dict.clear(self)
def __setitem__(self, key, value):
if key not in self:
end = self.__end
curr = end[1]
curr[2] = end[1] = self.__map[key] = [key, curr, end]
dict.__setitem__(self, key, value)
def __delitem__(self, key):
dict.__delitem__(self, key)
key, prev, next = self.__map.pop(key)
prev[2] = next
next[1] = prev
def __iter__(self):
end = self.__end
curr = end[2]
while curr is not end:
yield curr[0]
curr = curr[2]
def __reversed__(self):
end = self.__end
curr = end[1]
while curr is not end:
yield curr[0]
curr = curr[1]
def popitem(self, last=True):
if not self:
raise KeyError('dictionary is empty')
if last:
key = reversed(self).next()
else:
key = iter(self).next()
value = self.pop(key)
return key, value
def __reduce__(self):
items = [[k, self[k]] for k in self]
tmp = self.__map, self.__end
del self.__map, self.__end
inst_dict = vars(self).copy()
self.__map, self.__end = tmp
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
def keys(self):
return list(self)
setdefault = DictMixin.setdefault
update = DictMixin.update
pop = DictMixin.pop
values = DictMixin.values
items = DictMixin.items
iterkeys = DictMixin.iterkeys
itervalues = DictMixin.itervalues
iteritems = DictMixin.iteritems
def __repr__(self):
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
def copy(self):
return self.__class__(self)
@classmethod
def fromkeys(cls, iterable, value=None):
d = cls()
for key in iterable:
d[key] = value
return d
def __eq__(self, other):
if isinstance(other, OrderedDict):
if len(self) != len(other):
return False
for p, q in zip(self.items(), other.items()):
if p != q:
return False
return True
return dict.__eq__(self, other)
def __ne__(self, other):
return not self == other

File diff suppressed because it is too large Load Diff

View File

@@ -421,6 +421,8 @@ def initialize_scheduler():
schedule_job(activity_pinger.connect_server, 'Check for server response', schedule_job(activity_pinger.connect_server, 'Check for server response',
hours=0, minutes=0, seconds=0) hours=0, minutes=0, seconds=0)
schedule_job(web_socket.send_ping, 'Websocket ping',
hours=0, minutes=0, seconds=10 * bool(CONFIG.WEBSOCKET_MONITOR_PING_PONG))
else: else:
# Cancel all jobs # Cancel all jobs
@@ -440,6 +442,8 @@ def initialize_scheduler():
# Schedule job to reconnect server # Schedule job to reconnect server
schedule_job(activity_pinger.connect_server, 'Check for server response', schedule_job(activity_pinger.connect_server, 'Check for server response',
hours=0, minutes=0, seconds=60, args=(False,)) hours=0, minutes=0, seconds=60, args=(False,))
schedule_job(web_socket.send_ping, 'Websocket ping',
hours=0, minutes=0, seconds=0)
# Start scheduler # Start scheduler
if start_jobs and len(SCHED.get_jobs()): if start_jobs and len(SCHED.get_jobs()):
@@ -1863,7 +1867,7 @@ def generate_uuid():
def initialize_tracker(): def initialize_tracker():
data = { data = {
'dataSource': 'server', 'dataSource': 'server',
'appName': 'Tautulli', 'appName': common.PRODUCT,
'appVersion': common.RELEASE, 'appVersion': common.RELEASE,
'appId': plexpy.INSTALL_TYPE, 'appId': plexpy.INSTALL_TYPE,
'appInstallerId': plexpy.CONFIG.GIT_BRANCH, 'appInstallerId': plexpy.CONFIG.GIT_BRANCH,

View File

@@ -32,6 +32,7 @@ import xmltodict
import plexpy import plexpy
import config import config
import database import database
import helpers
import libraries import libraries
import logger import logger
import mobile_app import mobile_app
@@ -173,10 +174,11 @@ class API2:
end = int(end) end = int(end)
if regex: if regex:
logger.api_debug(u'Tautulli APIv2 :: Filtering log using regex %s' % regex) logger.api_debug(u"Tautulli APIv2 :: Filtering log using regex '%s'" % regex)
reg = re.compile('u' + regex, flags=re.I) reg = re.compile(regex, flags=re.I)
for line in open(logfile, 'r').readlines(): with open(logfile, 'r') as f:
for line in f.readlines():
temp_loglevel_and_time = None temp_loglevel_and_time = None
try: try:
@@ -191,7 +193,7 @@ class API2:
except IndexError: except IndexError:
# We assume this is a traceback # We assume this is a traceback
tl = (len(templog) - 1) tl = (len(templog) - 1)
templog[tl]['msg'] += line.replace('\n', '') templog[tl]['msg'] += helpers.sanitize(unicode(line.replace('\n', ''), 'utf-8'))
continue continue
if len(line) > 1 and temp_loglevel_and_time is not None and loglvl in line: if len(line) > 1 and temp_loglevel_and_time is not None and loglvl in line:
@@ -199,21 +201,24 @@ class API2:
d = { d = {
'time': temp_loglevel_and_time[0], 'time': temp_loglevel_and_time[0],
'loglevel': loglvl, 'loglevel': loglvl,
'msg': msg.replace('\n', ''), 'msg': helpers.sanitize(unicode(msg.replace('\n', ''), 'utf-8')),
'thread': thread 'thread': thread
} }
templog.append(d) templog.append(d)
if order == 'desc':
templog = templog[::-1]
if end > 0 or start > 0: if end > 0 or start > 0:
logger.api_debug(u'Tautulli APIv2 :: Slicing the log from %s to %s' % (start, end)) logger.api_debug(u"Tautulli APIv2 :: Slicing the log from %s to %s" % (start, end))
templog = templog[start:end] templog = templog[start:end]
if sort: if sort:
logger.api_debug(u'Tautulli APIv2 :: Sorting log based on %s' % sort) logger.api_debug(u"Tautulli APIv2 :: Sorting log based on '%s'" % sort)
templog = sorted(templog, key=lambda k: k[sort]) templog = sorted(templog, key=lambda k: k[sort])
if search: if search:
logger.api_debug(u'Tautulli APIv2 :: Searching log values for %s' % search) logger.api_debug(u"Tautulli APIv2 :: Searching log values for '%s'" % search)
tt = [d for d in templog for k, v in d.items() if search.lower() in v.lower()] tt = [d for d in templog for k, v in d.items() if search.lower() in v.lower()]
if len(tt): if len(tt):
@@ -222,16 +227,13 @@ class API2:
if regex: if regex:
tt = [] tt = []
for l in templog: for l in templog:
stringdict = ' '.join('{}{}'.format(k, v) for k, v in l.items()) stringdict = ' '.join(u'{}{}'.format(k, v) for k, v in l.items())
if reg.search(stringdict): if reg.search(stringdict):
tt.append(l) tt.append(l)
if len(tt): if len(tt):
templog = tt templog = tt
if order == 'desc':
templog = templog[::-1]
return templog return templog
def get_settings(self, key=''): def get_settings(self, key=''):

View File

@@ -19,6 +19,7 @@ from collections import OrderedDict
import version import version
# Identify Our Application # Identify Our Application
PRODUCT = 'Tautulli'
PLATFORM = platform.system() PLATFORM = platform.system()
PLATFORM_RELEASE = platform.release() PLATFORM_RELEASE = platform.release()
PLATFORM_VERSION = platform.version() PLATFORM_VERSION = platform.version()
@@ -27,7 +28,7 @@ PLATFORM_DEVICE_NAME = platform.node()
BRANCH = version.PLEXPY_BRANCH BRANCH = version.PLEXPY_BRANCH
RELEASE = version.PLEXPY_RELEASE_VERSION RELEASE = version.PLEXPY_RELEASE_VERSION
USER_AGENT = 'Tautulli/{} ({} {})'.format(RELEASE, PLATFORM, PLATFORM_RELEASE) USER_AGENT = '{}/{} ({} {})'.format(PRODUCT, RELEASE, PLATFORM, PLATFORM_RELEASE)
DEFAULT_USER_THUMB = "interfaces/default/images/gravatar-default-80x80.png" DEFAULT_USER_THUMB = "interfaces/default/images/gravatar-default-80x80.png"
DEFAULT_POSTER_THUMB = "interfaces/default/images/poster.png" DEFAULT_POSTER_THUMB = "interfaces/default/images/poster.png"
@@ -440,7 +441,8 @@ NOTIFICATION_PARAMETERS = [
{'name': 'Summary', 'type': 'str', 'value': 'summary', 'description': 'A short plot summary for the item.'}, {'name': 'Summary', 'type': 'str', 'value': 'summary', 'description': 'A short plot summary for the item.'},
{'name': 'Tagline', 'type': 'str', 'value': 'tagline', 'description': 'A tagline for the media item.'}, {'name': 'Tagline', 'type': 'str', 'value': 'tagline', 'description': 'A tagline for the media item.'},
{'name': 'Rating', 'type': 'float', 'value': 'rating', 'description': 'The rating (out of 10) for the item.'}, {'name': 'Rating', 'type': 'float', 'value': 'rating', 'description': 'The rating (out of 10) for the item.'},
{'name': 'Audience Rating', 'type': 'float', 'value': 'audience_rating', 'description': 'The audience rating (%) for the item.', 'help_text': 'Ratings source must be Rotten Tomatoes for the Plex Movie agent'}, {'name': 'Critic Rating', 'type': 'int', 'value': 'critic_rating', 'description': 'The critic rating (%) for the item.', 'help_text': 'Ratings source must be Rotten Tomatoes for the Plex Movie agent'},
{'name': 'Audience Rating', 'type': 'int', 'value': 'audience_rating', 'description': 'The audience rating (%) for the item.', 'help_text': 'Ratings source must be Rotten Tomatoes for the Plex Movie agent'},
{'name': 'Duration', 'type': 'int', 'value': 'duration', 'description': 'The duration (in minutes) for the item.'}, {'name': 'Duration', 'type': 'int', 'value': 'duration', 'description': 'The duration (in minutes) for the item.'},
{'name': 'Poster URL', 'type': 'str', 'value': 'poster_url', 'description': 'A URL for the movie, TV show, or album poster.'}, {'name': 'Poster URL', 'type': 'str', 'value': 'poster_url', 'description': 'A URL for the movie, TV show, or album poster.'},
{'name': 'Plex URL', 'type': 'str', 'value': 'plex_url', 'description': 'The Plex URL to your server for the item.'}, {'name': 'Plex URL', 'type': 'str', 'value': 'plex_url', 'description': 'The Plex URL to your server for the item.'},

View File

@@ -607,6 +607,7 @@ _CONFIG_DEFINITIONS = {
'UPDATE_NOTIFIERS_DB': (int, 'General', 1), 'UPDATE_NOTIFIERS_DB': (int, 'General', 1),
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1), 'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1), 'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1),
'WEBSOCKET_MONITOR_PING_PONG': (int, 'Advanced', 0),
'WEBSOCKET_CONNECTION_ATTEMPTS': (int, 'Advanced', 5), 'WEBSOCKET_CONNECTION_ATTEMPTS': (int, 'Advanced', 5),
'WEBSOCKET_CONNECTION_TIMEOUT': (int, 'Advanced', 5), 'WEBSOCKET_CONNECTION_TIMEOUT': (int, 'Advanced', 5),
'WEEK_START_MONDAY': (int, 'General', 0), 'WEEK_START_MONDAY': (int, 'General', 0),
@@ -802,6 +803,7 @@ class Config(object):
if self.VIDEO_LOGGING_ENABLE == 0: if self.VIDEO_LOGGING_ENABLE == 0:
self.MOVIE_LOGGING_ENABLE = 0 self.MOVIE_LOGGING_ENABLE = 0
self.TV_LOGGING_ENABLE = 0 self.TV_LOGGING_ENABLE = 0
self.CONFIG_VERSION = 1 self.CONFIG_VERSION = 1
if self.CONFIG_VERSION == 1: if self.CONFIG_VERSION == 1:
@@ -817,11 +819,12 @@ class Config(object):
if 'library_statistics' in home_library_cards: if 'library_statistics' in home_library_cards:
home_library_cards.remove('library_statistics') home_library_cards.remove('library_statistics')
self.HOME_LIBRARY_CARDS = home_library_cards self.HOME_LIBRARY_CARDS = home_library_cards
self.CONFIG_VERSION = 2 self.CONFIG_VERSION = 2
if self.CONFIG_VERSION == 2: if self.CONFIG_VERSION == 2:
def rep(s): def rep(s):
return s.replace('{progress}','{progress_duration}') return s.replace('{progress}', '{progress_duration}')
self.NOTIFY_ON_START_SUBJECT_TEXT = rep(self.NOTIFY_ON_START_SUBJECT_TEXT) self.NOTIFY_ON_START_SUBJECT_TEXT = rep(self.NOTIFY_ON_START_SUBJECT_TEXT)
self.NOTIFY_ON_START_BODY_TEXT = rep(self.NOTIFY_ON_START_BODY_TEXT) self.NOTIFY_ON_START_BODY_TEXT = rep(self.NOTIFY_ON_START_BODY_TEXT)
@@ -836,10 +839,13 @@ class Config(object):
self.NOTIFY_ON_WATCHED_SUBJECT_TEXT = rep(self.NOTIFY_ON_WATCHED_SUBJECT_TEXT) self.NOTIFY_ON_WATCHED_SUBJECT_TEXT = rep(self.NOTIFY_ON_WATCHED_SUBJECT_TEXT)
self.NOTIFY_ON_WATCHED_BODY_TEXT = rep(self.NOTIFY_ON_WATCHED_BODY_TEXT) self.NOTIFY_ON_WATCHED_BODY_TEXT = rep(self.NOTIFY_ON_WATCHED_BODY_TEXT)
self.NOTIFY_SCRIPTS_ARGS_TEXT = rep(self.NOTIFY_SCRIPTS_ARGS_TEXT) self.NOTIFY_SCRIPTS_ARGS_TEXT = rep(self.NOTIFY_SCRIPTS_ARGS_TEXT)
self.CONFIG_VERSION = 3 self.CONFIG_VERSION = 3
if self.CONFIG_VERSION == 3: if self.CONFIG_VERSION == 3:
if self.HTTP_ROOT == '/': self.HTTP_ROOT = '' if self.HTTP_ROOT == '/':
self.HTTP_ROOT = ''
self.CONFIG_VERSION = 4 self.CONFIG_VERSION = 4
if self.CONFIG_VERSION == 4: if self.CONFIG_VERSION == 4:
@@ -851,20 +857,26 @@ class Config(object):
home_sections = self.HOME_SECTIONS home_sections = self.HOME_SECTIONS
home_sections.remove('library_stats') home_sections.remove('library_stats')
self.HOME_SECTIONS = home_sections self.HOME_SECTIONS = home_sections
self.CONFIG_VERSION = 5 self.CONFIG_VERSION = 5
if self.CONFIG_VERSION == 5: if self.CONFIG_VERSION == 5:
self.MONITOR_PMS_UPDATES = 0 self.MONITOR_PMS_UPDATES = 0
self.CONFIG_VERSION = 6 self.CONFIG_VERSION = 6
if self.CONFIG_VERSION == 6: if self.CONFIG_VERSION == 6:
if self.GIT_USER.lower() == 'drzoidberg33': if self.GIT_USER.lower() == 'drzoidberg33':
self.GIT_USER = 'JonnyWong16' self.GIT_USER = 'JonnyWong16'
self.CONFIG_VERSION = 7 self.CONFIG_VERSION = 7
if self.CONFIG_VERSION == 7: if self.CONFIG_VERSION == 7:
def rep(s): def rep(s):
return s.replace('<tv>','<episode>').replace('</tv>','</episode>').replace('<music>','<track>').replace('</music>','</track>') return s.replace('<tv>', '<episode>') \
.replace('</tv>', '</episode>') \
.replace('<music>', '<track>') \
.replace('</music>', '</track>')
self.NOTIFY_ON_START_SUBJECT_TEXT = rep(self.NOTIFY_ON_START_SUBJECT_TEXT) self.NOTIFY_ON_START_SUBJECT_TEXT = rep(self.NOTIFY_ON_START_SUBJECT_TEXT)
self.NOTIFY_ON_START_BODY_TEXT = rep(self.NOTIFY_ON_START_BODY_TEXT) self.NOTIFY_ON_START_BODY_TEXT = rep(self.NOTIFY_ON_START_BODY_TEXT)
@@ -904,3 +916,7 @@ class Config(object):
self.GIT_REPO = 'Tautulli' self.GIT_REPO = 'Tautulli'
self.CONFIG_VERSION = 11 self.CONFIG_VERSION = 11
if self.CONFIG_VERSION == 11:
self.ANON_REDIRECT = self.ANON_REDIRECT.replace('http://www.nullrefer.com/?',
'https://www.nullrefer.com/?')

View File

@@ -466,7 +466,7 @@ def get_percent(value1, value2):
else: else:
percent = 0 percent = 0
return math.trunc(percent) return math.trunc(round(percent, 0))
def hex_to_int(hex): def hex_to_int(hex):

View File

@@ -33,18 +33,24 @@ class HTTPHandler(object):
Retrieve data from Plex Server Retrieve data from Plex Server
""" """
def __init__(self, urls, token=None, timeout=10, ssl_verify=True): def __init__(self, urls, headers=None, token=None, timeout=10, ssl_verify=True, silent=False):
self._silent = silent
if isinstance(urls, basestring): if isinstance(urls, basestring):
self.urls = urls.split() or urls.split(',') self.urls = urls.split() or urls.split(',')
else: else:
self.urls = urls self.urls = urls
self.headers = {'X-Plex-Product': 'Tautulli', if headers:
self.headers = headers
else:
self.headers = {'X-Plex-Product': plexpy.common.PRODUCT,
'X-Plex-Version': plexpy.common.RELEASE, 'X-Plex-Version': plexpy.common.RELEASE,
'X-Plex-Client-Identifier': plexpy.CONFIG.PMS_UUID, 'X-Plex-Client-Identifier': plexpy.CONFIG.PMS_UUID,
'X-Plex-Platform': plexpy.common.PLATFORM, 'X-Plex-Platform': plexpy.common.PLATFORM,
'X-Plex-Platform-Version': plexpy.common.PLATFORM_RELEASE, 'X-Plex-Platform-Version': plexpy.common.PLATFORM_RELEASE,
'X-Plex-Device': 'Web', 'X-Plex-Device': '{} {}'.format(plexpy.common.PLATFORM,
plexpy.common.PLATFORM_RELEASE),
'X-Plex-Device-Name': plexpy.common.PLATFORM_DEVICE_NAME 'X-Plex-Device-Name': plexpy.common.PLATFORM_DEVICE_NAME
} }
@@ -127,6 +133,7 @@ class HTTPHandler(object):
for work in pool.imap_unordered(part, urls, chunk): for work in pool.imap_unordered(part, urls, chunk):
yield work yield work
except Exception as e: except Exception as e:
if not self._silent:
logger.error(u"Failed to yield request: %s" % e) logger.error(u"Failed to yield request: %s" % e)
finally: finally:
pool.close() pool.close()
@@ -137,12 +144,15 @@ class HTTPHandler(object):
try: try:
r = session.request(self.request_type, url, headers=self.headers, timeout=self.timeout) r = session.request(self.request_type, url, headers=self.headers, timeout=self.timeout)
except IOError as e: except IOError as e:
if not self._silent:
logger.warn(u"Failed to access uri endpoint %s with error %s" % (self.uri, e)) logger.warn(u"Failed to access uri endpoint %s with error %s" % (self.uri, e))
return None return None
except Exception as e: except Exception as e:
if not self._silent:
logger.warn(u"Failed to access uri endpoint %s. Is your server maybe accepting SSL connections only? %s" % (self.uri, e)) logger.warn(u"Failed to access uri endpoint %s. Is your server maybe accepting SSL connections only? %s" % (self.uri, e))
return None return None
except: except:
if not self._silent:
logger.warn(u"Failed to access uri endpoint %s with Uncaught exception." % self.uri) logger.warn(u"Failed to access uri endpoint %s with Uncaught exception." % self.uri)
return None return None
@@ -153,6 +163,7 @@ class HTTPHandler(object):
if response_status in (200, 201): if response_status in (200, 201):
return self._http_format_output(response_content, response_headers) return self._http_format_output(response_content, response_headers)
else: else:
if not self._silent:
logger.warn(u"Failed to access uri endpoint %s. Status code %r" % (self.uri, response_status)) logger.warn(u"Failed to access uri endpoint %s. Status code %r" % (self.uri, response_status))
return None return None
@@ -179,5 +190,6 @@ class HTTPHandler(object):
return output return output
except Exception as e: except Exception as e:
if not self._silent:
logger.warn(u"Failed format response from uri %s to %s error %s" % (self.uri, self.output_format, e)) logger.warn(u"Failed format response from uri %s to %s error %s" % (self.uri, self.output_format, e))
return None return None

View File

@@ -633,7 +633,8 @@ class Libraries(object):
if 'media_info' in child_metadata and len(child_metadata['media_info']) > 0: if 'media_info' in child_metadata and len(child_metadata['media_info']) > 0:
media_info = child_metadata['media_info'][0] media_info = child_metadata['media_info'][0]
if 'parts' in media_info and len (media_info['parts']) > 0: if 'parts' in media_info and len (media_info['parts']) > 0:
media_part_info = media_info['parts'][0] media_part_info = next((p for p in media_info['parts'] if p['selected']),
media_info['parts'][0])
file_size += helpers.cast_to_int(media_part_info.get('file_size', 0)) file_size += helpers.cast_to_int(media_part_info.get('file_size', 0))

View File

@@ -486,20 +486,24 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
if 'media_info' in notify_params and len(notify_params['media_info']) > 0: if 'media_info' in notify_params and len(notify_params['media_info']) > 0:
media_info = notify_params['media_info'][0] media_info = notify_params['media_info'][0]
if 'parts' in media_info and len(media_info['parts']) > 0: if 'parts' in media_info and len(media_info['parts']) > 0:
media_part_info = media_info.pop('parts')[0] parts = media_info.pop('parts')
media_part_info = next((p for p in parts if p['selected']), parts[0])
stream_video = stream_audio = stream_subtitle = False
if 'streams' in media_part_info: if 'streams' in media_part_info:
for stream in media_part_info.pop('streams'): streams = media_part_info.pop('streams')
if not stream_video and stream['type'] == '1': video_streams = [s for s in streams if s['type'] == '1']
media_part_info.update(stream) audio_streams = [s for s in streams if s['type'] == '2']
stream_video = True subtitle_streams = [s for s in streams if s['type'] == '3']
if not stream_audio and stream['type'] == '2':
media_part_info.update(stream) if video_streams:
stream_audio = True video_stream = next((s for s in video_streams if s['selected']), video_streams[0])
if not stream_subtitle and stream['type'] == '3': media_part_info.update(video_stream)
media_part_info.update(stream) if audio_streams:
stream_subtitle = True audio_stream = next((s for s in audio_streams if s['selected']), audio_streams[0])
media_part_info.update(audio_stream)
if subtitle_streams:
subtitle_stream = next((s for s in subtitle_streams if s['selected']), subtitle_streams[0])
media_part_info.update(subtitle_stream)
notify_params.update(media_info) notify_params.update(media_info)
notify_params.update(media_part_info) notify_params.update(media_part_info)
@@ -527,7 +531,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
else: else:
transcode_decision = 'Direct Play' transcode_decision = 'Direct Play'
if notify_action != 'play': if notify_action != 'on_play':
stream_duration = int((time.time() - stream_duration = int((time.time() -
helpers.cast_to_int(session.get('started', 0)) - helpers.cast_to_int(session.get('started', 0)) -
helpers.cast_to_int(session.get('paused_counter', 0))) / 60) helpers.cast_to_int(session.get('paused_counter', 0))) / 60)
@@ -708,6 +712,14 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
child_count = 1 child_count = 1
grandchild_count = 1 grandchild_count = 1
critic_rating = ''
if notify_params['rating_image'].startswith('rottentomatoes://') and notify_params['rating']:
critic_rating = helpers.get_percent(notify_params['rating'], 10)
audience_rating = ''
if notify_params['audience_rating']:
audience_rating = helpers.get_percent(notify_params['audience_rating'], 10)
now = arrow.now() now = arrow.now()
now_iso = now.isocalendar() now_iso = now.isocalendar()
@@ -856,7 +868,8 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
'summary': notify_params['summary'], 'summary': notify_params['summary'],
'tagline': notify_params['tagline'], 'tagline': notify_params['tagline'],
'rating': notify_params['rating'], 'rating': notify_params['rating'],
'audience_rating': helpers.get_percent(notify_params['audience_rating'], 10) or '', 'critic_rating': critic_rating,
'audience_rating': audience_rating,
'duration': duration, 'duration': duration,
'poster_title': notify_params['poster_title'], 'poster_title': notify_params['poster_title'],
'poster_url': notify_params['poster_url'], 'poster_url': notify_params['poster_url'],
@@ -1422,6 +1435,10 @@ def get_themoviedb_info(rating_key=None, media_type=None, themoviedb_id=None):
class CustomFormatter(Formatter): class CustomFormatter(Formatter):
def __init__(self, default='{{{0}}}', default_format_spec='{{{0}:{1}}}'):
self.default = default
self.default_format_spec = default_format_spec
def convert_field(self, value, conversion): def convert_field(self, value, conversion):
if conversion is None: if conversion is None:
return value return value
@@ -1450,4 +1467,13 @@ class CustomFormatter(Formatter):
else: else:
return value return value
else: else:
try:
return super(CustomFormatter, self).format_field(value, format_spec) return super(CustomFormatter, self).format_field(value, format_spec)
except ValueError:
return self.default_format_spec.format(value[1:-1], format_spec)
def get_value(self, key, args, kwargs):
if isinstance(key, basestring):
return kwargs.get(key, self.default.format(key))
else:
return super(CustomFormatter, self).get_value(key, args, kwargs)

View File

@@ -3000,7 +3000,7 @@ class SCRIPTS(Notifier):
'TAUTULLI_URL': helpers.get_plexpy_url(hostname='localhost'), 'TAUTULLI_URL': helpers.get_plexpy_url(hostname='localhost'),
'TAUTULLI_APIKEY': plexpy.CONFIG.API_KEY, 'TAUTULLI_APIKEY': plexpy.CONFIG.API_KEY,
'TAUTULLI_ENCODING': plexpy.SYS_ENCODING, 'TAUTULLI_ENCODING': plexpy.SYS_ENCODING,
'PYTHONPATH': (';' if os.name == 'nt' else ':').join(sys.path) 'PYTHONPATH': os.pathsep.join([p for p in sys.path if p])
}) })
try: try:

View File

@@ -121,7 +121,7 @@ class PlexTV(object):
Plex.tv authentication Plex.tv authentication
""" """
def __init__(self, username=None, password=None, token=None): def __init__(self, username=None, password=None, token=None, headers=None):
self.username = username self.username = username
self.password = password self.password = password
self.token = token self.token = token
@@ -147,7 +147,8 @@ class PlexTV(object):
self.request_handler = http_handler.HTTPHandler(urls=self.urls, self.request_handler = http_handler.HTTPHandler(urls=self.urls,
token=self.token, token=self.token,
timeout=self.timeout, timeout=self.timeout,
ssl_verify=self.ssl_verify) ssl_verify=self.ssl_verify,
headers=headers)
def get_plex_auth(self, output_format='raw'): def get_plex_auth(self, output_format='raw'):
uri = '/users/sign_in.xml' uri = '/users/sign_in.xml'
@@ -226,6 +227,45 @@ class PlexTV(object):
return server_token return server_token
def get_plextv_pin(self, pin='', output_format=''):
if pin:
uri = '/api/v2/pins/' + pin
request = self.request_handler.make_request(uri=uri,
request_type='GET',
output_format=output_format,
no_token=True)
else:
uri = '/api/v2/pins?strong=true'
request = self.request_handler.make_request(uri=uri,
request_type='POST',
output_format=output_format,
no_token=True)
return request
def get_pin(self, pin=''):
plextv_response = self.get_plextv_pin(pin=pin,
output_format='xml')
if plextv_response:
try:
xml_head = plextv_response.getElementsByTagName('pin')
if xml_head:
pin = {'id': xml_head[0].getAttribute('id'),
'code': xml_head[0].getAttribute('code'),
'token': xml_head[0].getAttribute('authToken')
}
return pin
else:
logger.warn(u"Tautulli PlexTV :: Could not get Plex authentication pin.")
return None
except Exception as e:
logger.warn(u"Tautulli PlexTV :: Unable to parse XML for get_pin: %s." % e)
return None
else:
return None
def get_plextv_user_data(self): def get_plextv_user_data(self):
plextv_response = self.get_plex_auth(output_format='dict') plextv_response = self.get_plex_auth(output_format='dict')
@@ -645,6 +685,27 @@ class PlexTV(object):
def discover(self, include_cloud=True, all_servers=False): def discover(self, include_cloud=True, all_servers=False):
""" Query plex for all servers online. Returns the ones you own in a selectize format """ """ Query plex for all servers online. Returns the ones you own in a selectize format """
# Try to discover localhost server
local_machine_identifier = None
request_handler = http_handler.HTTPHandler(urls='http://127.0.0.1:32400', timeout=1,
ssl_verify=False, silent=True)
request = request_handler.make_request(uri='/identity', request_type='GET', output_format='xml')
if request:
xml_head = request.getElementsByTagName('MediaContainer')[0]
local_machine_identifier = xml_head.getAttribute('machineIdentifier')
local_server = {'httpsRequired': '0',
'clientIdentifier': local_machine_identifier,
'label': 'Local',
'ip': '127.0.0.1',
'port': '32400',
'uri': 'http://127.0.0.1:32400',
'local': '1',
'value': '127.0.0.1:32400',
'is_cloud': False
}
servers = self.get_plextv_resources(include_https=True, output_format='xml') servers = self.get_plextv_resources(include_https=True, output_format='xml')
clean_servers = [] clean_servers = []
@@ -685,6 +746,12 @@ class PlexTV(object):
helpers.get_xml_attr(c, 'local') == '0': helpers.get_xml_attr(c, 'local') == '0':
continue continue
if helpers.get_xml_attr(d, 'clientIdentifier') == local_machine_identifier:
local_server['httpsRequired'] = helpers.get_xml_attr(d, 'httpsRequired')
local_server['label'] = helpers.get_xml_attr(d, 'name')
clean_servers.append(local_server)
local_machine_identifier = None
server = {'httpsRequired': '1' if is_cloud else helpers.get_xml_attr(d, 'httpsRequired'), server = {'httpsRequired': '1' if is_cloud else helpers.get_xml_attr(d, 'httpsRequired'),
'clientIdentifier': helpers.get_xml_attr(d, 'clientIdentifier'), 'clientIdentifier': helpers.get_xml_attr(d, 'clientIdentifier'),
'label': helpers.get_xml_attr(d, 'name'), 'label': helpers.get_xml_attr(d, 'name'),
@@ -692,11 +759,16 @@ class PlexTV(object):
'port': helpers.get_xml_attr(c, 'port'), 'port': helpers.get_xml_attr(c, 'port'),
'uri': helpers.get_xml_attr(c, 'uri'), 'uri': helpers.get_xml_attr(c, 'uri'),
'local': helpers.get_xml_attr(c, 'local'), 'local': helpers.get_xml_attr(c, 'local'),
'value': helpers.get_xml_attr(c, 'address'), 'value': helpers.get_xml_attr(c, 'address') + ':' + helpers.get_xml_attr(c, 'port'),
'is_cloud': is_cloud 'is_cloud': is_cloud
} }
clean_servers.append(server) clean_servers.append(server)
if local_machine_identifier:
clean_servers.append(local_server)
clean_servers.sort(key=lambda s: (s['label'], -int(s['local']), s['ip']))
return clean_servers return clean_servers
def get_plex_downloads(self): def get_plex_downloads(self):
@@ -819,3 +891,28 @@ class PlexTV(object):
return True return True
else: else:
return False return False
def get_plex_account_details(self):
account_data = self.get_plextv_user_details(output_format='xml')
try:
xml_head = account_data.getElementsByTagName('user')
except Exception as e:
logger.warn(u"Tautulli PlexTV :: Unable to parse XML for get_plex_account_details: %s." % e)
return None
for a in xml_head:
account_details = {"user_id": helpers.get_xml_attr(a, 'id'),
"username": helpers.get_xml_attr(a, 'username'),
"thumb": helpers.get_xml_attr(a, 'thumb'),
"email": helpers.get_xml_attr(a, 'email'),
"is_home_user": helpers.get_xml_attr(a, 'home'),
"is_restricted": helpers.get_xml_attr(a, 'restricted'),
"filter_all": helpers.get_xml_attr(a, 'filterAll'),
"filter_movies": helpers.get_xml_attr(a, 'filterMovies'),
"filter_tv": helpers.get_xml_attr(a, 'filterTelevision'),
"filter_music": helpers.get_xml_attr(a, 'filterMusic'),
"filter_photos": helpers.get_xml_attr(a, 'filterPhotos'),
"user_token": helpers.get_xml_attr(a, 'authToken')
}
return account_details

View File

@@ -527,7 +527,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(m, 'summary'), 'summary': helpers.get_xml_attr(m, 'summary'),
'tagline': helpers.get_xml_attr(m, 'tagline'), 'tagline': helpers.get_xml_attr(m, 'tagline'),
'rating': helpers.get_xml_attr(m, 'rating'), 'rating': helpers.get_xml_attr(m, 'rating'),
'rating_image': helpers.get_xml_attr(m, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(m, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(m, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(m, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(m, 'userRating'), 'user_rating': helpers.get_xml_attr(m, 'userRating'),
'duration': helpers.get_xml_attr(m, 'duration'), 'duration': helpers.get_xml_attr(m, 'duration'),
'year': helpers.get_xml_attr(m, 'year'), 'year': helpers.get_xml_attr(m, 'year'),
@@ -680,7 +682,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -728,7 +732,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': duration, 'duration': duration,
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -773,7 +779,9 @@ class PmsConnect(object):
'summary': show_details['summary'], 'summary': show_details['summary'],
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': show_details['duration'], 'duration': show_details['duration'],
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -819,7 +827,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -863,7 +873,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -908,7 +920,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary') or artist_details['summary'], 'summary': helpers.get_xml_attr(metadata_main, 'summary') or artist_details['summary'],
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -956,7 +970,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': album_details['year'], 'year': album_details['year'],
@@ -1000,7 +1016,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -1045,7 +1063,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -1090,7 +1110,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -1136,7 +1158,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'),
'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'),
'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'),
'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'),
'duration': helpers.get_xml_attr(metadata_main, 'duration'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'),
'year': helpers.get_xml_attr(metadata_main, 'year'), 'year': helpers.get_xml_attr(metadata_main, 'year'),
@@ -1189,7 +1213,8 @@ class PmsConnect(object):
'video_width': helpers.get_xml_attr(stream, 'width'), 'video_width': helpers.get_xml_attr(stream, 'width'),
'video_language': helpers.get_xml_attr(stream, 'language'), 'video_language': helpers.get_xml_attr(stream, 'language'),
'video_language_code': helpers.get_xml_attr(stream, 'languageCode'), 'video_language_code': helpers.get_xml_attr(stream, 'languageCode'),
'video_profile': helpers.get_xml_attr(stream, 'profile') 'video_profile': helpers.get_xml_attr(stream, 'profile'),
'selected': int(helpers.get_xml_attr(stream, 'selected') == '1')
}) })
elif helpers.get_xml_attr(stream, 'streamType') == '2': elif helpers.get_xml_attr(stream, 'streamType') == '2':
@@ -1203,7 +1228,8 @@ class PmsConnect(object):
'audio_sample_rate': helpers.get_xml_attr(stream, 'samplingRate'), 'audio_sample_rate': helpers.get_xml_attr(stream, 'samplingRate'),
'audio_language': helpers.get_xml_attr(stream, 'language'), 'audio_language': helpers.get_xml_attr(stream, 'language'),
'audio_language_code': helpers.get_xml_attr(stream, 'languageCode'), 'audio_language_code': helpers.get_xml_attr(stream, 'languageCode'),
'audio_profile': helpers.get_xml_attr(stream, 'profile') 'audio_profile': helpers.get_xml_attr(stream, 'profile'),
'selected': int(helpers.get_xml_attr(stream, 'selected') == '1')
}) })
elif helpers.get_xml_attr(stream, 'streamType') == '3': elif helpers.get_xml_attr(stream, 'streamType') == '3':
@@ -1215,14 +1241,16 @@ class PmsConnect(object):
'subtitle_forced': int(helpers.get_xml_attr(stream, 'forced') == '1'), 'subtitle_forced': int(helpers.get_xml_attr(stream, 'forced') == '1'),
'subtitle_location': 'external' if helpers.get_xml_attr(stream, 'key') else 'embedded', 'subtitle_location': 'external' if helpers.get_xml_attr(stream, 'key') else 'embedded',
'subtitle_language': helpers.get_xml_attr(stream, 'language'), 'subtitle_language': helpers.get_xml_attr(stream, 'language'),
'subtitle_language_code': helpers.get_xml_attr(stream, 'languageCode') 'subtitle_language_code': helpers.get_xml_attr(stream, 'languageCode'),
'selected': int(helpers.get_xml_attr(stream, 'selected') == '1')
}) })
parts.append({'id': helpers.get_xml_attr(part, 'id'), parts.append({'id': helpers.get_xml_attr(part, 'id'),
'file': helpers.get_xml_attr(part, 'file'), 'file': helpers.get_xml_attr(part, 'file'),
'file_size': helpers.get_xml_attr(part, 'size'), 'file_size': helpers.get_xml_attr(part, 'size'),
'indexes': int(helpers.get_xml_attr(part, 'indexes') == 'sd'), 'indexes': int(helpers.get_xml_attr(part, 'indexes') == 'sd'),
'streams': streams 'streams': streams,
'selected': int(helpers.get_xml_attr(part, 'selected') == '1')
}) })
audio_channels = helpers.get_xml_attr(media, 'audioChannels') audio_channels = helpers.get_xml_attr(media, 'audioChannels')
@@ -1714,7 +1742,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(session, 'summary'), 'summary': helpers.get_xml_attr(session, 'summary'),
'tagline': helpers.get_xml_attr(session, 'tagline'), 'tagline': helpers.get_xml_attr(session, 'tagline'),
'rating': helpers.get_xml_attr(session, 'rating'), 'rating': helpers.get_xml_attr(session, 'rating'),
'rating_image': helpers.get_xml_attr(session, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(session, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(session, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(session, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(session, 'userRating'), 'user_rating': helpers.get_xml_attr(session, 'userRating'),
'duration': helpers.get_xml_attr(session, 'duration'), 'duration': helpers.get_xml_attr(session, 'duration'),
'year': helpers.get_xml_attr(session, 'year'), 'year': helpers.get_xml_attr(session, 'year'),
@@ -2037,7 +2067,9 @@ class PmsConnect(object):
'summary': helpers.get_xml_attr(m, 'summary'), 'summary': helpers.get_xml_attr(m, 'summary'),
'tagline': helpers.get_xml_attr(m, 'tagline'), 'tagline': helpers.get_xml_attr(m, 'tagline'),
'rating': helpers.get_xml_attr(m, 'rating'), 'rating': helpers.get_xml_attr(m, 'rating'),
'rating_image': helpers.get_xml_attr(m, 'ratingImage'),
'audience_rating': helpers.get_xml_attr(m, 'audienceRating'), 'audience_rating': helpers.get_xml_attr(m, 'audienceRating'),
'audience_rating_image': helpers.get_xml_attr(m, 'audienceRatingImage'),
'user_rating': helpers.get_xml_attr(m, 'userRating'), 'user_rating': helpers.get_xml_attr(m, 'userRating'),
'duration': helpers.get_xml_attr(m, 'duration'), 'duration': helpers.get_xml_attr(m, 'duration'),
'year': helpers.get_xml_attr(m, 'year'), 'year': helpers.get_xml_attr(m, 'year'),

View File

@@ -1,2 +1,2 @@
PLEXPY_BRANCH = "beta" PLEXPY_BRANCH = "master"
PLEXPY_RELEASE_VERSION = "v2.1.15-beta" PLEXPY_RELEASE_VERSION = "v2.1.18"

View File

@@ -31,6 +31,8 @@ import logger
name = 'websocket' name = 'websocket'
opcode_data = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY) opcode_data = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY)
ws_shutdown = False ws_shutdown = False
pong_timer = None
pong_count = 0
def start_thread(): def start_thread():
@@ -58,6 +60,8 @@ def on_connect():
plexpy.PLEX_SERVER_UP = True plexpy.PLEX_SERVER_UP = True
plexpy.initialize_scheduler() plexpy.initialize_scheduler()
if plexpy.CONFIG.WEBSOCKET_MONITOR_PING_PONG:
send_ping()
def on_disconnect(): def on_disconnect():
@@ -91,6 +95,37 @@ def close():
plexpy.WS_CONNECTED = False plexpy.WS_CONNECTED = False
def send_ping():
if plexpy.WS_CONNECTED:
# logger.debug(u"Tautulli WebSocket :: Sending ping.")
plexpy.WEBSOCKET.ping("Hi?")
global pong_timer
pong_timer = threading.Timer(5.0, wait_pong)
pong_timer.daemon = True
pong_timer.start()
def wait_pong():
global pong_count
pong_count += 1
logger.warning(u"Tautulli WebSocket :: Failed to receive pong from websocket, ping attempt %s." % str(pong_count))
if pong_count >= plexpy.CONFIG.WEBSOCKET_CONNECTION_ATTEMPTS:
pong_count = 0
close()
def receive_pong():
# logger.debug(u"Tautulli WebSocket :: Received pong.")
global pong_timer
global pong_count
if pong_timer:
pong_timer = pong_timer.cancel()
pong_count = 0
def run(): def run():
from websocket import create_connection from websocket import create_connection
@@ -115,18 +150,7 @@ def run():
reconnects = 0 reconnects = 0
# Try an open the websocket connection # Try an open the websocket connection
while not plexpy.WS_CONNECTED and reconnects < plexpy.CONFIG.WEBSOCKET_CONNECTION_ATTEMPTS:
if reconnects == 0:
logger.info(u"Tautulli WebSocket :: Opening %swebsocket." % secure) logger.info(u"Tautulli WebSocket :: Opening %swebsocket." % secure)
reconnects += 1
# Sleep 5 between connection attempts
if reconnects > 1:
time.sleep(plexpy.CONFIG.WEBSOCKET_CONNECTION_TIMEOUT)
logger.info(u"Tautulli WebSocket :: Connection attempt %s." % str(reconnects))
try: try:
plexpy.WEBSOCKET = create_connection(uri, header=header) plexpy.WEBSOCKET = create_connection(uri, header=header)
logger.info(u"Tautulli WebSocket :: Ready") logger.info(u"Tautulli WebSocket :: Ready")
@@ -196,7 +220,10 @@ def receive(ws):
ws.send_close() ws.send_close()
return frame.opcode, None return frame.opcode, None
elif frame.opcode == websocket.ABNF.OPCODE_PING: elif frame.opcode == websocket.ABNF.OPCODE_PING:
# logger.debug(u"Tautulli WebSocket :: Received ping, sending pong.")
ws.pong("Hi!") ws.pong("Hi!")
elif frame.opcode == websocket.ABNF.OPCODE_PONG:
receive_pong()
return None, None return None, None

View File

@@ -19,7 +19,6 @@
# Session tool to be loaded. # Session tool to be loaded.
from datetime import datetime, timedelta from datetime import datetime, timedelta
import re
from urllib import quote, unquote from urllib import quote, unquote
import cherrypy import cherrypy
@@ -37,17 +36,27 @@ JWT_ALGORITHM = 'HS256'
JWT_COOKIE_NAME = 'tautulli_token_' JWT_COOKIE_NAME = 'tautulli_token_'
def user_login(username=None, password=None): def plex_user_login(username=None, password=None, token=None, headers=None):
if not username or not password: user_token = None
return None user_id = None
# Try to login to Plex.tv to check if the user has a vaild account # Try to login to Plex.tv to check if the user has a vaild account
plex_tv = PlexTV(username=username, password=password) if username and password:
plex_tv = PlexTV(username=username, password=password, headers=headers)
plex_user = plex_tv.get_token() plex_user = plex_tv.get_token()
if plex_user: if plex_user:
user_token = plex_user['auth_token'] user_token = plex_user['auth_token']
user_id = plex_user['user_id'] user_id = plex_user['user_id']
elif token:
plex_tv = PlexTV(token=token, headers=headers)
plex_user = plex_tv.get_plex_account_details()
if plex_user:
user_token = token
user_id = plex_user['user_id']
else:
return None
if user_token and user_id:
# Try to retrieve the user from the database. # Try to retrieve the user from the database.
# Also make sure guest access is enabled for the user and the user is not deleted. # Also make sure guest access is enabled for the user and the user is not deleted.
user_data = Users() user_data = Users()
@@ -57,7 +66,7 @@ def user_login(username=None, password=None):
return None return None
elif plexpy.CONFIG.HTTP_PLEX_ADMIN and user_details['is_admin']: elif plexpy.CONFIG.HTTP_PLEX_ADMIN and user_details['is_admin']:
# Plex admin login # Plex admin login
return 'admin' return user_details, 'admin'
elif not user_details['allow_guest'] or user_details['deleted_user']: elif not user_details['allow_guest'] or user_details['deleted_user']:
# Guest access is disabled or the user is deleted. # Guest access is disabled or the user is deleted.
return None return None
@@ -68,56 +77,65 @@ def user_login(username=None, password=None):
# The user is in the database, and guest access is enabled, so try to retrieve a server token. # The user is in the database, and guest access is enabled, so try to retrieve a server token.
# If a server token is returned, then the user is a valid friend of the server. # If a server token is returned, then the user is a valid friend of the server.
plex_tv = PlexTV(token=user_token) plex_tv = PlexTV(token=user_token, headers=headers)
server_token = plex_tv.get_server_token() server_token = plex_tv.get_server_token()
if server_token: if server_token:
# Register the new user / update the access tokens. # Register the new user / update the access tokens.
monitor_db = MonitorDatabase() monitor_db = MonitorDatabase()
try: try:
logger.debug(u"Tautulli WebAuth :: Regestering tokens for user '%s' in the database." % username) logger.debug(u"Tautulli WebAuth :: Registering token for user '%s' in the database."
result = monitor_db.action('UPDATE users SET user_token = ?, server_token = ? WHERE user_id = ?', % user_details['username'])
[user_token, server_token, user_id]) result = monitor_db.action('UPDATE users SET server_token = ? WHERE user_id = ?',
[server_token, user_details['user_id']])
if result: if result:
# Refresh the users list to make sure we have all the correct permissions. # Refresh the users list to make sure we have all the correct permissions.
refresh_users() refresh_users()
# Successful login # Successful login
return 'guest' return user_details, 'guest'
else: else:
logger.warn(u"Tautulli WebAuth :: Unable to register user '%s' in database." % username) logger.warn(u"Tautulli WebAuth :: Unable to register user '%s' in database."
% user_details['username'])
return None return None
except Exception as e: except Exception as e:
logger.warn(u"Tautulli WebAuth :: Unable to register user '%s' in database: %s." % (username, e)) logger.warn(u"Tautulli WebAuth :: Unable to register user '%s' in database: %s."
% (user_details['username'], e))
return None return None
else: else:
logger.warn(u"Tautulli WebAuth :: Unable to retrieve Plex.tv server token for user '%s'." % username) logger.warn(u"Tautulli WebAuth :: Unable to retrieve Plex.tv server token for user '%s'."
% user_details['username'])
return None return None
else: elif username:
logger.warn(u"Tautulli WebAuth :: Unable to retrieve Plex.tv user token for user '%s'." % username) logger.warn(u"Tautulli WebAuth :: Unable to retrieve Plex.tv user token for user '%s'." % username)
return None return None
elif token:
logger.warn(u"Tautulli WebAuth :: Unable to retrieve Plex.tv user token for Plex OAuth.")
return None return None
def check_credentials(username, password, admin_login='0'): def check_credentials(username=None, password=None, token=None, admin_login='0', headers=None):
"""Verifies credentials for username and password. """Verifies credentials for username and password.
Returns True and the user group on success or False and no user group""" Returns True and the user group on success or False and no user group"""
if username and password:
if plexpy.CONFIG.HTTP_PASSWORD: if plexpy.CONFIG.HTTP_PASSWORD:
user_details = {'user_id': None, 'username': username}
if plexpy.CONFIG.HTTP_HASHED_PASSWORD and \ if plexpy.CONFIG.HTTP_HASHED_PASSWORD and \
username == plexpy.CONFIG.HTTP_USERNAME and check_hash(password, plexpy.CONFIG.HTTP_PASSWORD): username == plexpy.CONFIG.HTTP_USERNAME and check_hash(password, plexpy.CONFIG.HTTP_PASSWORD):
return True, 'tautulli admin' return True, user_details, 'admin'
elif not plexpy.CONFIG.HTTP_HASHED_PASSWORD and \ elif not plexpy.CONFIG.HTTP_HASHED_PASSWORD and \
username == plexpy.CONFIG.HTTP_USERNAME and password == plexpy.CONFIG.HTTP_PASSWORD: username == plexpy.CONFIG.HTTP_USERNAME and password == plexpy.CONFIG.HTTP_PASSWORD:
return True, 'tautulli admin' return True, user_details, 'admin'
if plexpy.CONFIG.HTTP_PLEX_ADMIN or (not admin_login == '1' and plexpy.CONFIG.ALLOW_GUEST_ACCESS): if plexpy.CONFIG.HTTP_PLEX_ADMIN or (not admin_login == '1' and plexpy.CONFIG.ALLOW_GUEST_ACCESS):
plex_login = user_login(username, password) plex_login = plex_user_login(username=username, password=password, token=token, headers=headers)
if plex_login is not None: if plex_login is not None:
return True, plex_login return True, plex_login[0], plex_login[1]
return False, None return False, None, None
def check_jwt_token(): def check_jwt_token():
@@ -220,7 +238,7 @@ class AuthController(object):
return return
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT) raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
def on_login(self, username, user_id=None, user_group=None, success=0): def on_login(self, username=None, user_id=None, user_group=None, success=False, oauth=False):
"""Called on successful login""" """Called on successful login"""
# Save login to the database # Save login to the database
@@ -236,8 +254,10 @@ class AuthController(object):
user_agent=user_agent, user_agent=user_agent,
success=success) success=success)
if success == 1: if success:
logger.debug(u"Tautulli WebAuth :: %s user '%s' logged into Tautulli." % (user_group.capitalize(), username)) use_oauth = 'Plex OAuth' if oauth else 'form'
logger.debug(u"Tautulli WebAuth :: %s user '%s' logged into Tautulli using %s login."
% (user_group.capitalize(), username, use_oauth))
def on_logout(self, username, user_group): def on_logout(self, username, user_group):
"""Called on logout""" """Called on logout"""
@@ -279,43 +299,37 @@ class AuthController(object):
@cherrypy.expose @cherrypy.expose
@cherrypy.tools.json_out() @cherrypy.tools.json_out()
def signin(self, username=None, password=None, remember_me='0', admin_login='0', *args, **kwargs): def signin(self, username=None, password=None, token=None, remember_me='0', admin_login='0', *args, **kwargs):
if cherrypy.request.method != 'POST': if cherrypy.request.method != 'POST':
cherrypy.response.status = 405 cherrypy.response.status = 405
return {'status': 'error', 'message': 'Sign in using POST.'} return {'status': 'error', 'message': 'Sign in using POST.'}
error_message = {'status': 'error', 'message': 'Incorrect username or password.'} error_message = {'status': 'error', 'message': 'Invalid credentials.'}
valid_login, user_group = check_credentials(username, password, admin_login) valid_login, user_details, user_group = check_credentials(username=username,
password=password,
token=token,
admin_login=admin_login,
headers=kwargs)
if valid_login: if valid_login:
if user_group == 'tautulli admin':
user_group = 'admin'
user_id = None
else:
if re.match(r"[^@]+@[^@]+\.[^@]+", username):
user_details = Users().get_details(email=username)
else:
user_details = Users().get_details(user=username)
user_id = user_details['user_id']
time_delta = timedelta(days=30) if remember_me == '1' else timedelta(minutes=60) time_delta = timedelta(days=30) if remember_me == '1' else timedelta(minutes=60)
expiry = datetime.utcnow() + time_delta expiry = datetime.utcnow() + time_delta
payload = { payload = {
'user_id': user_id, 'user_id': user_details['user_id'],
'user': username, 'user': user_details['username'],
'user_group': user_group, 'user_group': user_group,
'exp': expiry 'exp': expiry
} }
jwt_token = jwt.encode(payload, plexpy.CONFIG.JWT_SECRET, algorithm=JWT_ALGORITHM) jwt_token = jwt.encode(payload, plexpy.CONFIG.JWT_SECRET, algorithm=JWT_ALGORITHM)
self.on_login(username=username, self.on_login(username=user_details['username'],
user_id=user_id, user_id=user_details['user_id'],
user_group=user_group, user_group=user_group,
success=1) success=True,
oauth=bool(token))
jwt_cookie = JWT_COOKIE_NAME + plexpy.CONFIG.PMS_UUID jwt_cookie = JWT_COOKIE_NAME + plexpy.CONFIG.PMS_UUID
cherrypy.response.cookie[jwt_cookie] = jwt_token cherrypy.response.cookie[jwt_cookie] = jwt_token
@@ -326,14 +340,20 @@ class AuthController(object):
cherrypy.response.status = 200 cherrypy.response.status = 200
return {'status': 'success', 'token': jwt_token.decode('utf-8'), 'uuid': plexpy.CONFIG.PMS_UUID} return {'status': 'success', 'token': jwt_token.decode('utf-8'), 'uuid': plexpy.CONFIG.PMS_UUID}
elif admin_login == '1': elif admin_login == '1' and username:
self.on_login(username=username) self.on_login(username=username)
logger.debug(u"Tautulli WebAuth :: Invalid admin login attempt from '%s'." % username) logger.debug(u"Tautulli WebAuth :: Invalid admin login attempt from '%s'." % username)
cherrypy.response.status = 401 cherrypy.response.status = 401
return error_message return error_message
else: elif username:
self.on_login(username=username) self.on_login(username=username)
logger.debug(u"Tautulli WebAuth :: Invalid login attempt from '%s'." % username) logger.debug(u"Tautulli WebAuth :: Invalid user login attempt from '%s'." % username)
cherrypy.response.status = 401
return error_message
elif token:
self.on_login(username='Plex OAuth', oauth=True)
logger.debug(u"Tautulli WebAuth :: Invalid Plex OAuth login attempt.")
cherrypy.response.status = 401 cherrypy.response.status = 401
return error_message return error_message

View File

@@ -110,6 +110,7 @@ class WebInterface(object):
"pms_is_cloud": plexpy.CONFIG.PMS_IS_CLOUD, "pms_is_cloud": plexpy.CONFIG.PMS_IS_CLOUD,
"pms_token": plexpy.CONFIG.PMS_TOKEN, "pms_token": plexpy.CONFIG.PMS_TOKEN,
"pms_uuid": plexpy.CONFIG.PMS_UUID, "pms_uuid": plexpy.CONFIG.PMS_UUID,
"pms_name": plexpy.CONFIG.PMS_NAME,
"logging_ignore_interval": plexpy.CONFIG.LOGGING_IGNORE_INTERVAL "logging_ignore_interval": plexpy.CONFIG.LOGGING_IGNORE_INTERVAL
} }
@@ -2802,6 +2803,7 @@ class WebInterface(object):
"pms_url_manual": checked(plexpy.CONFIG.PMS_URL_MANUAL), "pms_url_manual": checked(plexpy.CONFIG.PMS_URL_MANUAL),
"pms_uuid": plexpy.CONFIG.PMS_UUID, "pms_uuid": plexpy.CONFIG.PMS_UUID,
"pms_web_url": plexpy.CONFIG.PMS_WEB_URL, "pms_web_url": plexpy.CONFIG.PMS_WEB_URL,
"pms_name": plexpy.CONFIG.PMS_NAME,
"date_format": plexpy.CONFIG.DATE_FORMAT, "date_format": plexpy.CONFIG.DATE_FORMAT,
"time_format": plexpy.CONFIG.TIME_FORMAT, "time_format": plexpy.CONFIG.TIME_FORMAT,
"week_start_monday": checked(plexpy.CONFIG.WEEK_START_MONDAY), "week_start_monday": checked(plexpy.CONFIG.WEEK_START_MONDAY),
@@ -4560,6 +4562,7 @@ class WebInterface(object):
"added_at": "1461572396", "added_at": "1461572396",
"art": "/library/metadata/1219/art/1462175063", "art": "/library/metadata/1219/art/1462175063",
"audience_rating": "8", "audience_rating": "8",
"audience_rating_image": "rottentomatoes://image.rating.upright",
"banner": "/library/metadata/1219/banner/1462175063", "banner": "/library/metadata/1219/banner/1462175063",
"collections": [], "collections": [],
"content_rating": "TV-MA", "content_rating": "TV-MA",
@@ -4613,7 +4616,8 @@ class WebInterface(object):
"video_language_code": "", "video_language_code": "",
"video_profile": "high", "video_profile": "high",
"video_ref_frames": "4", "video_ref_frames": "4",
"video_width": "1920" "video_width": "1920",
"selected": 0
}, },
{ {
"audio_bitrate": "384", "audio_bitrate": "384",
@@ -4626,7 +4630,8 @@ class WebInterface(object):
"audio_profile": "", "audio_profile": "",
"audio_sample_rate": "48000", "audio_sample_rate": "48000",
"id": "511664", "id": "511664",
"type": "2" "type": "2",
"selected": 1
}, },
{ {
"id": "511953", "id": "511953",
@@ -4637,7 +4642,8 @@ class WebInterface(object):
"subtitle_language": "English", "subtitle_language": "English",
"subtitle_language_code": "eng", "subtitle_language_code": "eng",
"subtitle_location": "external", "subtitle_location": "external",
"type": "3" "type": "3",
"selected": 1
} }
] ]
} }
@@ -4657,6 +4663,7 @@ class WebInterface(object):
"parent_thumb": "/library/metadata/153036/thumb/1462175062", "parent_thumb": "/library/metadata/153036/thumb/1462175062",
"parent_title": "", "parent_title": "",
"rating": "7.8", "rating": "7.8",
"rating_image": "rottentomatoes://image.rating.ripe",
"rating_key": "153037", "rating_key": "153037",
"section_id": "2", "section_id": "2",
"sort_title": "Game of Thrones", "sort_title": "Game of Thrones",
@@ -4920,6 +4927,7 @@ class WebInterface(object):
"art": "/library/metadata/1219/art/1503306930", "art": "/library/metadata/1219/art/1503306930",
"aspect_ratio": "1.78", "aspect_ratio": "1.78",
"audience_rating": "", "audience_rating": "",
"audience_rating_image": "rottentomatoes://image.rating.upright",
"audio_bitrate": "384", "audio_bitrate": "384",
"audio_bitrate_mode": "", "audio_bitrate_mode": "",
"audio_channel_layout": "5.1(side)", "audio_channel_layout": "5.1(side)",
@@ -4996,6 +5004,7 @@ class WebInterface(object):
"progress_percent": "0", "progress_percent": "0",
"quality_profile": "Original", "quality_profile": "Original",
"rating": "7.8", "rating": "7.8",
"rating_image": "rottentomatoes://image.rating.ripe",
"rating_key": "153037", "rating_key": "153037",
"relay": 0, "relay": 0,
"section_id": "2", "section_id": "2",