Skip to content

Commit

Permalink
Last merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ukdtom committed Dec 10, 2017
1 parent 86c6747 commit 5207379
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 188 deletions.
92 changes: 0 additions & 92 deletions Contents/Code/plextvhelper.py
Original file line number Diff line number Diff line change
@@ -1,94 +1,3 @@
<<<<<<< HEAD
######################################################################################################################
# Plex.tv helper unit
#
# Author: dane22, a Plex Community member
#
######################################################################################################################
import sys

from consts import VERSION, PREFIX, NAME

class plexTV(object):
# Defaults used by the rest of the class
def __init__(self):
# Endpoints @ Plex server
self.mainUrl = 'https://plex.tv'
self.loginUrl = self.mainUrl + '/users/sign_in'
self.serverUrl = self.mainUrl + '/pms/servers'
self.resourceURL = self.mainUrl + '/pms/resources.xml'
# Mandentory headers
id = self.get_thisPMSIdentity()
self.myHeader = {}
self.myHeader['X-Plex-Client-Identifier'] = NAME + '-' + id
self.myHeader['Accept'] = 'application/json'
self.myHeader['X-Plex-Product'] = NAME
self.myHeader['X-Plex-Version'] = VERSION
self.myHeader['X-Plex-Platform'] = Platform.OS

# Login to Plex.tv
def login(self, user, pwd):
Log.Info('Start to auth towards plex.tv')
authString = String.Base64Encode('%s:%s' % (user, pwd))
self.myHeader['Authorization'] = 'Basic ' + authString
try:
token = JSON.ObjectFromURL(self.loginUrl + '.json', headers=self.myHeader, method='POST')['user']['authToken']
Log.Info('Authenticated towards plex.tv with success')
return token
except Ex.HTTPError, e:
Log.Exception('Login error: ' + str(e))
return None
except Exception, e:
Log.Exception('Login error: ' + str(e))
return None


''' Is user the owner of the server?
user identified by token
server identified by clientIdentifier
if server found, and user is the owner, return 0
if server is not found, return 1
if user is not the owner, return 2
if unknow error, return -1
'''
def isServerOwner(self, token):
Log.Debug('Checking server for ownership')
try:
# Ident of this server
PMSId = XML.ElementFromURL('http://127.0.0.1:32400/identity').get('machineIdentifier')
# Grap Resource list from plex.tv
self.myHeader['X-Plex-Token'] = token
elements = XML.ElementFromURL(self.resourceURL, headers=self.myHeader).xpath('//Device[@clientIdentifier="' + PMSId + '"]/@owned')
if len(elements) < 1:
Log.Debug('Server %s was not found @ plex.tv' %(PMSId))
return 1
else:
if elements[0] == '1':
Log.Debug('Authenticated ok towards %s' %(PMSId))
return 0
else:
Log.Debug('Server %s was found @ plex.tv, but user is not the owner' %(PMSId))
return 2
except Ex.HTTPError, e:
Log.Exception('Unknown exception was: %s' %(e))
return -1

''' will return the machineIdentity of this server '''
def get_thisPMSIdentity(self):
return XML.ElementFromURL('http://127.0.0.1:32400/identity').get('machineIdentifier')

''' Will return true, if PMS is authenticated towards plex.tv '''
def auth2myPlex(self):
return 'ok' == XML.ElementFromURL('http://127.0.0.1:32400').get('myPlexSigninState')








=======
######################################################################################################################
# Plex.tv helper unit
#
Expand Down Expand Up @@ -255,4 +164,3 @@ def getUserList(self):
return usrList
except Exception, e:
Log.Exception('Fatal error happened in getUserList ' + str(e))
>>>>>>> tommy-work3-pmsV3-partial
6 changes: 1 addition & 5 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<<<<<<< HEAD
2.4.1
=======
3.0.0
>>>>>>> tommy-work3-pmsV3-partial
3.0.0
91 changes: 0 additions & 91 deletions http/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,96 +18,6 @@
<link rel="stylesheet" type="text/css" href="external/css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="external/css/font-awesome.min.css">

<<<<<<< HEAD
if ($('input[name="repeatpwd"]').val() != $('input[name="pwd"]').val()) {
$('#LoginMessage').addClass('bg-danger');
$('#LoginMessage').html('Passwords did not match');
$('#LoginMessage').show();
$('.modal').modal('hide');
return false;
}
}
$.ajax({
url: '/login',
cache: false,
type: 'POST',
global: false,
data: {
user: $('input[name="user"]').val(),
pwd: $('input[name="pwd"]').val()
},
success: function(data) {
$.ajax({
url: '/webtools2',
data: {
'module': 'git',
'function': 'getReleaseInfo',
'url': 'https://github.com/dagalufh/WebTools.bundle',
'version': 'latest'
},
type: 'GET',
datatype: 'JSON',
cache: false,
success: function(data) {
data = JSON.parse(data);
infoarray = [];
debugger;

if (typeof(data.published_at) == 'undefined') {
//infoarray.push('No releases available.');
document.location.href = '/';
} else {

//console.log('version compare: ' + compare(webtools.version, data.name.substring(1)) + ' A: ' + webtools.version + '> B: ' + data.tag_name);
switch (compare(webtools.version, data.tag_name)) {
case 0:
console.log("You are on latest.");
document.location.href = '/';
//infoarray.push('You are on the latest and greatest!');
//$('#myModalFoot').html('<button type="button" class="btn btn-default" onclick="webtools.install_WT();">Re-Install WebTools</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>');
break;
case -1:
document.location.href = '/';
infoarray.push('Currently Installed Version: ' + webtools.version);
infoarray.push('Latest Update: ' + data.published_at);
infoarray.push('Version Name: ' + data.name);
infoarray.push('Author: <a target="_NEW" href="' + data.author.html_url + '">' + data.author.login + '</a>');
infoarray.push('Release Notes: ' + data.body);
infoarray.push('Download url: <a target="_NEW" href="' + data.zipball_url + '">' + data.zipball_url + '</a>');
infoarray.push('You\'ve fallen behind. Time to update to the greatest!');
$('#myModalFoot').html('<button type="button" class="btn btn-default" onclick="document.location.href='/'">Continue with Login</button>');
$('#myModalBody').html(infoarray.join('<br>'));
break;
case 1:
console.log("You are in the future.");
document.location.href = '/';
//infoarray.push('You are ahead of time. Your version is newer than the one on Github.');
//$('#myModalFoot').html('<button type="button" class="btn btn-default" onclick="webtools.install_WT();">Re-Install WebTools</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>');
break;
}
}

},
error: function() {
//console.log("Error while fetching updates.");
//$('#updateinfo').html('An error occured while trying to fetch information from Github. Try again in a little while.');
// After successfull send them back to the regular page.
document.location.href = '/';
}
});


},
error: function(data) {
$('#LoginMessage').addClass('bg-danger');
$('#LoginMessage').html('Incorrect credentials entered. Try again.');
$('#LoginMessage').show();
$('.modal').modal('hide');
}
});
}
</script>
=======
<!--EXTERNAL SCRIPT INIT-->
<script src="external/scripts/jquery-3.1.1.min.js"></script>
<script src="external/scripts/bootstrap.min.js"></script>
Expand All @@ -120,7 +30,6 @@
<!-- No Auth = always WhiteBlue -->
<script src="static/login/login.js"></script>
</head>
>>>>>>> tommy-work3-pmsV3-partial

<body>
<!-- Strings to translate -->
Expand Down

0 comments on commit 5207379

Please sign in to comment.