diff --git a/README.md b/README.md
index 74c1d1f..045ec10 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# slideslurp
Give slideslurp a URL to a [SlideShare](https://www.slideshare.net/)
-presentation and it will give you a PDF called `out.pdf`.
+presentation and it will render it as a PDF.
I will clean this up, I promise.
@@ -11,5 +11,21 @@ I will clean this up, I promise.
pip install slideslurp
```
+## Usage
+
+```
+usage: slideslurp [-h] [--output OUTPUT] url
+
+Generate PDFs from Slideshare presentations
+
+positional arguments:
+ url the URL to slurp
+
+optional arguments:
+ -h, --help show this help message and exit
+ --output OUTPUT, -o OUTPUT
+ the file to write to (default: out.pdf)
+```
+
Happy slurping!
diff --git a/setup.py b/setup.py
index 72fad80..3fa0075 100644
--- a/setup.py
+++ b/setup.py
@@ -6,13 +6,13 @@ from setuptools import setup
setup(
name = 'slideslurp',
- version = '0.0.3',
+ version = '0.0.4',
description = 'SlideShare to PDF',
author = 'Veit Heller',
author_email = 'veit@veitheller.de',
license = 'MIT License',
url = 'https://github.com/hellerve/slideslurp',
- download_url = 'https://github.com/hellerve/slideslurp/tarball/0.0.3',
+ download_url = 'https://github.com/hellerve/slideslurp/tarball/0.0.4',
packages = find_packages('.'),
install_requires=[
"bs4",
diff --git a/slideslurp/__init__.py b/slideslurp/__init__.py
index ce83fc6..04638c9 100644
--- a/slideslurp/__init__.py
+++ b/slideslurp/__init__.py
@@ -1,3 +1,4 @@
+import argparse
import sys
import bs4
@@ -6,16 +7,25 @@ import requests
from reportlab.pdfgen import canvas
-def main():
- if not len(sys.argv) == 2:
- print("Usage: slideslurp ")
- sys.exit(1)
- url = sys.argv[1]
+def parse_args():
+ descr = "Generate PDFs from Slideshare presentations"
- res = requests.get(url)
+ parser = argparse.ArgumentParser(description=descr)
+ parser.add_argument('url', metavar='url', nargs=1,
+ help='the URL to slurp')
+ parser.add_argument('--output', '-o', default='out.pdf',
+ help='the file to write to (default: out.pdf)')
+
+ return parser.parse_args()
+
+
+def main():
+ args = parse_args()
+
+ res = requests.get(args.url)
tree = bs4.BeautifulSoup(res.text, "html.parser")
- c = canvas.Canvas('out.pdf')
+ c = canvas.Canvas(args.file)
for img in tree.findAll("img", class_="slide_image"):
img_url = img.attrs["data-full"]