Compare commits

...

43 Commits

Author SHA1 Message Date
JonnyWong16
5cc6e0b172 Merge branch 'dev' 2016-03-27 17:25:53 -07:00
JonnyWong16
bff22900cb v1.3.13 2016-03-27 17:25:16 -07:00
JonnyWong16
5e79c9fd62 Only filter logger if string is longer than 5 characters 2016-03-27 17:22:30 -07:00
JonnyWong16
92f55c254c Merge branch 'dev' 2016-03-27 16:51:30 -07:00
JonnyWong16
39034e38f6 v1.3.12 2016-03-27 16:43:06 -07:00
JonnyWong16
3c7b9558fe Access log file from the Help & Info page 2016-03-27 16:41:57 -07:00
JonnyWong16
c8f7f40b46 ISO date format for logs 2016-03-27 16:10:02 -07:00
JonnyWong16
2a764cf190 Add "First" and "Last" page buttons to datatables 2016-03-27 15:32:03 -07:00
JonnyWong16
ba6ef4d629 Add toggle for log blacklist and mask public IP addresses 2016-03-27 15:18:41 -07:00
JonnyWong16
67d3505733 Merge pull request #627 from JonnyWong16/dev-env
Enable PlexPy dev environment
2016-03-27 10:30:42 -07:00
JonnyWong16
252145cf58 Enable PlexPy dev environment using --dev flag 2016-03-27 10:25:46 -07:00
JonnyWong16
dbc62542ef Merge pull request #634 from evilmarty/enhancement/ifttt
Allow formatting of IFTTT event key with action name
2016-03-26 18:08:45 -07:00
Marty Zalega
005829ab72 Allow formatting of ifttt event key with action name 2016-03-27 10:46:09 +10:00
JonnyWong16
448c8b0e8a Merge pull request #632 from alshain/patch-2
Fix unicode logging with 1252 encoded locale on Windows
2016-03-26 12:09:27 -07:00
Chris
ff0e724ee5 Fix unicode logging with 1252 encoded locale on Windows
Replaces the abbreviation for months in the log output with numerals. Works around logging exceptions on Windows during March ("Mär") with Swiss-German locale on Windows, which is encoded with Windows-1252.
2016-03-26 19:59:12 +01:00
JonnyWong16
568e4a5ee8 Fix blacklist logging again ed8c7c1 2016-03-26 10:00:58 -07:00
JonnyWong16
fbf4a524c1 Catch URLError when uploading to Imgur 2016-03-25 15:39:31 -07:00
JonnyWong16
29db2e958f Hide Plex notification agent 2016-03-25 13:24:24 -07:00
JonnyWong16
cc7bcbf9d5 Change log directory to log file in "Help & Info" 2016-03-25 13:20:50 -07:00
JonnyWong16
98d4484e6c Update CONTRIBUTING.md 2016-03-25 13:20:25 -07:00
JonnyWong16
0b126278f9 Fix blacklisting of blank strings from ed8c7c1 2016-03-25 13:00:04 -07:00
JonnyWong16
cc919415bb Merge pull request #612 from codedecay/dev
Add CherryPy Environment Option
2016-03-25 12:59:28 -07:00
JonnyWong16
a3f398390c Clean up Arnie quotes 2016-03-25 09:16:24 -07:00
JonnyWong16
5ae89368f1 Merge pull request #625 from Chrisophogus/patch-1
Extra Arnie
2016-03-25 09:14:25 -07:00
JonnyWong16
c8f1cb0a0a Start PlexPy for different environment variables 2016-03-25 09:12:40 -07:00
Chrisophogus
f783b08b78 Additional changes 2016-03-23 20:52:50 +00:00
Chrisophogus
85e0c6d3cd Extra Arnie
Added some additional Arnie quotes.
2016-03-23 20:14:48 +00:00
JonnyWong16
2259a96058 Use default poster for Facebook if unable to upload poster 2016-03-21 18:53:56 -07:00
JonnyWong16
afed5841e7 Remove old notify_log table upgrades 2016-03-20 17:17:50 -07:00
JonnyWong16
52361cd505 Catch error if unable to retrieve poster for notification 2016-03-20 17:06:58 -07:00
JonnyWong16
b743cca7bc Add summary to Facebook posts 2016-03-19 23:27:26 -07:00
JonnyWong16
1d01d0bff1 Add FeatHub feature requests and guidelines modal popup 2016-03-19 22:24:09 -07:00
JonnyWong16
c45a488962 Remove experimental from Facebook and Scripts 2016-03-19 20:45:49 -07:00
JonnyWong16
6731c44541 Merge pull request #614 from Vilsol/dev
Update Arnold Quotes
2016-03-19 16:20:31 -07:00
JonnyWong16
b04ed83963 Make sure build_notify_text returns two values 2016-03-16 19:13:29 -07:00
Vilsol
c35b79e642 Update Arnold Quotes 2016-03-16 16:33:56 +00:00
JonnyWong16
ed8c7c1052 Filter out tokens/keys/passwords from logger 2016-03-15 23:49:35 -07:00
JonnyWong16
498a074222 Add user GitHub API Token to settings 2016-03-15 23:49:27 -07:00
JonnyWong16
3fe6db4d42 Fix "Check GitHub for updates" not rescheduling when toggling setting 2016-03-15 20:42:45 -07:00
Eric Solari
6e5cd82dfb Add CherryPy Environment Option 2016-03-15 22:24:08 -05:00
JonnyWong16
cbf3488de9 Merge branch 'dev' 2016-03-15 19:15:46 -07:00
JonnyWong16
c72314fb71 v1.3.11 2016-03-15 19:14:56 -07:00
JonnyWong16
c4af6feb92 Fix typo preventing history logging for websockets 2016-03-15 19:13:13 -07:00
26 changed files with 441 additions and 219 deletions

View File

@@ -1,5 +1,36 @@
# Changelog
## v1.3.13 (2016-03-27)
* Fix: Only mask strings longer than 5 characters in logs.
## v1.3.12 (2016-03-27)
* Fix: "Check GitHub for updates" not rescheduling when toggling setting.
* Fix: Bug where notifications would fail if metadata is not found.
* Fix: Bug where notifications would fail if unable to upload poster to Imgur.
* Fix: PlexPy will now start properly for different Python environment variables.
* New: Feature requests moved to FeatHub.
* New: Ability to specify a GitHub API token for updates (optional).
* New: Mask out sensitive information from the logs.
* New: New and updated Arnold quotes. (Thanks @Vilsol & @Chrisophogus)
* New: "First" and "Last" page buttons to datatables.
* New: Access log file from the "Help & Info" page.
* New: CherryPy environment options (for development). (Thanks @codedecay)
* New: PlexPy development environment (for development only).
* Change: Facebook posts with a posters now include a summary.
* Change: Facebook posts now use a default poster if the poster is not found or unable to upload to Imgur.
* Change: IFTTT events can be fromatted with the {action} name.
* Change: Logs now use ISO date format to avoid locale encoding errors. (Thanks @alshain)
* Remove: Non-functioning Plex notification agent.
## v1.3.11 (2016-03-15)
* Fix: Typo preventing history logging for websockets.
## v1.3.10 (2016-03-12)
* Fix: Actually allow HTML tags for Pushover.

View File

@@ -1,7 +1,7 @@
# Contributing to PlexPy
## Issues
In case you read this because you are posting an issue, please take a minute and conside the things below. The issue tracker is not a support forum. It is primarily intended to submit bugs, improvements or feature requests. However, we are glad to help you, and make sure the problem is not caused by PlexPy, but don't expect step-by-step answers.
In case you read this because you are posting an issue, please take a minute and conside the things below. The issue tracker is not a support forum. It is primarily intended to submit bugs. However, we are glad to help you, and make sure the problem is not caused by PlexPy, but don't expect step-by-step answers.
##### Many issues can simply be solved by:
@@ -35,11 +35,11 @@ In case you read this because you are posting an issue, please take a minute and
## Feature Requests
1. Search for similar existing 'issues', feature requests can be recognized by the blue `enhancement` label.
2. If a similar request exists, post a comment (+1, or add a new idea to the existing request).
3. If no similar requests exist, you can create a new one.
4. Provide a clear title to easily identify the feature request.
5. Tag your feature request with `[Feature Request]` so it can be identified easily.
Feature requests are handled on [FeatHub](http://feathub.com/drzoidberg33/plexpy).
1. Search the existing requests to see if your suggestion has already been submitted.
2. If a similar request exists, give it a thumbs up (+1), or add additional comments to the request.
3. If no similar requests exist, you can create a new one. Make sure to provide a clear title to easily identify the feature request.
## Pull Requests
If you think you can contribute code to the PlexPy repository, do not hesitate to submit a pull request.

View File

@@ -1,4 +1,9 @@
#!/usr/bin/env python
#!/bin/sh
''''which python >/dev/null 2>&1 && exec python "$0" "$@" # '''
''''which python2 >/dev/null 2>&1 && exec python2 "$0" "$@" # '''
''''which python2.7 >/dev/null 2>&1 && exec python2.7 "$0" "$@" # '''
''''exec echo "Error: Python not found!" # '''
# -*- coding: utf-8 -*-
# This file is part of PlexPy.
@@ -76,11 +81,14 @@ def main():
'-d', '--daemon', action='store_true', help='Run as a daemon')
parser.add_argument(
'-p', '--port', type=int, help='Force PlexPy to run on a specified port')
parser.add_argument(
'--dev', action='store_true', help='Start PlexPy in the development environment')
parser.add_argument(
'--datadir', help='Specify a directory where to store your data files')
parser.add_argument('--config', help='Specify a config file to use')
parser.add_argument('--nolaunch', action='store_true',
help='Prevent browser from launching on startup')
parser.add_argument(
'--config', help='Specify a config file to use')
parser.add_argument(
'--nolaunch', action='store_true', help='Prevent browser from launching on startup')
parser.add_argument(
'--pidfile', help='Create a pid file (only relevant when running as a daemon)')
@@ -95,6 +103,10 @@ def main():
logger.initLogger(console=not plexpy.QUIET, log_dir=False,
verbose=plexpy.VERBOSE)
if args.dev:
plexpy.DEV = True
logger.debug(u"PlexPy is running in the dev environment.")
if args.daemon:
if sys.platform == 'win32':
sys.stderr.write(
@@ -159,6 +171,19 @@ def main():
# Read config and start logging
plexpy.initialize(config_file)
# Start the background threads
plexpy.start()
# Open connection for websocket
if plexpy.CONFIG.MONITORING_USE_WEBSOCKET:
try:
web_socket.start_thread()
except:
logger.warn(u"Websocket :: Unable to open connection.")
# Fallback to polling
plexpy.POLLING_FAILOVER = True
plexpy.initialize_scheduler()
# Force the http port if neccessary
if args.port:
http_port = args.port
@@ -181,6 +206,7 @@ def main():
'http_port': http_port,
'http_host': plexpy.CONFIG.HTTP_HOST,
'http_root': plexpy.CONFIG.HTTP_ROOT,
'http_environment': plexpy.CONFIG.HTTP_ENVIRONMENT,
'http_proxy': plexpy.CONFIG.HTTP_PROXY,
'enable_https': plexpy.CONFIG.ENABLE_HTTPS,
'https_cert': plexpy.CONFIG.HTTPS_CERT,
@@ -190,21 +216,8 @@ def main():
}
webstart.initialize(web_config)
# Start the background threads
plexpy.start()
# Open connection for websocket
if plexpy.CONFIG.MONITORING_USE_WEBSOCKET:
try:
web_socket.start_thread()
except:
logger.warn(u"Websocket :: Unable to open connection.")
# Fallback to polling
plexpy.POLLING_FAILOVER = True
plexpy.initialize_scheduler()
# Open webbrowser
if plexpy.CONFIG.LAUNCH_BROWSER and not args.nolaunch:
if plexpy.CONFIG.LAUNCH_BROWSER and not args.nolaunch and not plexpy.DEV:
plexpy.launch_browser(plexpy.CONFIG.HTTP_HOST, http_port,
plexpy.CONFIG.HTTP_ROOT)

View File

