Merge v2.0.28 into v2-newsletters

This commit is contained in:
JonnyWong16 2018-04-02 14:33:52 -07:00
commit 5ef8947532
20 changed files with 171 additions and 67 deletions

View file

@ -175,6 +175,16 @@ HW_ENCODERS = [
'nvenc'
]
EXTRA_TYPES = {
'1': 'Trailer',
'2': 'Deleted Scene',
'3': 'Interview',
'5': 'Behind the Scenes',
'6': 'Scene',
'10': 'Featurette',
'11': 'Short'
}
SCHEDULER_LIST = [
'Check GitHub for updates',
'Check for server response',

View file

@ -209,6 +209,7 @@ _CONFIG_DEFINITIONS = {
'HOME_STATS_CARDS': (list, 'General', ['top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', \
'popular_music', 'last_watched', 'top_users', 'top_platforms', 'most_concurrent']),
'HOME_STATS_RECENTLY_ADDED_COUNT': (int, 'General', 50),
'HOME_REFRESH_INTERVAL': (int, 'General', 10),
'HTTPS_CREATE_CERT': (int, 'General', 1),
'HTTPS_CERT': (str, 'General', ''),
'HTTPS_CERT_CHAIN': (str, 'General', ''),

View file

@ -3321,10 +3321,17 @@ class TELEGRAM(Notifier):
if poster_content:
poster_filename = 'poster_{}.png'.format(pretty_metadata.parameters['rating_key'])
files = {'photo': (poster_filename, poster_content, 'image/png')}
data['caption'] = text
return self.make_request('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']),
data=data, files=files)
if len(text) > 200:
data['disable_notification'] = True
else:
data['caption'] = text
r = self.make_request('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']),
data=data, files=files)
if not data.pop('disable_notification', None):
return r
data['text'] = text

View file

@ -1133,7 +1133,9 @@ class PmsConnect(object):
'genres': genres,
'labels': labels,
'collections': collections,
'full_title': helpers.get_xml_attr(metadata_main, 'title')
'full_title': helpers.get_xml_attr(metadata_main, 'title'),
'extra_type': helpers.get_xml_attr(metadata_main, 'extraType'),
'sub_type': helpers.get_xml_attr(metadata_main, 'subtype')
}
else:
@ -1724,7 +1726,9 @@ class PmsConnect(object):
'audio_channel_layout': common.AUDIO_CHANNELS.get(audio_channels, audio_channels),
'channel_icon': helpers.get_xml_attr(session, 'sourceIcon'),
'channel_title': helpers.get_xml_attr(session, 'sourceTitle'),
'live': int(helpers.get_xml_attr(session, 'live') == '1')
'live': int(helpers.get_xml_attr(session, 'live') == '1'),
'extra_type': helpers.get_xml_attr(session, 'extraType'),
'sub_type': helpers.get_xml_attr(session, 'subtype')
}
else:
channel_stream = 0

View file

@ -1,2 +1,2 @@
PLEXPY_BRANCH = "master"
PLEXPY_RELEASE_VERSION = "v2.0.25"
PLEXPY_RELEASE_VERSION = "v2.0.28"

View file

@ -27,6 +27,8 @@ from hashing_passwords import make_hash
from mako.lookup import TemplateLookup
from mako import exceptions
import websocket
import plexpy
import activity_pinger
import common
@ -173,6 +175,7 @@ class WebInterface(object):
"home_stats_type": plexpy.CONFIG.HOME_STATS_TYPE,
"home_stats_count": plexpy.CONFIG.HOME_STATS_COUNT,
"home_stats_recently_added_count": plexpy.CONFIG.HOME_STATS_RECENTLY_ADDED_COUNT,
"home_refresh_interval": plexpy.CONFIG.HOME_REFRESH_INTERVAL,
"pms_name": plexpy.CONFIG.PMS_NAME,
"pms_is_cloud": plexpy.CONFIG.PMS_IS_CLOUD,
"update_show_changelog": plexpy.CONFIG.UPDATE_SHOW_CHANGELOG
@ -2730,6 +2733,7 @@ class WebInterface(object):
"home_sections": json.dumps(plexpy.CONFIG.HOME_SECTIONS),
"home_stats_cards": json.dumps(plexpy.CONFIG.HOME_STATS_CARDS),
"home_library_cards": json.dumps(plexpy.CONFIG.HOME_LIBRARY_CARDS),
"home_refresh_interval": plexpy.CONFIG.HOME_REFRESH_INTERVAL,
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
"buffer_wait": plexpy.CONFIG.BUFFER_WAIT,
"group_history_tables": checked(plexpy.CONFIG.GROUP_HISTORY_TABLES),
@ -3556,7 +3560,7 @@ class WebInterface(object):
@requireAuth(member_of("admin"))
@addtoapi()
def get_server_id(self, hostname=None, port=None, identifier=None, ssl=0, remote=0, manual=0,
get_url=False, **kwargs):
get_url=False, test_websocket=False, **kwargs):
""" Get the PMS server identifier.
```
@ -3612,6 +3616,23 @@ class WebInterface(object):
pms_url_manual=manual,
pms_identifier=identifier)
result['url'] = server['pms_url']
result['ws'] = None
if test_websocket == 'true':
# Quick test websocket connection
ws_url = result['url'].replace('http', 'ws', 1) + '/:/websockets/notifications'
header = ['X-Plex-Token: %s' % plexpy.CONFIG.PMS_TOKEN]
logger.debug("Testing websocket connection...")
try:
test_ws = websocket.create_connection(ws_url, header=header)
test_ws.close()
logger.debug("Websocket connection test successful.")
result['ws'] = True
except (websocket.WebSocketException, IOError, Exception) as e:
logger.error("Websocket connection test failed: %s" % e)
result['ws'] = False
return result
else:
logger.warn('Unable to retrieve the PMS identifier.')
@ -3790,6 +3811,9 @@ class WebInterface(object):
@cherrypy.expose
@requireAuth()
def info(self, rating_key=None, source=None, query=None, **kwargs):
if rating_key and not str(rating_key).isdigit():
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
metadata = None
config = {