2016-01-12 18:42:32 +01:00
|
|
|
import os
|
|
|
|
import json
|
2015-12-06 23:32:17 +01:00
|
|
|
import webbrowser
|
|
|
|
import xmlrpclib, sys
|
|
|
|
|
2016-01-17 05:06:24 +01:00
|
|
|
|
2016-01-12 18:42:32 +01:00
|
|
|
def render_video(path):
|
2016-01-17 05:06:24 +01:00
|
|
|
r = r'<center><video src="' + path + r'" controls autoplay width="960" height="720"></center>'
|
2016-01-12 18:42:32 +01:00
|
|
|
return r
|
2015-12-06 23:32:17 +01:00
|
|
|
|
2016-01-17 05:06:24 +01:00
|
|
|
|
2015-12-06 23:32:17 +01:00
|
|
|
def main(args):
|
|
|
|
if len(args) == 0:
|
2015-12-10 05:59:19 +01:00
|
|
|
args.append('lbry://wonderfullife')
|
2015-12-06 23:32:17 +01:00
|
|
|
|
|
|
|
daemon = xmlrpclib.ServerProxy('http://localhost:7080/')
|
|
|
|
|
2016-01-22 15:44:38 +01:00
|
|
|
try:
|
|
|
|
b = daemon.get_balance()
|
|
|
|
is_running = True
|
|
|
|
except:
|
|
|
|
webbrowser.open('http://lbry.io/get')
|
|
|
|
is_running = False
|
|
|
|
|
2015-12-06 23:32:17 +01:00
|
|
|
if len(args) > 1:
|
|
|
|
print 'Too many args', args
|
2015-12-10 05:57:58 +01:00
|
|
|
|
2016-01-22 15:44:38 +01:00
|
|
|
elif is_running:
|
2016-01-17 05:06:24 +01:00
|
|
|
if args[0][7:] == 'lbry':
|
|
|
|
daemon.render_gui()
|
|
|
|
|
|
|
|
elif args[0][7:] == 'settings':
|
|
|
|
r = daemon.get_settings()
|
|
|
|
html = "<body>" + json.dumps(r) + "</body>"
|
|
|
|
r = daemon.render_html(html)
|
|
|
|
|
|
|
|
else:
|
2016-01-12 18:42:32 +01:00
|
|
|
r = daemon.get(args[0][7:])
|
|
|
|
print r
|
|
|
|
path = r['path']
|
|
|
|
if path[0] != '/':
|
|
|
|
path = '/' + path
|
|
|
|
|
|
|
|
print path
|
|
|
|
filename = path.split('/')[len(path.split('/')) - 1]
|
|
|
|
extension = path.split('.')[len(path.split('.')) - 1]
|
|
|
|
|
|
|
|
if extension in ['mp4', 'flv', 'mov']:
|
2016-01-17 05:06:24 +01:00
|
|
|
html = render_video(path)
|
|
|
|
daemon.render_html(html)
|
2016-01-12 18:42:32 +01:00
|
|
|
|
|
|
|
else:
|
2016-01-17 05:06:24 +01:00
|
|
|
webbrowser.open('file://' + str(path))
|
|
|
|
|
2015-12-06 23:32:17 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main(sys.argv[1:])
|