@@ -9,6 +9,7 @@ This project is based on code from [Headphones](https://github.com/rembo10/headp
* PlexPy [forum thread](https://forums.plex.tv/discussion/169591/plexpy-another-plex-monitoring-program)
## Features
* Responsive web design viewable on desktop, tablet and mobile web browsers.
* Themed to complement Plex/Web.
* Easy configuration setup (no separate web server required).
@@ -65,13 +66,14 @@ This project is based on code from [Headphones](https://github.com/rembo10/headp
## Feature Requests
1. Search for similar existing 'issues', feature requests can be recognized by the blue `enhancement` label.
2. If a similar request exists, post a comment (+1, or add a new idea to the existing request).
3. If no similar requests exist, you can create a new one.
4. Provide a clear title to easily identify the feature request.
5. Tag your feature request with `[Feature Request]` so it can be identified easily.
Feature requests are handled on [FeatHub](http://feathub.com/drzoidberg33/plexpy).
1. Search the existing requests to see if your suggestion has already been submitted.
2. If a similar request exists, give it a thumbs up (+1), or add additional comments to the request.
3. If no similar requests exist, you can create a new one. Make sure to provide a clear title to easily identify the feature request.
## License
This is free software under the GPL v3 open source license. Feel free to do with it what you wish, but any modification must be open sourced. A copy of the license is included.
This software includes Highsoft software libraries which you may freely distribute for non-commercial use. Commerical users must licence this software, for more information visit https://shop.highsoft.com/faq/non-commercial#non-commercial-redistribution.

View File

@@ -21,7 +21,7 @@ history_table_options = {
"infoFiltered":"<span class='hidden-md hidden-sm hidden-xs'>(filtered from _MAX_ total entries)</span>",
"emptyTable": "No data in table"
},
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"stateSave": true,
"processing": false,
"serverSide": true,

View File

@@ -19,7 +19,7 @@ history_table_modal_options = {
"infoFiltered":"",
"emptyTable": "No data in table",
},
"pagingType": "bootstrap",
"pagingType": "simple_numbers",
"stateSave": false,
"processing": false,
"serverSide": true,

View File

@@ -17,7 +17,7 @@ libraries_list_table_options = {
"order": [ 2, 'asc'],
"autoWidth": true,
"stateSave": true,
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"columnDefs": [
{
"targets": [0],

View File

@@ -2,7 +2,7 @@ var log_table_options = {
"destroy": true,
"serverSide": true,
"processing": false,
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"order": [ 0, 'desc'],
"pageLength": 50,
"stateSave": true,

View File

@@ -22,7 +22,7 @@ media_info_table_options = {
"infoFiltered":"<span class='hidden-md hidden-sm hidden-xs'>(filtered from _MAX_ total entries)</span>",
"emptyTable": "No data in table"
},
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"stateSave": true,
"processing": false,
"serverSide": true,

View File

@@ -2,7 +2,7 @@ notification_log_table_options = {
"destroy": true,
"serverSide": true,
"processing": false,
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"order": [ 0, 'desc'],
"pageLength": 50,
"stateSave": true,

View File

@@ -2,7 +2,7 @@ var plex_log_table_options = {
"destroy": true,
"processing": false,
"serverSide": false,
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"order": [ 0, 'desc'],
"pageLength": 50,
"stateSave": true,

View File

@@ -1,7 +1,7 @@
sync_table_options = {
"processing": false,
"serverSide": false,
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"order": [ [ 0, 'desc'], [ 1, 'asc'], [2, 'asc'] ],
"pageLength": 25,
"stateSave": true,

View File

@@ -9,7 +9,7 @@ user_ip_table_options = {
"emptyTable": "No data in table",
},
"stateSave": true,
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"processing": false,
"serverSide": true,
"pageLength": 10,

View File

@@ -17,7 +17,7 @@ users_list_table_options = {
"order": [ 2, 'asc'],
"autoWidth": true,
"stateSave": true,
"pagingType": "bootstrap",
"pagingType": "full_numbers",
"columnDefs": [
{
"targets": [0],

View File

@@ -1,5 +1,6 @@
<%inherit file="base.html"/>
<%!
import os
import sys
import plexpy
from plexpy import notifiers, common, versioncheck
@@ -80,6 +81,10 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<td>Database File:</td>
<td>${plexpy.DB_FILE}</td>
</tr>
<tr>
<td>Log File:</td>
<td><a class="no-highlight" href="logFile" target="_blank">${os.path.join(config['log_dir'],'plexpy.log')}</a></td>
</tr>
<tr>
<td>Backup Directory:</td>
<td>${config['backup_dir']}</td>
@@ -88,10 +93,6 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<td>Cache Directory:</td>
<td>${config['cache_dir']}</td>
</tr>
<tr>
<td>Log Directory:</td>
<td>${config['log_dir']}</td>
</tr>
% if plexpy.ARGS:
<tr>
<td>Arguments:</td>
@@ -110,13 +111,21 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<td class="top-line">Plex Forums:</td>
<td class="top-line"><a class="no-highlight" href="${anon_url('https://forums.plex.tv/discussion/169591/plexpy-another-plex-monitoring-program')}" target="_blank">https://forums.plex.tv/discussion/169591/plexpy-another-plex-monitoring-program</a></td>
</tr>
<tr>
<td>Source:</td>
<td><a id="source-link" class="no-highlight" href="${anon_url('https://github.com/drzoidberg33/plexpy')}" target="_blank">https://github.com/drzoidberg33/plexpy</a></td>
</tr>
<tr>
<td>Wiki:</td>
<td><a class="no-highlight" href="${anon_url('https://github.com/drzoidberg33/plexpy/wiki')}" target="_blank">https://github.com/drzoidberg33/plexpy/wiki</a></td>
</tr>
<tr>
<td>Source:</td>
<td><a class="no-highlight" href="${anon_url('https://github.com/drzoidberg33/plexpy')}" target="_blank">https://github.com/drzoidberg33/plexpy</a></td>
<td>Issues:</td>
<td><a class="no-highlight guidelines-modal-link" href="${anon_url('https://github.com/drzoidberg33/plexpy/issues')}" data-id="issue">https://github.com/drzoidberg33/plexpy/issues</a></td>
</tr>
<tr>
<td>Feature Requests:</td>
<td><a class="no-highlight guidelines-modal-link" href="${anon_url('http://feathub.com/drzoidberg33/plexpy')}" data-id="feature request">http://feathub.com/drzoidberg33/plexpy</a></td>
</tr>
<tr>
<td>Gitter Chat:</td>
@@ -142,6 +151,18 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
</label>
<p class="help-block">If you have Git installed, allow periodic checks for updates.</p>
</div>
<div id="git_update_options">
<div class="form-group">
<label for="git_token">GitHub API Token</label>
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control" id="git_token" name="git_token" value="${config['git_token']}" data-parsley-trigger="change">
</div>
</div>
<p class="help-block">Optional: Use your own GitHub API token when checking for updates.
</div>
</div>
<div class="padded-header">
<h3>Display Settings</h3>
</div>
@@ -169,6 +190,13 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
</label>
<p class="help-block">Group successive play history by the same user as a single entry in the tables and watch statistics.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="log_blacklist" name="log_blacklist" value="1" ${config['log_blacklist']}> Mask Sensitive Information in Logs
</label>
<p class="help-block">Enable to mask passwords, access tokens, and public IP addresses with asterisks (*) in the logs.<br />
Note: Only logs from the time this setting is enabled will be masked. Do not post your logs publically without masking sensitive information!</p>
</div>
<div class="padded-header">
<h3>Directories</h3>
@@ -1098,12 +1126,12 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<tr>
<td><strong>YYYY</strong></td>
<td>Numeric, four digits</td>
<td>Eg., 1999, 2003</td>
<td>E.g. 1999, 2003</td>
</tr>
<tr>
<td><strong>YY</strong></td>
<td>Numeric, two digits</td>
<td>Eg., 99, 03</td>
<td>E.g. 99, 03</td>
</tr>
</tbody>
</table>
@@ -1181,7 +1209,7 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<tr>
<td><strong>Do</strong></td>
<td>Numeric, with suffix</td>
<td>Eg., 1st, 2nd ... 31st.</td>
<td>E.g. 1st, 2nd ... 31st.</td>
</tr>
</tbody>
</table>
@@ -1317,12 +1345,12 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<tr>
<td><strong>ZZ</strong></td>
<td>UTC offset</td>
<td>Eg., +0100, -0700</td>
<td>E.g. +0100, -0700</td>
</tr>
<tr>
<td><strong>Z</strong></td>
<td>UTC offset</td>
<td>Eg., +01:00, -07:00</td>
<td>E.g. +01:00, -07:00</td>
</tr>
</tbody>
</table>
@@ -1338,7 +1366,7 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<tr>
<td><strong>X</strong></td>
<td>Unix timestamp</td>
<td>Eg., 1456887825</td>
<td>E.g. 1456887825</td>
</tr>
</tbody>
</table>
@@ -1858,6 +1886,26 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
</div>
</div>
</div>
<div id="guidelines-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="guidelines-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">Guidelines</h4>
</div>
<div class="modal-body">
<div style="text-align: center; margin-top: 20px; margin-bottom: 20px;">
<strong>Please read the <a href="#" target="_blank" id="guidelines-link">guidelines</a> in the README document <br />before submitting a new <span id="guidelines-type"></span>!</strong>
<br /><br />
Your post may be removed for failure to follow the guidelines.
</div>
</div>
<div class="modal-footer">
<a href="#" target="_blank" id="guidelines-continue" class="btn btn-bright">Continue</a>
</div>
</div>
</div>
</div>
</div>
</%def>
@@ -1990,6 +2038,20 @@ $(document).ready(function() {
}
});
if ($("#check_github").is(":checked")) {
$("#git_update_options").show();
} else {
$("#git_update_options").hide();
}
$("#check_github").click(function(){
if ($("#check_github").is(":checked")) {
$("#git_update_options").slideDown();
} else {
$("#git_update_options").slideUp();
}
});
$( ".http-settings" ).change(function() {
httpChanged = true;
});
@@ -2311,6 +2373,17 @@ $(document).ready(function() {
var c = this.checked ? '#eb8600' : '#737373';
$('#notify_recently_added_grandparent_note').css('color', c);
});
$('.guidelines-modal-link').on('click', function (e) {
e.preventDefault();
$('#guidelines-link').attr('href', $('#source-link').attr('href'));
$('#guidelines-type').text($(this).data('id'))
$('#guidelines-modal').modal();
$('#guidelines-continue').attr('href', $(this).attr('href')).on('click', function () {
$('#guidelines-modal').modal('hide');
});
});
});
</script>
</%def>

View File

@@ -74,6 +74,8 @@ UMASK = None
POLLING_FAILOVER = False
DEV = False
def initialize(config_file):
with INIT_LOCK:
@@ -729,30 +731,6 @@ def dbcheck():
'ALTER TABLE users ADD COLUMN deleted_user INTEGER DEFAULT 0'
)
# Upgrade notify_log table from earlier versions
try:
c_db.execute('SELECT on_pause FROM notify_log')
except sqlite3.OperationalError:
logger.debug(u"Altering database. Updating database table notify_log.")
c_db.execute(
'ALTER TABLE notify_log ADD COLUMN on_pause INTEGER'
)
c_db.execute(
'ALTER TABLE notify_log ADD COLUMN on_resume INTEGER'
)
c_db.execute(
'ALTER TABLE notify_log ADD COLUMN on_buffer INTEGER'
)
# Upgrade notify_log table from earlier versions
try:
c_db.execute('SELECT on_created FROM notify_log')
except sqlite3.OperationalError:
logger.debug(u"Altering database. Updating database table notify_log.")
c_db.execute(
'ALTER TABLE notify_log ADD COLUMN on_created INTEGER'
)
# Upgrade notify_log table from earlier versions
try:
c_db.execute('SELECT poster_url FROM notify_log')

View File

@@ -130,7 +130,6 @@ class ActivityProcessor(object):
stopped = int(time.time())
self.set_session_state(session_key=session['session_key'],
state='stopped',
view_offset=session['viewOffset'],
stopped=stopped)
if plexpy.CONFIG.MOVIE_LOGGING_ENABLE and str(session['rating_key']).isdigit() and \
@@ -382,9 +381,10 @@ class ActivityProcessor(object):
return None
def set_session_state(self, session_key=None, state=None, view_offset=0, **kwargs):
if str(session_key).isdigit() and str(view_offset).isdigit():
values = {'view_offset': int(view_offset)}
def set_session_state(self, session_key=None, state=None, **kwargs):
if str(session_key).isdigit():
values = {}
if state:
values['state'] = state

View File

@@ -111,6 +111,7 @@ _CONFIG_DEFINITIONS = {
'GET_FILE_SIZES_HOLD': (dict, 'General', {'section_ids': [], 'rating_keys': []}),
'GIT_BRANCH': (str, 'General', 'master'),
'GIT_PATH': (str, 'General', ''),
'GIT_TOKEN': (str, 'General', ''),
'GIT_USER': (str, 'General', 'drzoidberg33'),
'GRAPH_TYPE': (str, 'General', 'plays'),
'GRAPH_DAYS': (int, 'General', 30),
@@ -142,6 +143,7 @@ _CONFIG_DEFINITIONS = {
'HTTPS_KEY': (str, 'General', ''),
'HTTPS_DOMAIN': (str, 'General', 'localhost'),
'HTTPS_IP': (str, 'General', '127.0.0.1'),
'HTTP_ENVIRONMENT': (str, 'General', 'production'),
'HTTP_HOST': (str, 'General', '0.0.0.0'),
'HTTP_PASSWORD': (str, 'General', ''),
'HTTP_PORT': (int, 'General', 8181),
@@ -167,6 +169,7 @@ _CONFIG_DEFINITIONS = {
'IFTTT_ON_PMSUPDATE': (int, 'IFTTT', 0),
'JOURNAL_MODE': (str, 'Advanced', 'wal'),
'LAUNCH_BROWSER': (int, 'General', 1),
'LOG_BLACKLIST': (int, 'General', 1),
'LOG_DIR': (str, 'General', ''),
'LOGGING_IGNORE_INTERVAL': (int, 'Monitoring', 120),
'MOVIE_LOGGING_ENABLE': (int, 'Monitoring', 1),
@@ -431,6 +434,9 @@ _CONFIG_DEFINITIONS = {
'XBMC_ON_PMSUPDATE': (int, 'XBMC', 0)
}
_BLACKLIST_KEYS = ['_APITOKEN', '_TOKEN', '_KEY', '_SECRET', '_PASSWORD', '_APIKEY', '_ID']
_WHITELIST_KEYS = ['HTTPS_KEY', 'UPDATE_SECTION_IDS']
# pylint:disable=R0902
# it might be nice to refactor for fewer instance variables
@@ -444,6 +450,19 @@ class Config(object):
for key in _CONFIG_DEFINITIONS.keys():
self.check_setting(key)
self._upgrade()
self._blacklist()
def _blacklist(self):
""" Add tokens and passwords to blacklisted words in logger """
blacklist = []
for key, subkeys in self._config.iteritems():
for subkey, value in subkeys.iteritems():
if isinstance(value, basestring) and len(value.strip()) > 5 and \
subkey.upper() not in _WHITELIST_KEYS and any(bk in subkey.upper() for bk in _BLACKLIST_KEYS):
blacklist.append(value.strip())
plexpy.logger._BLACKLIST_WORDS = blacklist
def _define(self, name):
key = name.upper()
@@ -503,6 +522,8 @@ class Config(object):
except IOError as e:
plexpy.logger.error("Error writing configuration file: %s", e)
self._blacklist()
def __getattr__(self, name):
"""
Returns something from the ini unless it is a real property

View File

@@ -552,13 +552,14 @@ def uploadToImgur(imgPath, imgTitle=''):
response = json.loads(response.read())
if response.get('status') == 200:
logger.debug(u"PlexPy Helpers :: Image uploaded to Imgur.")
t = '\'' + imgTitle + '\' ' if imgTitle else ''
logger.debug(u"PlexPy Helpers :: Image %suploaded to Imgur." % t)
img_url = response.get('data').get('link', '')
elif response.get('status') >= 400 and response.get('status') < 500:
logger.warn(u"PlexPy Helpers :: Unable to upload image to Imgur: %s" % response.reason)
else:
logger.warn(u"PlexPy Helpers :: Unable to upload image to Imgur.")
except urllib2.HTTPError as e:
except (urllib2.HTTPError, urllib2.URLError) as e:
logger.warn(u"PlexPy Helpers :: Unable to upload image to Imgur: %s" % e)
return img_url

View File

@@ -27,12 +27,15 @@ import logging
import errno
import sys
import os
import re
# These settings are for file logging only
FILENAME = "plexpy.log"
MAX_SIZE = 1000000 # 1 MB
MAX_FILES = 5
_BLACKLIST_WORDS = []
# PlexPy logger
logger = logging.getLogger("plexpy")
@@ -62,6 +65,62 @@ class NoThreadFilter(logging.Filter):
return not record.threadName == self.threadName
# Taken from Hellowlol/HTPC-Manager
class BlacklistFilter(logging.Filter):
"""
Log filter for blacklisted tokens and passwords
"""
def __init__(self):
pass
def filter(self, record):
if not plexpy.CONFIG.LOG_BLACKLIST:
return True
for item in _BLACKLIST_WORDS:
try:
if item in record.msg:
record.msg = record.msg.replace(item, 8 * '*' + item[-2:])
if any(item in str(arg) for arg in record.args):
record.args = tuple(arg.replace(item, 8 * '*' + item[-2:]) if isinstance(arg, basestring) else arg
for arg in record.args)
except:
pass
return True
class PublicIPFilter(logging.Filter):
"""
Log filter for public IP addresses
"""
def __init__(self):
pass
def filter(self, record):
if not plexpy.CONFIG.LOG_BLACKLIST:
return True
try:
# Currently only checking for ipv4 addresses
ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}', record.msg)
for ip in ipv4:
if helpers.is_ip_public(ip):
record.msg = record.msg.replace(ip, ip.partition('.')[0] + '.***.***.***')
args = []
for arg in record.args:
ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}', arg) if isinstance(arg, basestring) else []
for ip in ipv4:
if helpers.is_ip_public(ip):
arg = arg.replace(ip, ip.partition('.')[0] + '.***.***.***')
args.append(arg)
record.args = tuple(args)
except:
pass
return True
@contextlib.contextmanager
def listener():
"""
@@ -160,7 +219,7 @@ def initLogger(console=False, log_dir=False, verbose=False):
if log_dir:
filename = os.path.join(log_dir, FILENAME)
file_formatter = logging.Formatter('%(asctime)s - %(levelname)-7s :: %(threadName)s : %(message)s', '%d-%b-%Y %H:%M:%S')
file_formatter = logging.Formatter('%(asctime)s - %(levelname)-7s :: %(threadName)s : %(message)s', '%Y-%m-%d %H:%M:%S')
file_handler = handlers.RotatingFileHandler(filename, maxBytes=MAX_SIZE, backupCount=MAX_FILES)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(file_formatter)
@@ -169,13 +228,21 @@ def initLogger(console=False, log_dir=False, verbose=False):
# Setup console logger
if console:
console_formatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(threadName)s : %(message)s', '%d-%b-%Y %H:%M:%S')
console_formatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(threadName)s : %(message)s', '%Y-%m-%d %H:%M:%S')
console_handler = logging.StreamHandler()
console_handler.setFormatter(console_formatter)
console_handler.setLevel(logging.DEBUG)
logger.addHandler(console_handler)
# Add filters to log handlers
# Only add filters after the config file has been initialized
# Nothing prior to initialization should contain sensitive information
if not plexpy.DEV and plexpy.CONFIG:
for handler in logger.handlers:
handler.addFilter(BlacklistFilter())
handler.addFilter(PublicIPFilter())
# Install exception hooks
initHooks()

View File

@@ -325,11 +325,9 @@ def notify_timeline(timeline_data=None, notify_action=None):
notify_action=notify_action)
# Set the notification state in the db
set_notify_state(session={},
notify_action=notify_action,
set_notify_state(notify_action=notify_action,
agent_info=agent,
notify_strings=notify_strings,
metadata={})
notify_strings=notify_strings)
if agent['on_intdown'] and notify_action == 'intdown':
# Build and send notification
@@ -343,11 +341,9 @@ def notify_timeline(timeline_data=None, notify_action=None):
notify_action=notify_action)
# Set the notification state in the db
set_notify_state(session={},
notify_action=notify_action,
set_notify_state(notify_action=notify_action,
agent_info=agent,
notify_strings=notify_strings,
metadata={})
notify_strings=notify_strings)
if agent['on_extup'] and notify_action == 'extup':
# Build and send notification
@@ -361,11 +357,9 @@ def notify_timeline(timeline_data=None, notify_action=None):
notify_action=notify_action)
# Set the notification state in the db
set_notify_state(session={},
notify_action=notify_action,
set_notify_state(notify_action=notify_action,
agent_info=agent,
notify_strings=notify_strings,
metadata={})
notify_strings=notify_strings)
if agent['on_intup'] and notify_action == 'intup':
# Build and send notification
@@ -379,11 +373,9 @@ def notify_timeline(timeline_data=None, notify_action=None):
notify_action=notify_action)
# Set the notification state in the db
set_notify_state(session={},
notify_action=notify_action,
set_notify_state(notify_action=notify_action,
agent_info=agent,
notify_strings=notify_strings,
metadata={})
notify_strings=notify_strings)
if agent['on_pmsupdate'] and notify_action == 'pmsupdate':
# Build and send notification
@@ -397,11 +389,9 @@ def notify_timeline(timeline_data=None, notify_action=None):
notify_action=notify_action)
# Set the notification state in the db
set_notify_state(session={},
notify_action=notify_action,
set_notify_state(notify_action=notify_action,
agent_info=agent,
notify_strings=notify_strings,
metadata={})
notify_strings=notify_strings)
else:
logger.debug(u"PlexPy NotificationHandler :: Notify timeline called but incomplete data received.")
@@ -426,11 +416,14 @@ def get_notify_state(session):
return notify_states
def set_notify_state(session, notify_action, agent_info, notify_strings, metadata):
def set_notify_state(notify_action, agent_info, notify_strings, session=None, metadata=None):
if notify_action and agent_info:
monitor_db = database.MonitorDatabase()
session = session or {}
metadata = metadata or {}
if notify_strings[2]:
script_args = '[' + ', '.join(notify_strings[2]) + ']'
else:
@@ -496,7 +489,7 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
metadata = metadata_list['metadata']
else:
logger.error(u"PlexPy NotificationHandler :: Unable to retrieve metadata for rating_key %s" % str(rating_key))
return []
return [None, None, None], None
# Check for exclusion tags
if metadata['media_type'] == 'movie':
@@ -632,11 +625,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
# If no previous poster_url
if not poster_url and plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS:
# Retrieve the poster from Plex and cache to file
urllib.urlretrieve(plexpy.CONFIG.PMS_URL + thumb + '?X-Plex-Token=' + plexpy.CONFIG.PMS_TOKEN,
os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg'))
# Upload thumb to Imgur and get link
poster_url = helpers.uploadToImgur(os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg'), poster_title)
try:
# Retrieve the poster from Plex and cache to file
urllib.urlretrieve(plexpy.CONFIG.PMS_URL + thumb + '?X-Plex-Token=' + plexpy.CONFIG.PMS_TOKEN,
os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg'))
# Upload thumb to Imgur and get link
poster_url = helpers.uploadToImgur(os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg'), poster_title)
except Exception as e:
logger.error(u"PlexPy Notifier :: Unable to retrieve poster for rating_key %s: %s." % (str(rating_key), e))
metadata['poster_url'] = poster_url
@@ -918,7 +914,7 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
else:
return [subject_text, body_text, script_args], metadata
else:
return None
return [None, None, None], None
def build_server_notify_text(notify_action=None, agent_id=None):

View File

@@ -114,24 +114,24 @@ def available_notification_agents():
'on_intup': plexpy.CONFIG.XBMC_ON_INTUP,
'on_pmsupdate': plexpy.CONFIG.XBMC_ON_PMSUPDATE
},
{'name': 'Plex',
'id': AGENT_IDS['Plex'],
'config_prefix': 'plex',
'has_config': True,
'state': checked(plexpy.CONFIG.PLEX_ENABLED),
'on_play': plexpy.CONFIG.PLEX_ON_PLAY,
'on_stop': plexpy.CONFIG.PLEX_ON_STOP,
'on_pause': plexpy.CONFIG.PLEX_ON_PAUSE,
'on_resume': plexpy.CONFIG.PLEX_ON_RESUME,
'on_buffer': plexpy.CONFIG.PLEX_ON_BUFFER,
'on_watched': plexpy.CONFIG.PLEX_ON_WATCHED,
'on_created': plexpy.CONFIG.PLEX_ON_CREATED,
'on_extdown': plexpy.CONFIG.PLEX_ON_EXTDOWN,
'on_intdown': plexpy.CONFIG.PLEX_ON_INTDOWN,
'on_extup': plexpy.CONFIG.PLEX_ON_EXTUP,
'on_intup': plexpy.CONFIG.PLEX_ON_INTUP,
'on_pmsupdate': plexpy.CONFIG.PLEX_ON_PMSUPDATE
},
#{'name': 'Plex',
# 'id': AGENT_IDS['Plex'],
# 'config_prefix': 'plex',
# 'has_config': True,
# 'state': checked(plexpy.CONFIG.PLEX_ENABLED),
# 'on_play': plexpy.CONFIG.PLEX_ON_PLAY,
# 'on_stop': plexpy.CONFIG.PLEX_ON_STOP,
# 'on_pause': plexpy.CONFIG.PLEX_ON_PAUSE,
# 'on_resume': plexpy.CONFIG.PLEX_ON_RESUME,
# 'on_buffer': plexpy.CONFIG.PLEX_ON_BUFFER,
# 'on_watched': plexpy.CONFIG.PLEX_ON_WATCHED,
# 'on_created': plexpy.CONFIG.PLEX_ON_CREATED,
# 'on_extdown': plexpy.CONFIG.PLEX_ON_EXTDOWN,
# 'on_intdown': plexpy.CONFIG.PLEX_ON_INTDOWN,
# 'on_extup': plexpy.CONFIG.PLEX_ON_EXTUP,
# 'on_intup': plexpy.CONFIG.PLEX_ON_INTUP,
# 'on_pmsupdate': plexpy.CONFIG.PLEX_ON_PMSUPDATE
# },
{'name': 'NotifyMyAndroid',
'id': AGENT_IDS['NMA'],
'config_prefix': 'nma',
@@ -436,7 +436,7 @@ def get_notification_agent_config(agent_id):
return []
def send_notification(agent_id, subject, body, **kwargs):
def send_notification(agent_id, subject, body, notify_action, **kwargs):
if str(agent_id).isdigit():
agent_id = int(agent_id)
@@ -478,7 +478,7 @@ def send_notification(agent_id, subject, body, **kwargs):
tweet.notify(subject=subject, message=body)
elif agent_id == 12:
iftttClient = IFTTT()
iftttClient.notify(subject=subject, message=body)
iftttClient.notify(subject=subject, message=body, action=notify_action)
elif agent_id == 13:
telegramClient = TELEGRAM()
telegramClient.notify(message=body, event=subject)
@@ -1604,10 +1604,11 @@ class IFTTT(object):
self.apikey = plexpy.CONFIG.IFTTT_KEY
self.event = plexpy.CONFIG.IFTTT_EVENT
def notify(self, message, subject):
def notify(self, message, subject, action):
if not message or not subject:
return
event = unicode(self.event).format(action=action)
http_handler = HTTPSConnection("maker.ifttt.com")
data = {'value1': subject.encode("utf-8"),
@@ -1616,7 +1617,7 @@ class IFTTT(object):
# logger.debug(u"Ifttt SENDING: %s" % json.dumps(data))
http_handler.request("POST",
"/trigger/%s/with/key/%s" % (self.event, self.apikey),
"/trigger/%s/with/key/%s" % (event, self.apikey),
headers={'Content-type': "application/json"},
body=json.dumps(data))
response = http_handler.getresponse()
@@ -1649,7 +1650,9 @@ class IFTTT(object):
{'label': 'Ifttt Event',
'value': self.event,
'name': 'ifttt_event',
'description': 'The Ifttt maker event to fire. The notification subject and body will be sent'
'description': 'The Ifttt maker event to fire. You can include'
' the {action} to be substituted with the action name.'
' The notification subject and body will be sent'
' as value1 and value2 respectively.',
'input_type': 'text'
}
@@ -2006,12 +2009,11 @@ class Scripts(object):
logger.error(u"PlexPy Notifiers :: Failed to run script: %s" % e)
def return_config_options(self):
config_option = [{'label': 'Warning',
'description': '<strong>Script notifications are currently experimental!</strong><br><br>\
Supported file types: ' + ', '.join(self.script_exts),
config_option = [{'label': 'Supported File Types',
'description': ', '.join(self.script_exts),
'input_type': 'help'
},
{'label': 'Script folder',
{'label': 'Script Folder',
'value': plexpy.CONFIG.SCRIPTS_FOLDER,
'name': 'scripts_folder',
'description': 'Add your script folder.',
@@ -2170,74 +2172,83 @@ class FacebookNotifier(object):
if self.incl_poster and 'metadata' in kwargs:
metadata = kwargs['metadata']
poster_url = metadata.get('poster_url','')
poster_link = ''
caption = ''
if poster_url:
if metadata['media_type'] == 'movie':
title = metadata['title']
subtitle = metadata['year']
rating_key = metadata['rating_key']
if metadata.get('imdb_url',''):
poster_link = metadata.get('imdb_url', '')
caption = 'View on IMDB.'
elif metadata.get('themoviedb_url',''):
poster_link = metadata.get('themoviedb_url', '')
caption = 'View on The Movie Database.'
elif metadata['media_type'] == 'show':
title = metadata['title']
subtitle = metadata['year']
rating_key = metadata['rating_key']
if metadata.get('thetvdb_url',''):
poster_link = metadata.get('thetvdb_url', '')
caption = 'View on TheTVDB.'
elif metadata.get('themoviedb_url',''):
poster_link = metadata.get('themoviedb_url', '')
caption = 'View on The Movie Database.'
elif metadata['media_type'] == 'episode':
title = '%s - %s' % (metadata['grandparent_title'], metadata['title'])
subtitle = 'S%s %s E%s' % (metadata['parent_media_index'],
'\xc2\xb7'.decode('utf8'),
metadata['media_index'])
rating_key = metadata['rating_key']
if metadata.get('thetvdb_url',''):
poster_link = metadata.get('thetvdb_url', '')
caption = 'View on TheTVDB.'
elif metadata.get('themoviedb_url',''):
poster_link = metadata.get('themoviedb_url', '')
caption = 'View on The Movie Database.'
elif metadata['media_type'] == 'artist':
title = metadata['title']
subtitle = ''
rating_key = metadata['rating_key']
if metadata.get('lastfm_url',''):
poster_link = metadata.get('lastfm_url', '')
caption = 'View on Last.fm.'
elif metadata['media_type'] == 'track':
title = '%s - %s' % (metadata['grandparent_title'], metadata['title'])
subtitle = metadata['parent_title']
rating_key = metadata['parent_rating_key']
if metadata.get('lastfm_url',''):
poster_link = metadata.get('lastfm_url', '')
caption = 'View on Last.fm.'
# Build Facebook post attachment
if self.incl_pmslink:
caption = 'View on Plex Web.'
attachment['link'] = 'http://app.plex.tv/web/app#!/server/' + plexpy.CONFIG.PMS_IDENTIFIER + \
'/details/%2Flibrary%2Fmetadata%2F' + rating_key
attachment['caption'] = caption
elif poster_link:
attachment['link'] = poster_link
attachment['caption'] = caption
# Use default posters if no poster_url
if not poster_url:
if metadata['media_type'] in ['artist', 'track']:
poster_url = 'https://raw.githubusercontent.com/drzoidberg33/plexpy/master/data/interfaces/default/images/cover.png'
else:
attachment['link'] = poster_url
poster_url = 'https://raw.githubusercontent.com/drzoidberg33/plexpy/master/data/interfaces/default/images/poster.png'
attachment['picture'] = poster_url
attachment['name'] = title
attachment['description'] = subtitle
if metadata['media_type'] == 'movie':
title = '%s (%s)' % (metadata['title'], metadata['year'])
subtitle = metadata['summary']
rating_key = metadata['rating_key']
if metadata.get('imdb_url',''):
poster_link = metadata.get('imdb_url', '')
caption = 'View on IMDB'
elif metadata.get('themoviedb_url',''):
poster_link = metadata.get('themoviedb_url', '')
caption = 'View on The Movie Database'
elif metadata['media_type'] == 'show':
title = '%s (%s)' % (metadata['title'], metadata['year'])
subtitle = metadata['summary']
rating_key = metadata['rating_key']
if metadata.get('thetvdb_url',''):
poster_link = metadata.get('thetvdb_url', '')
caption = 'View on TheTVDB'
elif metadata.get('themoviedb_url',''):
poster_link = metadata.get('themoviedb_url', '')
caption = 'View on The Movie Database'
elif metadata['media_type'] == 'episode':
title = '%s - %s (S%s %s E%s)' % (metadata['grandparent_title'],
metadata['title'],
metadata['parent_media_index'],
'\xc2\xb7'.decode('utf8'),
metadata['media_index'])
subtitle = metadata['summary']
rating_key = metadata['rating_key']
if metadata.get('thetvdb_url',''):
poster_link = metadata.get('thetvdb_url', '')
caption = 'View on TheTVDB'
elif metadata.get('themoviedb_url',''):
poster_link = metadata.get('themoviedb_url', '')
caption = 'View on The Movie Database'
elif metadata['media_type'] == 'artist':
title = metadata['title']
subtitle = metadata['summary']
rating_key = metadata['rating_key']
if metadata.get('lastfm_url',''):
poster_link = metadata.get('lastfm_url', '')
caption = 'View on Last.fm'
elif metadata['media_type'] == 'track':
title = '%s - %s' % (metadata['grandparent_title'], metadata['title'])
subtitle = metadata['parent_title']
rating_key = metadata['parent_rating_key']
if metadata.get('lastfm_url',''):
poster_link = metadata.get('lastfm_url', '')
caption = 'View on Last.fm'
# Build Facebook post attachment
if self.incl_pmslink:
caption = 'View on Plex Web'
attachment['link'] = 'http://app.plex.tv/web/app#!/server/' + plexpy.CONFIG.PMS_IDENTIFIER + \
'/details/%2Flibrary%2Fmetadata%2F' + rating_key
elif poster_link:
attachment['link'] = poster_link
else:
attachment['link'] = poster_url
attachment['picture'] = poster_url
attachment['name'] = title
attachment['description'] = subtitle
attachment['caption'] = caption
try:
api.put_wall_post(profile_id=self.group_id, message=message, attachment=attachment)
@@ -2253,13 +2264,12 @@ class FacebookNotifier(object):
def return_config_options(self):
config_option = [{'label': 'Instructions',
'description': '<strong>Facebook notifications are currently experimental!</strong><br><br> \
Step 1: Visit <a href="' + helpers.anon_url('https://developers.facebook.com/apps') + '" target="_blank"> \
'description': 'Step 1: Visit <a href="' + helpers.anon_url('https://developers.facebook.com/apps') + '" target="_blank"> \
Facebook Developers</a> to add a new app using <strong>basic setup</strong>.<br>\
Step 2: Go to <strong>Settings > Basic</strong> and fill in a \
<strong>Contact Email</strong>.<br>\
Step 3: Go to <strong>Settings > Advanced</strong> and fill in \
<strong>Valid OAuth redirect URIs</strong> with your PlexPy URL (i.e. http://localhost:8181).<br>\
<strong>Valid OAuth redirect URIs</strong> with your PlexPy URL (e.g. http://localhost:8181).<br>\
Step 4: Go to <strong>App Review</strong> and toggle public to <strong>Yes</strong>.<br>\
Step 5: Fill in the <strong>PlexPy URL</strong> below with the exact same URL from Step 3.<br>\
Step 6: Fill in the <strong>App ID</strong> and <strong>App Secret</strong> below.<br>\
@@ -2270,7 +2280,8 @@ class FacebookNotifier(object):
{'label': 'PlexPy URL',
'value': self.redirect_uri,
'name': 'facebook_redirect_uri',
'description': 'Your PlexPy URL. This will tell Facebook where to redirect you after authorization.',
'description': 'Your PlexPy URL. This will tell Facebook where to redirect you after authorization.\
(e.g. http://localhost:8181)',
'input_type': 'text'
},
{'label': 'Facebook App ID',

View File

@@ -1,2 +1,2 @@
PLEXPY_VERSION = "master"
PLEXPY_RELEASE_VERSION = "1.3.10"
PLEXPY_RELEASE_VERSION = "1.3.13"

View File

@@ -124,6 +124,7 @@ def checkGithub():
# Get the latest version available from github
logger.info('Retrieving latest version information from GitHub')
url = 'https://api.github.com/repos/%s/plexpy/commits/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_BRANCH)
if plexpy.CONFIG.GIT_TOKEN: url = url + '?access_token=%s' % plexpy.CONFIG.GIT_TOKEN
version = request.request_json(url, timeout=20, validator=lambda x: type(x) == dict)
if version is None:
@@ -144,6 +145,7 @@ def checkGithub():
logger.info('Comparing currently installed version with latest GitHub version')
url = 'https://api.github.com/repos/%s/plexpy/compare/%s...%s' % (plexpy.CONFIG.GIT_USER, plexpy.LATEST_VERSION, plexpy.CURRENT_VERSION)
if plexpy.CONFIG.GIT_TOKEN: url = url + '?access_token=%s' % plexpy.CONFIG.GIT_TOKEN
commits = request.request_json(url, timeout=20, whitelist_status_code=404, validator=lambda x: type(x) == dict)
if commits is None:

View File

@@ -1145,6 +1145,15 @@ class WebInterface(object):
line))
return True
@cherrypy.expose
def logFile(self):
try:
with open(os.path.join(plexpy.CONFIG.LOG_DIR, 'plexpy.log'), 'r') as f:
return '<pre>%s</pre>' % f.read()
except IOError as e:
return "Log file not found."
##### Settings #####
@cherrypy.expose
@@ -1180,6 +1189,7 @@ class WebInterface(object):
"backup_dir": plexpy.CONFIG.BACKUP_DIR,
"cache_dir": plexpy.CONFIG.CACHE_DIR,
"log_dir": plexpy.CONFIG.LOG_DIR,
"log_blacklist": checked(plexpy.CONFIG.LOG_BLACKLIST),
"check_github": checked(plexpy.CONFIG.CHECK_GITHUB),
"interface_list": interface_list,
"cache_sizemb": plexpy.CONFIG.CACHE_SIZEMB,
@@ -1261,7 +1271,8 @@ class WebInterface(object):
"home_library_cards": json.dumps(plexpy.CONFIG.HOME_LIBRARY_CARDS),
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
"buffer_wait": plexpy.CONFIG.BUFFER_WAIT,
"group_history_tables": checked(plexpy.CONFIG.GROUP_HISTORY_TABLES)
"group_history_tables": checked(plexpy.CONFIG.GROUP_HISTORY_TABLES),
"git_token": plexpy.CONFIG.GIT_TOKEN
}
return serve_template(templatename="settings.html", title="Settings", config=config)
@@ -1281,7 +1292,7 @@ class WebInterface(object):
"ip_logging_enable", "movie_logging_enable", "tv_logging_enable", "music_logging_enable",
"pms_is_remote", "home_stats_type", "group_history_tables", "notify_consecutive", "notify_upload_posters",
"notify_recently_added", "notify_recently_added_grandparent",
"monitor_pms_updates", "monitor_remote_access", "get_file_sizes"
"monitor_pms_updates", "monitor_remote_access", "get_file_sizes", "log_blacklist"
]
for checked_config in checked_configs:
if checked_config not in kwargs:
@@ -1308,7 +1319,8 @@ class WebInterface(object):
refresh_users = False
# If we change any monitoring settings, make sure we reschedule tasks.
if kwargs.get('monitoring_interval') != str(plexpy.CONFIG.MONITORING_INTERVAL) or \
if kwargs.get('check_github') != plexpy.CONFIG.CHECK_GITHUB or \
kwargs.get('monitoring_interval') != str(plexpy.CONFIG.MONITORING_INTERVAL) or \
kwargs.get('refresh_libraries_interval') != str(plexpy.CONFIG.REFRESH_LIBRARIES_INTERVAL) or \
kwargs.get('refresh_users_interval') != str(plexpy.CONFIG.REFRESH_USERS_INTERVAL) or \
kwargs.get('notify_recently_added') != plexpy.CONFIG.NOTIFY_RECENTLY_ADDED or \
@@ -1454,7 +1466,7 @@ class WebInterface(object):
if this_agent:
logger.debug(u"Sending test %s notification." % this_agent['name'])
notifiers.send_notification(this_agent['id'], subject, body, **kwargs)
notifiers.send_notification(this_agent['id'], subject, body, 'test', **kwargs)
return "Notification sent."
else:
logger.debug(u"Unable to send test notification, invalid notification agent ID %s." % agent_id)
@@ -2222,11 +2234,18 @@ class WebInterface(object):
'I need your clothes, your boots and your motorcycle.',
'No, it\'s not a tumor. It\'s not a tumor!',
'I LIED!',
'See you at the party, Richter!',
'Are you Sarah Conner?',
'Are you Sarah Connor?',
'I\'m a cop you idiot!',
'Come with me if you want to live.',
'Who is your daddy and what does he do?'
'Who is your daddy and what does he do?',
'Oh, cookies! I can\'t wait to toss them.',
'Can you hurry up. My horse is getting tired.',
'What killed the dinosaurs? The Ice Age!',
'That\'s for sleeping with my wife!',
'Remember when I said Id kill you last... I lied!',
'You want to be a farmer? Here\'s a couple of acres',
'Now, this is the plan. Get your ass to Mars.',
'I just had a terrible thought... What if this is a dream?'
]
random_number = randint(0, len(quote_list) - 1)
@@ -2248,4 +2267,4 @@ class WebInterface(object):
def check_pms_updater(self):
pms_connect = pmsconnect.PmsConnect()
result = pms_connect.get_update_staus()
return json.dumps(result)
return json.dumps(result)

View File

@@ -46,12 +46,11 @@ def initialize(options):
options_dict = {
'server.socket_port': options['http_port'],
'server.socket_host': options['http_host'],
'environment': options['http_environment'],
'server.thread_pool': 10,
'tools.encode.on': True,
'tools.encode.encoding': 'utf-8',
'tools.decode.on': True,
'log.screen': False,
'engine.autoreload.on': False,
}
if enable_https:
@@ -61,6 +60,10 @@ def initialize(options):
else:
protocol = "http"
if plexpy.DEV:
options_dict['environment'] = "test_suite"
options_dict['engine.autoreload.on'] = True
logger.info("Starting PlexPy web server on %s://%s:%d/", protocol,
options['http_host'], options['http_port'])
cherrypy.config.update(options_dict)
@@ -119,7 +122,12 @@ def initialize(options):
try:
cherrypy.process.servers.check_port(str(options['http_host']), options['http_port'])
cherrypy.server.start()
if not plexpy.DEV:
cherrypy.server.start()
else:
cherrypy.engine.signals.subscribe()
cherrypy.engine.start()
cherrypy.engine.block()
except IOError:
sys.stderr.write('Failed to start on port: %i. Is something else running?\n' % (options['http_port']))
sys.exit(1)