Created
April 30, 2011 21:50
-
-
Save uchida/950025 to your computer and use it in GitHub Desktop.
bookmark script for newsbeuter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# bookmark script for newsbeuter | |
# by Akihiro Uchida, CC0 dedicated to the public domain | |
# see http://creativecommons.org/publicdomain/zero/1.0/ | |
import sys | |
import os.path | |
import cPickle as pickle | |
BOOKMARK = os.path.expanduser('~/newsbeuter/bookmark.pkl') | |
def add_bookmark(item): | |
bookmark_items = [] | |
if os.path.exists(BOOKMARK): | |
f = open(BOOKMARK, 'rb') | |
bookmark_items.extend(pickle.load(f)) | |
f.close() | |
bookmark_items.append(item) | |
f = open(BOOKMARK, 'wb') | |
pickle.dump(bookmark_items, f) | |
f.close() | |
return | |
if __name__ == '__main__': | |
keys = ('url', 'title', 'desc') | |
args = [s.decode('utf-8') for s in sys.argv[1:]] | |
item = dict(zip(keys, args)) | |
item.setdefault('desc', '') | |
if item['url'] != '': | |
add_bookmark(item) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment