Scribd_up - zbudowany na potrzebie skrypt do szybkiego, prostego wysyłania plików na Scribd.com, który pozwala łatwo, szybko i przyjemnie dzielić się plikami PDF.
usage: scribd_up [-h] [-c CFG] [-p] [-s] filename [filename ...] positional arguments: filename Files to upload optional arguments: -h, --help show this help message and exit -c CFG, --config CFG config_file -p, --public Make docs public -s, --shortcode Output as shortcode
Pozyskujemy klucz API z http://pl.scribd.com/account-settings/api , a następnie tworzymy plik konfiguracyjny zapisując go w jednej z ścieżek:
bazując na wzorze
[api] key=XXXX secret=XXXX [user] login=adobrawy pass=XXXX
#!/usr/bin/python import scribd from sys import argv,stderr import ConfigParser from os.path import expanduser import argparse parser = argparse.ArgumentParser() parser.add_argument("-c", "--config", metavar="CFG", help="config_file", default=['scribd_up.cfg', expanduser('~/.config/scribd_up.cfg')]) parser.add_argument("-p", "--public", action="store_true", default=False, help="Make docs public",) parser.add_argument("-s","--shortcode", action="store_true",default=False, help="Output as shortcode",) parser.add_argument('filename', type=file, nargs='+', help="Files to upload") args =parser.parse_args() config = ConfigParser.ConfigParser() config.read(args.config) scribd.config(config.get('api','key'),config.get('api','secret')) user = scribd.login(config.get('user','login'), config.get('user','pass')) def upload(filename): access = "public" if args.public else "private" document = user.upload(filename, access=access,progress_callback=progress) document.save() return document def progress(bytes_sent, bytes_total): print >> stderr, "\r%s of %s (%s%%)" % (bytes_sent, bytes_total, bytes_sent*100/bytes_total), for filename in args.filename: doc = upload(filename) if args.shortcode: att = doc.get_attributes() text = "[scribd id=%s key=%s mode=scroll]" % (att['doc_id'],att['access_key']) else: text = doc.get_scribd_url() print "\r",filename.name, text
~~DISCUSSION~~