From 440f1a26ef243f83f1bb2ce43d3e0e7835cf1c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Thu, 4 Oct 2018 23:51:54 +0200 Subject: Introduce python packaging --- README.md | 5 +++-- arte.tv-dl.py | 43 ------------------------------------------- arte/__init__.py | 0 arte/__main__.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 39 +++++++++++++++++++++++++++++++++++++++ setup.py | 7 +++++++ 6 files changed, 97 insertions(+), 45 deletions(-) delete mode 100755 arte.tv-dl.py create mode 100644 arte/__init__.py create mode 100755 arte/__main__.py create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/README.md b/README.md index 21ccef3..4ec32b7 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,14 @@ This little script can download a video from arte.tv website. Juste run the following command for install requirements on your system: ``` -pip install -r requirements.txt +pip install pbr +pip install . ``` ## Usage ``` -./arte.tv-dl.sh +arte_tv ``` ## Licence diff --git a/arte.tv-dl.py b/arte.tv-dl.py deleted file mode 100755 index bc61bdf..0000000 --- a/arte.tv-dl.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/python - -"""A download a video from arte.tv website.""" - -from bs4 import BeautifulSoup -from urllib.request import urlopen, unquote, urlretrieve -import re, json, sys - -if len(sys.argv) != 2: - print("Usage:") - print(" "+sys.argv[0]+" ") - print("Example:") - print(" "+sys.argv[0]+" https://www.arte.tv/fr/videos/051868-000-A/liberte-egalite-indemnites-vers-un-revenu-universel/") - sys.exit(0) - -url = sys.argv[1] - -content = urlopen(url) - -soup = BeautifulSoup(content, "lxml") - -iframes = soup.find_all("iframe") - -url = "" - -for iframe in iframes: - url = unquote(iframe['src']) - -url = re.split("url=",url)[1] -url = re.split("\?autostart", url)[0] - -content = urlopen(url) -json = json.loads(content.read().decode()) -name = json['videoJsonPlayer']['VTI'] -url = json['videoJsonPlayer']['VSR']['HTTPS_SQ_1']['url'] - -name=name+".mp4" -try: - print("Downloading '"+name+"'...") - urlretrieve(url, name) - print("\nDownload completed") -except Exception as e: - print(e) diff --git a/arte/__init__.py b/arte/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/arte/__main__.py b/arte/__main__.py new file mode 100755 index 0000000..a9e30df --- /dev/null +++ b/arte/__main__.py @@ -0,0 +1,48 @@ +#!/bin/python + +"""A download a video from arte.tv website.""" + +from bs4 import BeautifulSoup +from urllib.request import urlopen, unquote, urlretrieve +import re, json, sys + +def main(): + if len(sys.argv) != 2: + print("Usage:") + print(" "+sys.argv[0]+" ") + print("Example:") + print(" "+sys.argv[0]+" https://www.arte.tv/fr/videos/051868-000-A/liberte-egalite-indemnites-vers-un-revenu-universel/") + sys.exit(0) + + url = sys.argv[1] + + content = urlopen(url) + + soup = BeautifulSoup(content, "lxml") + + iframes = soup.find_all("iframe") + + url = "" + + for iframe in iframes: + url = unquote(iframe['src']) + + url = re.split("url=",url)[1] + url = re.split("\?autostart", url)[0] + + content = urlopen(url) + json = json.loads(content.read().decode()) + name = json['videoJsonPlayer']['VTI'] + url = json['videoJsonPlayer']['VSR']['HTTPS_SQ_1']['url'] + + name=name+".mp4" + try: + print("Downloading '"+name+"'...") + urlretrieve(url, name) + print("\nDownload completed") + except Exception as e: + print(e) + + +if __name__ == "__main__": + main() diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..14ef91d --- /dev/null +++ b/setup.cfg @@ -0,0 +1,39 @@ +[metadata] +name = arte +home-page = https://git.neodarz.net/neodarz/scripts/arte.tv-dl.git +summary = Download videos from arte.tv +description-file = + README.md +author = NeodarZ +author-email = neodarz@neodarz.net +licence = GPL3 +classifier = + Development Status :: 5 - Production/Stable + Intended Audience :: Information Technology + License :: OSI Approved :: GNU General Public License v3 (GPLv3) + Operating System :: POSIX + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 + +[files] +packages = + arte + +[extras] +devel= + fixtures + pbr + tox + bandit + +[entry_points] +console_scripts = + arte = arte.__main__:main + +[wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..78c57ea --- /dev/null +++ b/setup.py @@ -0,0 +1,7 @@ +from setuptools import setup + +setup( + requires=['pbd'], + pbr=True, + long_description_content_type="text/markdown", +) -- cgit v1.2.1