mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Proxy PMS downloads json through server
This commit is contained in:
parent
d943877e76
commit
b7937b8740
4 changed files with 27 additions and 23 deletions
|
@ -2934,27 +2934,18 @@ $(document).ready(function() {
|
||||||
var update_channel = update_params.pms_update_channel;
|
var update_channel = update_params.pms_update_channel;
|
||||||
var update_distro = update_params.pms_update_distro;
|
var update_distro = update_params.pms_update_distro;
|
||||||
var update_distro_build = update_params.pms_update_distro_build;
|
var update_distro_build = update_params.pms_update_distro_build;
|
||||||
var plex_update_channel = update_params.plex_update_channel;
|
|
||||||
|
|
||||||
$('#pms_update_channel option[value=beta]').remove();
|
$('#pms_update_channel option[value=beta]').remove();
|
||||||
if (plexpass) {
|
if (plexpass) {
|
||||||
var selected = (update_channel == 'beta') ? true : false;
|
$('#pms_update_channel').append($('<option></option>').text('Beta').val('beta'))
|
||||||
$('#pms_update_channel')
|
|
||||||
.append($('<option></option>')
|
|
||||||
.text('Beta')
|
|
||||||
.val('beta')
|
|
||||||
.prop('selected', selected));
|
|
||||||
}
|
}
|
||||||
|
$('#pms_update_channel option[value=' + update_channel + ']').prop('selected', true);
|
||||||
var download_url = 'https://plex.tv/api/downloads/' + (plex_update_channel === 'plexpass' ? '5' : '1') + '.json?channel=' + plex_update_channel;
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: download_url,
|
url: 'get_pms_downloads',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
data: { update_channel: update_channel },
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
beforeSend: function (xhr) {
|
|
||||||
xhr.setRequestHeader('X-Plex-Token', $('#pms_token').val());
|
|
||||||
},
|
|
||||||
success: function (downloads) {
|
success: function (downloads) {
|
||||||
var platform_downloads = downloads.computer[platform] || downloads.nas[platform];
|
var platform_downloads = downloads.computer[platform] || downloads.nas[platform];
|
||||||
if (platform_downloads) {
|
if (platform_downloads) {
|
||||||
|
|
|
@ -261,7 +261,7 @@ def check_server_updates():
|
||||||
logger.info("Tautulli Monitor :: Checking for PMS updates...")
|
logger.info("Tautulli Monitor :: Checking for PMS updates...")
|
||||||
|
|
||||||
plex_tv = plextv.PlexTV()
|
plex_tv = plextv.PlexTV()
|
||||||
download_info = plex_tv.get_plex_downloads()
|
download_info = plex_tv.get_plex_update()
|
||||||
|
|
||||||
if download_info:
|
if download_info:
|
||||||
logger.info("Tautulli Monitor :: Current PMS version: %s", plexpy.CONFIG.PMS_VERSION)
|
logger.info("Tautulli Monitor :: Current PMS version: %s", plexpy.CONFIG.PMS_VERSION)
|
||||||
|
|
|
@ -754,7 +754,16 @@ class PlexTV(object):
|
||||||
|
|
||||||
return clean_servers
|
return clean_servers
|
||||||
|
|
||||||
def get_plex_downloads(self):
|
def get_plex_downloads(self, update_channel):
|
||||||
|
plex_downloads = self.get_plextv_downloads(plexpass=(update_channel == 'beta'))
|
||||||
|
|
||||||
|
try:
|
||||||
|
return json.loads(plex_downloads)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn("Tautulli PlexTV :: Unable to load JSON for get_plex_updates: %s", e)
|
||||||
|
return {}
|
||||||
|
|
||||||
|
def get_plex_update(self):
|
||||||
logger.debug("Tautulli PlexTV :: Retrieving current server version.")
|
logger.debug("Tautulli PlexTV :: Retrieving current server version.")
|
||||||
|
|
||||||
pms_connect = pmsconnect.PmsConnect()
|
pms_connect = pmsconnect.PmsConnect()
|
||||||
|
@ -763,12 +772,9 @@ class PlexTV(object):
|
||||||
update_channel = pms_connect.get_server_update_channel()
|
update_channel = pms_connect.get_server_update_channel()
|
||||||
|
|
||||||
logger.debug("Tautulli PlexTV :: Plex update channel is %s." % update_channel)
|
logger.debug("Tautulli PlexTV :: Plex update channel is %s." % update_channel)
|
||||||
plex_downloads = self.get_plextv_downloads(plexpass=(update_channel == 'beta'))
|
available_downloads = self.get_plex_downloads(update_channel=update_channel)
|
||||||
|
|
||||||
try:
|
if not available_downloads:
|
||||||
available_downloads = json.loads(plex_downloads)
|
|
||||||
except Exception as e:
|
|
||||||
logger.warn("Tautulli PlexTV :: Unable to load JSON for get_plex_updates.")
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# Get the updates for the platform
|
# Get the updates for the platform
|
||||||
|
|
|
@ -3423,6 +3423,14 @@ class WebInterface(object):
|
||||||
if not response.ok:
|
if not response.ok:
|
||||||
cherrypy.response.status = 401
|
cherrypy.response.status = 401
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
@cherrypy.tools.json_out()
|
||||||
|
@requireAuth(member_of("admin"))
|
||||||
|
def get_pms_downloads(self, update_channel, **kwargs):
|
||||||
|
plex_tv = plextv.PlexTV()
|
||||||
|
downloads = plex_tv.get_plex_downloads(update_channel=update_channel)
|
||||||
|
return downloads
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
|
@ -3471,8 +3479,7 @@ class WebInterface(object):
|
||||||
plexpy.CONFIG.PMS_PLATFORM, plexpy.CONFIG.PMS_PLATFORM),
|
plexpy.CONFIG.PMS_PLATFORM, plexpy.CONFIG.PMS_PLATFORM),
|
||||||
'pms_update_channel': plexpy.CONFIG.PMS_UPDATE_CHANNEL,
|
'pms_update_channel': plexpy.CONFIG.PMS_UPDATE_CHANNEL,
|
||||||
'pms_update_distro': plexpy.CONFIG.PMS_UPDATE_DISTRO,
|
'pms_update_distro': plexpy.CONFIG.PMS_UPDATE_DISTRO,
|
||||||
'pms_update_distro_build': plexpy.CONFIG.PMS_UPDATE_DISTRO_BUILD,
|
'pms_update_distro_build': plexpy.CONFIG.PMS_UPDATE_DISTRO_BUILD}
|
||||||
'plex_update_channel': 'plexpass' if update_channel == 'beta' else 'public'}
|
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
|
@ -6423,7 +6430,7 @@ class WebInterface(object):
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
plex_tv = plextv.PlexTV()
|
plex_tv = plextv.PlexTV()
|
||||||
result = plex_tv.get_plex_downloads()
|
result = plex_tv.get_plex_update()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue