Skip to content

Instantly share code, notes, and snippets.

@uchida
Created April 30, 2011 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uchida/950025 to your computer and use it in GitHub Desktop.
Save uchida/950025 to your computer and use it in GitHub Desktop.
bookmark script for newsbeuter
#!/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