scripts /

#!/usr/bin/env python2
Delicious CLI

A simple script to easily create bookmarks in Delicious via command line.

It is recommended to put a wrapper like this to ``~/bin/b``::

    python2 ~/src/scripts/ add my-user-name $@

The usage will be as follows::

    $ b -t search,bigbrother
    Added "Google" with tags "search,bigbrother".

Note that you don't have to specify the title. However, if you need to do it
(e.g. in case if the script fails to determine it), you can use the ``--title``
from argh import arg, dispatch_command
import requests
from BeautifulSoup import BeautifulSoup
from pydelicious import DeliciousAPI
from getpass import getpass

@arg('-t', '--tags')
@arg('-d', '--description')
@arg('--private', default=False)
def add_bookmark(args):
    url = args.url
    if not url.startswith('http://'):
        url = 'http://' + url

    if args.title:
        title = args.title
        resp = requests.get(url)
        soup = BeautifulSoup(resp.content)
        title = soup.find('title').text.strip()

    tags = args.tags or 'unsorted'

    api = DeliciousAPI(args.username, getpass('Password:'))
    api.posts_add(url, title, tags=tags, extended=args.description,
                  shared=not args.private)

    print u'Added "{0}" with tags "{1}".'.format(title, tags)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.