Compare commits

...

21 Commits

Author SHA1 Message Date
JonnyWong16
c8575bbc0f v2.1.21 2018-09-21 18:16:48 -07:00
JonnyWong16
f1b3a6f7b6 Merge pull request #1316 from Arcanemagus/fix_content_rating_type
Fix the type of the Content Rating notification parameter (Fixes Tautulli/Tautulli-Issues#122)
2018-09-19 12:49:31 -07:00
Landon Abney
8a94f6d63a Fix the type of the Content Rating notification parameter
The "Content Rating" notification parameter was incorrectly marked as an
integer, leading to all values being cast to the number 0. This made it
so every single content rating was the same value in conditions.
2018-09-19 12:46:28 -07:00
JonnyWong16
9b8fb73a7a Merge pull request #1312 from samwiseg00/add/init_distro
Add chown instructions per major distros
2018-09-19 08:41:05 -07:00
JonnyWong16
67c333e86e Add X-Plex-Token log filter 2018-09-16 10:24:07 -07:00
JonnyWong16
cfa0b20419 Fix music showing as pre-tautulli in stream info (Fixes Tautulli/Tautulli-Issues#120) 2018-09-16 09:56:32 -07:00
samwiseg00
4b2930c890 Add chown instructions per major distros 2018-09-15 16:54:49 -03:00
JonnyWong16
d98565ea12 Merge pull request #1309 from Sheigutn/refresh-image-patch
Move refresh image button to right div for track results
2018-09-15 10:28:08 -07:00
Florian Böhm
471f7c184a Replace album-item with cover-item
Also add missing quotation mark in artist cover div
2018-09-12 21:52:57 +02:00
Florian Böhm
3d4a5e6547 Move refresh image span to right div 2018-09-12 15:45:49 +02:00
JonnyWong16
382322d5e7 Always format notification subject 2018-09-11 18:08:40 -07:00
JonnyWong16
c0ae25611b Merge pull request #1152 from wilmardo/execute-permission-init-scripts
Adds execute permission to fedora.centos and systemd init-scripts
2018-09-11 17:45:45 -07:00
JonnyWong16
f025533582 Merge pull request #1308 from ldumont/fix_systemd_group
Fix typo in systemd group value
2018-09-10 08:29:49 -07:00
Loïc Dumont
fd28e5183a Fix typo in systemd group value 2018-09-10 07:35:45 +02:00
JonnyWong16
185099f183 Check for alternative reverse proxy headers 2018-09-09 10:57:14 -07:00
JonnyWong16
cd6289046e Fallback directories to data dir 2018-09-08 23:16:14 -07:00
JonnyWong16
955dc795ff Update javascript uuidv4 function 2018-09-06 23:23:55 -07:00
JonnyWong16
1b772e60a9 Add browser warning for IE/Edge 2018-09-06 22:51:01 -07:00
JonnyWong16
c6f4c17a81 Remove polling flag 2018-09-05 17:45:51 -07:00
JonnyWong16
1e68a81fe1 Stop polling if OAuth popup closed 2018-09-05 17:44:04 -07:00
Wilmar
634e003bb7 Adds execute permission to fedora.centos and systemd init-scripts 2017-11-21 01:09:54 +01:00
13 changed files with 181 additions and 71 deletions

View File

@@ -1,5 +1,22 @@
# Changelog
## v2.1.21 (2018-09-21)
* Notifications:
* Fix: Content Rating notification condition always evaluating to True. (Thanks @Arcanemagus)
* Fix: Script arguments not showing substituted values in the notification logs.
* UI:
* New: Unsupported browser warning when using IE or Edge.
* Fix: Misaligned refresh image icon in album search results. (Thanks @Sheigutn)
* Fix: Music history showing as pre-Tautulli in stream info modal.
* Other:
* Fix: Typo in Systemd init script group value. (Thanks @ldumont)
* Fix: Execute permissions in Fedora/CentOS and Systemd init scripts. (Thanks @wilmardo)
* Fix: Systemd init script instructions per Linux distro. (Thanks @samwiseg00)
* Change: Fallback to Tautulli data directory if logs/backup/cache/newsletter directories are not writable.
* Change: Check for alternative reverse proxy headers if X-Forwarded-Host is missing.
## v2.1.20 (2018-09-05)
* No changes.

View File

@@ -4162,4 +4162,16 @@ a[data-tab-destination] {
}
.fa-blank {
visibility: hidden;
}
#browser-warning {
height: 25px;
width: 100%;
background: #cc7b19;
text-align: center;
font-weight: bold;
padding-top: 2px;
position: absolute;
top: 0;
z-index: 9999;
}

View File

@@ -190,12 +190,12 @@ DOCUMENTATION :: END
<li>
<a href="info?rating_key=${child['rating_key']}" id="${child['rating_key']}">
<div class="item-children-poster">
<div class="item-children-poster-face cover-item style="background-image: url(pms_image_proxy?img=${child['thumb']}&width=300&height=300&fallback=cover);"></div>
<div class="item-children-poster-face cover-item" style="background-image: url(pms_image_proxy?img=${child['thumb']}&width=300&height=300&fallback=cover);"></div>
% if _session['user_group'] == 'admin':
<span class="overlay-refresh-image" title="Refresh image"><i class="fa fa-refresh refresh_pms_image"></i></span>
% endif
</div>
<div class="item-children-instance-text-wrapper album-item">
<div class="item-children-instance-text-wrapper cover-item">
<h3 title="${child['title']}">${child['title']}</h3>
</div>
</a>
@@ -219,7 +219,7 @@ DOCUMENTATION :: END
<span class="overlay-refresh-image" title="Refresh image"><i class="fa fa-refresh refresh_pms_image"></i></span>
% endif
</div>
<div class="item-children-instance-text-wrapper album-item">
<div class="item-children-instance-text-wrapper cover-item">
<h3 title="${child['parent_title']}">${child['parent_title']}</h3>
<h3 title="${child['title']}">${child['title']}</h3>
</div>
@@ -246,11 +246,11 @@ DOCUMENTATION :: END
</div>
</div>
</div>
% if _session['user_group'] == 'admin':
<span class="overlay-refresh-image" title="Refresh image"><i class="fa fa-refresh refresh_pms_image"></i></span>
% endif
</div>
% if _session['user_group'] == 'admin':
<span class="overlay-refresh-image" title="Refresh image"><i class="fa fa-refresh refresh_pms_image"></i></span>
% endif
<div class="item-children-instance-text-wrapper album-item">
<div class="item-children-instance-text-wrapper cover-item">
<h3 title="${child['original_title'] or child['grandparent_title']}">${child['original_title'] or child['grandparent_title']}</h3>
<h3 title="${child['title']}">${child['title']}</h3>
<h3 title="${child['parent_title']}" class="text-muted">${child['parent_title']}</h3>

View File

@@ -1,3 +1,29 @@
var p = {
name: 'Unknown',
version: 'Unknown',
os: 'Unknown'
};
if (typeof platform !== 'undefined') {
p.name = platform.name;
p.version = platform.version;
p.os = platform.os.toString();
}
if (['IE', 'Microsoft Edge', 'IE Mobile'].indexOf(p.name) > -1) {
$('body').prepend('<div id="browser-warning"><i class="fa fa-exclamation-circle"></i>&nbsp;' +
'Tautulli does not support Internet Explorer or Microsoft Edge! ' +
'Please use a different browser such as Chrome or Firefox.</div>');
var offset = $('#browser-warning').height();
var navbar = $('.navbar-fixed-top');
if (navbar.length) {
navbar.offset({top: navbar.offset().top + offset});
}
var container = $('.body-container');
if (container.length) {
container.offset({top: container.offset().top + offset});
}
}
function initConfigCheckbox(elem, toggleElem, reverse) {
toggleElem = (toggleElem === undefined) ? null : toggleElem;
reverse = (reverse === undefined) ? false : reverse;
@@ -496,9 +522,10 @@ if (!localStorage.getItem('Tautulli_ClientId')) {
}
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c) {
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
return (c ^ cryptoObj.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
});
}
var x_plex_headers = {
@@ -506,10 +533,10 @@ var x_plex_headers = {
'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
'X-Plex-Platform': p.name,
'X-Plex-Platform-Version': p.version,
'X-Plex-Device': p.os,
'X-Plex-Device-Name': p.name
};
var plex_oauth_window = null;
@@ -568,7 +595,6 @@ getPlexOAuthPin = function () {
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() {
@@ -593,7 +619,8 @@ function PlexOAuth(success, error, pre) {
getPlexOAuthPin().then(function (data) {
const pin = data.pin;
const code = data.code;
var keep_polling = true;
plex_oauth_window.location = 'https://app.plex.tv/auth/#!?clientID=' + x_plex_headers['X-Plex-Client-Identifier'] + '&code=' + code;
(function poll() {
polling = setTimeout(function () {
@@ -603,7 +630,6 @@ function PlexOAuth(success, error, pre) {
headers: x_plex_headers,
success: function (data) {
if (data.authToken){
keep_polling = false;
closePlexOAuthWindow();
if (typeof success === "function") {
success(data.authToken)
@@ -611,14 +637,13 @@ function PlexOAuth(success, error, pre) {
}
},
error: function () {
keep_polling = false;
closePlexOAuthWindow();
if (typeof error === "function") {
error()
}
},
complete: function () {
if (keep_polling){
if (!plex_oauth_window.closed){
poll();
} else {
clearTimeout(polling);

0
init-scripts/init.fedora.centos.service Normal file → Executable file
View File

5
init-scripts/init.systemd Normal file → Executable file
View File

@@ -24,7 +24,8 @@
# - The example settings in this file assume that Tautulli is installed to: /opt/Tautulli
#
# - To create this user and give it ownership of the Tautulli directory:
# sudo adduser --system --no-create-home tautulli
# Ubuntu/Debian: sudo addgroup tautulli && sudo adduser --system --no-create-home tautulli --ingroup tautulli
# CentOS/Fedora: sudo adduser --system --no-create-home tautulli
# sudo chown tautulli:tautulli -R /opt/Tautulli
#
# - Adjust ExecStart= to point to:
@@ -51,7 +52,7 @@ ExecStart=/opt/Tautulli/Tautulli.py --config /opt/Tautulli/config.ini --datadir
GuessMainPID=no
Type=forking
User=tautulli
Group=tautlli
Group=tautulli
[Install]
WantedBy=multi-user.target

View File

@@ -140,21 +140,13 @@ def initialize(config_file):
if not CONFIG.HTTPS_KEY:
CONFIG.HTTPS_KEY = os.path.join(DATA_DIR, 'server.key')
if not CONFIG.LOG_DIR:
CONFIG.LOG_DIR = os.path.join(DATA_DIR, 'logs')
if not os.path.exists(CONFIG.LOG_DIR):
try:
os.makedirs(CONFIG.LOG_DIR)
except OSError:
CONFIG.LOG_DIR = None
if not QUIET:
sys.stderr.write("Unable to create the log directory. " \
"Logging to screen only.\n")
CONFIG.LOG_DIR, log_writable = check_folder_writable(
CONFIG.LOG_DIR, os.path.join(DATA_DIR, 'logs'), 'logs')
if not log_writable and not QUIET:
sys.stderr.write("Unable to create the log directory. Logging to screen only.\n")
# Start the logger, disable console if needed
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR,
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR if log_writable else None,
verbose=VERBOSE)
logger.info(u"Starting Tautulli {}".format(
@@ -177,29 +169,12 @@ def initialize(config_file):
DB_FILE
))
if not CONFIG.BACKUP_DIR:
CONFIG.BACKUP_DIR = os.path.join(DATA_DIR, 'backups')
if not os.path.exists(CONFIG.BACKUP_DIR):
try:
os.makedirs(CONFIG.BACKUP_DIR)
except OSError as e:
logger.error(u"Could not create backup dir '%s': %s" % (CONFIG.BACKUP_DIR, e))
if not CONFIG.CACHE_DIR:
CONFIG.CACHE_DIR = os.path.join(DATA_DIR, 'cache')
if not os.path.exists(CONFIG.CACHE_DIR):
try:
os.makedirs(CONFIG.CACHE_DIR)
except OSError as e:
logger.error(u"Could not create cache dir '%s': %s" % (CONFIG.CACHE_DIR, e))
if not CONFIG.NEWSLETTER_DIR:
CONFIG.NEWSLETTER_DIR = os.path.join(DATA_DIR, 'newsletters')
if not os.path.exists(CONFIG.NEWSLETTER_DIR):
try:
os.makedirs(CONFIG.NEWSLETTER_DIR)
except OSError as e:
logger.error(u"Could not create newsletter dir '%s': %s" % (CONFIG.NEWSLETTER_DIR, e))
CONFIG.BACKUP_DIR, _ = check_folder_writable(
CONFIG.BACKUP_DIR, os.path.join(DATA_DIR, 'backups'), 'backups')
CONFIG.CACHE_DIR, _ = check_folder_writable(
CONFIG.CACHE_DIR, os.path.join(DATA_DIR, 'cache'), 'cache')
CONFIG.NEWSLETTER_DIR, _ = check_folder_writable(
CONFIG.NEWSLETTER_DIR, os.path.join(DATA_DIR, 'newsletters'), 'newsletters')
# Initialize the database
logger.info(u"Checking if the database upgrades are required...")
@@ -1974,3 +1949,29 @@ def analytics_event(category, action, label=None, value=None, **kwargs):
TRACKER.send('event', data)
except Exception as e:
logger.warn(u"Failed to send analytics event for category '%s', action '%s': %s" % (category, action, e))
def check_folder_writable(folder, fallback, name):
if not folder:
folder = fallback
if not os.path.exists(folder):
try:
os.makedirs(folder)
except OSError as e:
logger.error(u"Could not create %s dir '%s': %s" % (name, folder, e))
if folder != fallback:
logger.warn(u"Falling back to %s dir '%s'" % (name, fallback))
return check_folder_writable(None, fallback, name)
else:
return folder, None
if not os.access(folder, os.W_OK):
logger.error(u"Cannot write to %s dir '%s'" % (name, folder))
if folder != fallback:
logger.warn(u"Falling back to %s dir '%s'" % (name, fallback))
return check_folder_writable(None, fallback, name)
else:
return folder, False
return folder, True

View File

@@ -433,7 +433,7 @@ NOTIFICATION_PARAMETERS = [
{'name': 'Updated Date', 'type': 'str', 'value': 'updated_date', 'description': 'The date (in date format) the item was updated on Plex.'},
{'name': 'Last Viewed Date', 'type': 'str', 'value': 'last_viewed_date', 'description': 'The date (in date format) the item was last viewed on Plex.'},
{'name': 'Studio', 'type': 'str', 'value': 'studio', 'description': 'The studio for the item.'},
{'name': 'Content Rating', 'type': 'int', 'value': 'content_rating', 'description': 'The content rating for the item.', 'example': 'e.g. TV-MA, TV-PG, etc.'},
{'name': 'Content Rating', 'type': 'str', 'value': 'content_rating', 'description': 'The content rating for the item.', 'example': 'e.g. TV-MA, TV-PG, etc.'},
{'name': 'Directors', 'type': 'str', 'value': 'directors', 'description': 'A list of directors for the item.'},
{'name': 'Writers', 'type': 'str', 'value': 'writers', 'description': 'A list of writers for the item.'},
{'name': 'Actors', 'type': 'str', 'value': 'actors', 'description': 'A list of actors for the item.'},

View File

@@ -926,7 +926,7 @@ class DataFactory(object):
pre_tautulli = 0
# For backwards compatibility. Pick one new Tautulli key to check and override with old values.
if not item['stream_video_resolution']:
if not item['stream_container']:
item['stream_video_resolution'] = item['video_resolution']
item['stream_container'] = item['transcode_container'] or item['container']
item['stream_video_decision'] = item['video_decision']

View File

@@ -130,6 +130,32 @@ class PublicIPFilter(logging.Filter):
return True
class PlexTokenFilter(logging.Filter):
"""
Log filter for X-Plex-Token
"""
def __init__(self):
pass
def filter(self, record):
try:
tokens = re.findall(r'X-Plex-Token(?:=|%3D)([a-zA-Z0-9]+)', record.msg)
for token in tokens:
record.msg = record.msg.replace(token, 8 * '*' + token[-2:])
args = []
for arg in record.args:
tokens = re.findall(r'X-Plex-Token(?:=|%3D)([a-zA-Z0-9]+)', arg) if isinstance(arg, basestring) else []
for token in tokens:
arg = arg.replace(token, 8 * '*' + token[-2:])
args.append(arg)
record.args = tuple(args)
except:
pass
return True
@contextlib.contextmanager
def listener():
"""
@@ -268,6 +294,7 @@ def initLogger(console=False, log_dir=False, verbose=False):
for handler in logger.handlers + logger_api.handlers + logger_plex_websocket.handlers:
handler.addFilter(BlacklistFilter())
handler.addFilter(PublicIPFilter())
handler.addFilter(PlexTokenFilter())
# Install exception hooks
initHooks()

View File

@@ -1052,7 +1052,16 @@ def build_notify_text(subject='', body='', notify_action=None, parameters=None,
logger.error(u"Tautulli NotificationHandler :: Unable to parse custom script arguments: %s. Using fallback." % e)
script_args = []
elif agent_id == 25:
try:
subject = custom_formatter.format(unicode(subject), **parameters)
except LookupError as e:
logger.error(u"Tautulli NotificationHandler :: Unable to parse parameter %s in notification subject. Using fallback." % e)
subject = unicode(default_subject).format(**parameters)
except Exception as e:
logger.error(u"Tautulli NotificationHandler :: Unable to parse custom notification subject: %s. Using fallback." % e)
subject = unicode(default_subject).format(**parameters)
if agent_id == 25:
if body:
try:
body = json.loads(body)
@@ -1076,15 +1085,6 @@ def build_notify_text(subject='', body='', notify_action=None, parameters=None,
body = ''
else:
try:
subject = custom_formatter.format(unicode(subject), **parameters)
except LookupError as e:
logger.error(u"Tautulli NotificationHandler :: Unable to parse parameter %s in notification subject. Using fallback." % e)
subject = unicode(default_subject).format(**parameters)
except Exception as e:
logger.error(u"Tautulli NotificationHandler :: Unable to parse custom notification subject: %s. Using fallback." % e)
subject = unicode(default_subject).format(**parameters)
try:
body = custom_formatter.format(unicode(body), **parameters)
except LookupError as e:

View File

@@ -1,2 +1,2 @@
PLEXPY_BRANCH = "master"
PLEXPY_RELEASE_VERSION = "v2.1.20"
PLEXPY_RELEASE_VERSION = "v2.1.21"

View File

@@ -67,6 +67,10 @@ def initialize(options):
else:
protocol = "http"
if options['http_proxy']:
# Overwrite cherrypy.tools.proxy with our own proxy handler
cherrypy.tools.proxy = cherrypy.Tool('before_handler', proxy)
if options['http_password']:
login_allowed = ["Tautulli admin (username is '%s')" % options['http_username']]
if plexpy.CONFIG.HTTP_PLEX_ADMIN:
@@ -94,7 +98,7 @@ def initialize(options):
conf = {
'/': {
'tools.staticdir.root': os.path.join(plexpy.PROG_DIR, 'data'),
'tools.proxy.on': options['http_proxy'], # pay attention to X-Forwarded-Proto header
'tools.proxy.on': bool(options['http_proxy']),
'tools.gzip.on': True,
'tools.gzip.mime_types': ['text/html', 'text/plain', 'text/css',
'text/javascript', 'application/json',
@@ -226,3 +230,26 @@ class BaseRedirect(object):
@cherrypy.expose
def index(self):
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
def proxy():
# logger.debug(u"REQUEST URI: %s, HEADER [X-Forwarded-Host]: %s, [X-Host]: %s, [Origin]: %s, [Host]: %s",
# cherrypy.request.wsgi_environ['REQUEST_URI'],
# cherrypy.request.headers.get('X-Forwarded-Host'),
# cherrypy.request.headers.get('X-Host'),
# cherrypy.request.headers.get('Origin'),
# cherrypy.request.headers.get('Host'))
# Change cherrpy.tools.proxy.local header if X-Forwarded-Host header is not present
local = 'X-Forwarded-Host'
if not cherrypy.request.headers.get('X-Forwarded-Host'):
if cherrypy.request.headers.get('X-Host'): # lighttpd
local = 'X-Host'
elif cherrypy.request.headers.get('Origin'): # Squid
local = 'Origin'
elif cherrypy.request.headers.get('Host'): # nginx
local = 'Host'
# logger.debug(u"cherrypy.tools.proxy.local set to [%s]", local)
# Call original cherrypy proxy tool with the new local
cherrypy.lib.cptools.proxy(local=local)