Add bokkmarks to commandline

main
Bob Mottram 2021-03-20 10:43:52 +00:00
parent 01b08104e1
commit a3069d0922
1 changed files with 64 additions and 0 deletions

View File

@ -22,6 +22,8 @@ from person import deactivateAccount
from skills import setSkillLevel from skills import setSkillLevel
from roles import setRole from roles import setRole
from webfinger import webfingerHandle from webfinger import webfingerHandle
from bookmarks import sendBookmarkViaServer
from bookmarks import sendUndoBookmarkViaServer
from posts import c2sBoxJson from posts import c2sBoxJson
from posts import downloadFollowCollection from posts import downloadFollowCollection
from posts import getPublicPostDomains from posts import getPublicPostDomains
@ -417,6 +419,12 @@ parser.add_argument('--favorite', '--like', dest='like', type=str,
default=None, help='Like a url') default=None, help='Like a url')
parser.add_argument('--undolike', '--unlike', dest='undolike', type=str, parser.add_argument('--undolike', '--unlike', dest='undolike', type=str,
default=None, help='Undo a like of a url') 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, parser.add_argument('--sendto', dest='sendto', type=str,
default=None, help='Address to send a post to') default=None, help='Address to send a post to')
parser.add_argument('--attach', dest='attach', type=str, parser.add_argument('--attach', dest='attach', type=str,
@ -1304,6 +1312,62 @@ if args.undolike:
time.sleep(1) time.sleep(1)
sys.exit() 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 args.delete:
if not args.nickname: if not args.nickname:
print('Specify a nickname with the --nickname option') print('Specify a nickname with the --nickname option')