From a3069d0922475875d82222815a5985a5c4291688 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 20 Mar 2021 10:43:52 +0000 Subject: [PATCH] Add bokkmarks to commandline --- epicyon.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/epicyon.py b/epicyon.py index 4e3971f24..5b2d3fc97 100644 --- a/epicyon.py +++ b/epicyon.py @@ -22,6 +22,8 @@ from person import deactivateAccount from skills import setSkillLevel from roles import setRole from webfinger import webfingerHandle +from bookmarks import sendBookmarkViaServer +from bookmarks import sendUndoBookmarkViaServer from posts import c2sBoxJson from posts import downloadFollowCollection from posts import getPublicPostDomains @@ -417,6 +419,12 @@ parser.add_argument('--favorite', '--like', dest='like', type=str, default=None, help='Like a url') parser.add_argument('--undolike', '--unlike', dest='undolike', type=str, default=None, help='Undo a like of a url') +parser.add_argument('--bookmark', '--bm', dest='bookmark', type=str, + default=None, + help='Bookmark the url of a post') +parser.add_argument('--unbookmark', '--unbm', dest='unbookmark', type=str, + default=None, + help='Undo a bookmark given the url of a post') parser.add_argument('--sendto', dest='sendto', type=str, default=None, help='Address to send a post to') parser.add_argument('--attach', dest='attach', type=str, @@ -1304,6 +1312,62 @@ if args.undolike: time.sleep(1) sys.exit() +if args.bookmark: + if not args.nickname: + print('Specify a nickname with the --nickname option') + sys.exit() + + if not args.password: + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') + + session = createSession(proxyType) + personCache = {} + cachedWebfingers = {} + print('Sending bookmark of ' + args.bookmark) + + sendBookmarkViaServer(baseDir, session, + args.nickname, args.password, + domain, port, + httpPrefix, args.bookmark, + cachedWebfingers, personCache, + True, __version__) + for i in range(10): + # TODO detect send success/fail + time.sleep(1) + sys.exit() + +if args.unbookmark: + if not args.nickname: + print('Specify a nickname with the --nickname option') + sys.exit() + + if not args.password: + args.password = getpass.getpass('Password: ') + if not args.password: + print('Specify a password with the --password option') + sys.exit() + args.password = args.password.replace('\n', '') + + session = createSession(proxyType) + personCache = {} + cachedWebfingers = {} + print('Sending undo bookmark of ' + args.unbookmark) + + sendUndoBookmarkViaServer(baseDir, session, + args.nickname, args.password, + domain, port, + httpPrefix, args.unbookmark, + cachedWebfingers, personCache, + True, __version__) + for i in range(10): + # TODO detect send success/fail + time.sleep(1) + sys.exit() + if args.delete: if not args.nickname: print('Specify a nickname with the --nickname option')