Różnice między wybraną wersją a wersją aktualną.
Nowa wersja | Poprzednia wersja | ||
it:scribd_up [2013/08/07 05:00] naczelnik utworzono |
it:scribd_up [2014/07/10 18:54] (aktualna) naczelnik [Kod] |
||
---|---|---|---|
Linia 1: | Linia 1: | ||
Scribd_up - zbudowany na potrzebie skrypt do szybkiego, prostego wysyłania plików na [[http:// | Scribd_up - zbudowany na potrzebie skrypt do szybkiego, prostego wysyłania plików na [[http:// | ||
====== Użycie ====== | ====== Użycie ====== | ||
- | < | + | < |
+ | |||
+ | positional arguments: | ||
+ | filename | ||
+ | |||
+ | optional arguments: | ||
+ | -h, --help | ||
+ | -c CFG, --config CFG config_file | ||
+ | -p, --public | ||
+ | -s, --shortcode | ||
+ | </ | ||
====== Konfiguracja ====== | ====== Konfiguracja ====== | ||
- | W pliku "$PWD/ | + | Pozyskujemy klucz API z http:// |
+ | * $PWD/ | ||
+ | * $HOME/ | ||
+ | * wskazana przez parametr " | ||
+ | bazując | ||
< | < | ||
[api] | [api] | ||
Linia 19: | Linia 33: | ||
import ConfigParser | import ConfigParser | ||
from os.path import expanduser | from os.path import expanduser | ||
+ | import argparse | ||
+ | |||
+ | parser = argparse.ArgumentParser() | ||
+ | parser.add_argument(" | ||
+ | help=" | ||
+ | parser.add_argument(" | ||
+ | help=" | ||
+ | parser.add_argument(" | ||
+ | help=" | ||
+ | parser.add_argument(' | ||
+ | help=" | ||
+ | args =parser.parse_args() | ||
config = ConfigParser.ConfigParser() | config = ConfigParser.ConfigParser() | ||
- | config.read([' | + | config.read(args.config) |
scribd.config(config.get(' | scribd.config(config.get(' | ||
Linia 27: | Linia 53: | ||
def upload(filename): | def upload(filename): | ||
- | document = user.upload(open(filename, ' | + | |
+ | | ||
document.save() | document.save() | ||
- | return document.get_scribd_url() | + | return document |
def progress(bytes_sent, | def progress(bytes_sent, | ||
print >> stderr, "\r%s of %s (%s%%)" | print >> stderr, "\r%s of %s (%s%%)" | ||
- | if len(argv)<2: | + | for filename in args.filename: |
- | | + | doc = upload(filename) |
- | else: | + | |
- | if len(argv)> | + | att = doc.get_attributes() |
- | | + | text = "[scribd id=%s key=%s mode=scroll]" |
- | url = upload(filename) | + | else: |
- | print " | + | |
- | else: #==2 | + | print " |
- | print " | + | |
</ | </ | ||
~~DISCUSSION~~ | ~~DISCUSSION~~ |