update uri handler for change in daemon output

This commit is contained in:
Jack 2016-03-29 17:04:01 -04:00
parent b3465f3bbf
commit a7fb434f9f

View file

@ -28,7 +28,7 @@ class LBRYURIHandler(object):
def check_status(self): def check_status(self):
status = None status = None
try: try:
status = json.loads(self.daemon.is_running())['result'] status = self.daemon.is_running()
if self.start_timeout < 30 and not status: if self.start_timeout < 30 and not status:
sleep(1) sleep(1)
self.start_timeout += 1 self.start_timeout += 1
@ -49,7 +49,7 @@ class LBRYURIHandler(object):
lbry_process = [d for d in subprocess.Popen(['ps','aux'], stdout=subprocess.PIPE).stdout.readlines() lbry_process = [d for d in subprocess.Popen(['ps','aux'], stdout=subprocess.PIPE).stdout.readlines()
if 'LBRY.app' in d and 'LBRYURIHandler' not in d] if 'LBRY.app' in d and 'LBRYURIHandler' not in d]
try: try:
status = json.loads(self.daemon.is_running())['result'] status = self.daemon.is_running()
except: except:
status = None status = None
@ -64,17 +64,7 @@ class LBRYURIHandler(object):
if lbry_name == "lbry" or lbry_name == "" and not started: if lbry_name == "lbry" or lbry_name == "" and not started:
webbrowser.get('safari').open(UI_ADDRESS) webbrowser.get('safari').open(UI_ADDRESS)
else: else:
r = json.loads(self.daemon.get({'name': lbry_name})) webbrowser.get('safari').open(UI_ADDRESS + "/view?name=" + lbry_name)
if r['code'] == 200:
path = r['result']['path'].encode('utf-8')
extension = os.path.splitext(path)[1]
if extension in ['mp4', 'flv', 'mov', 'ogv']:
webbrowser.get('safari').open(UI_ADDRESS + "/view?name=" + lbry_name)
else:
webbrowser.get('safari').open('file://' + path)
else:
webbrowser.get('safari').open('http://lbry.io/get')
def main(args): def main(args):
if len(args) != 1: if len(args) != 1: