441d3c1220
Adds a daemon for lbrynet. Currently commands are limited the following: download_name(name) resolve_name(name) get_downloads stop This allows other programs to easily interact with lbrynet, such as LBRYURIHandler. LBRYURIHandler can be built with py2app, the resulting plist file must be edited in the same way the committed plist file has been edited. When built and installed to the /Applications folder lbry:// domain names will download and open the corresponding file so long as the daemon is running.
22 lines
No EOL
570 B
Python
22 lines
No EOL
570 B
Python
import os
|
|
import webbrowser
|
|
import xmlrpclib, sys
|
|
|
|
|
|
def main(args):
|
|
if len(args) == 0:
|
|
args.append('lbry://economicsman')
|
|
|
|
daemon = xmlrpclib.ServerProxy('http://localhost:7080/')
|
|
|
|
if len(args) > 1:
|
|
print 'Too many args', args
|
|
else:
|
|
resolved = daemon.resolve_name(str(args[0])[7:])
|
|
daemon.download_name(str(args[0])[7:])
|
|
path = [h for h in daemon.get_downloads() if h['stream_hash'] == resolved['stream_hash']][0]['path']
|
|
webbrowser.open('file://' + path)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv[1:]) |