From d8a4c4016ce30c14ef1df4019cdfb7cc89159a20 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 6 Oct 2018 18:16:56 +0200 Subject: rename module and command --- README.md | 2 +- arte/__init__.py | 0 arte/__main__.py | 48 ------------------------------------------------ artetv_dl/__init__.py | 0 artetv_dl/__main__.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 6 +++--- 6 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 arte/__init__.py delete mode 100755 arte/__main__.py create mode 100644 artetv_dl/__init__.py create mode 100755 artetv_dl/__main__.py diff --git a/README.md b/README.md index 4ec32b7..549cedc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ pip install . ## Usage ``` -arte_tv +artetv-dl ``` ## Licence diff --git a/arte/__init__.py b/arte/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/arte/__main__.py b/arte/__main__.py deleted file mode 100755 index a9e30df..0000000 --- a/arte/__main__.py +++ /dev/null @@ -1,48 +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 - -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/artetv_dl/__init__.py b/artetv_dl/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/artetv_dl/__main__.py b/artetv_dl/__main__.py new file mode 100755 index 0000000..d85f5f6 --- /dev/null +++ b/artetv_dl/__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 index 14ef91d..10c67c2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [metadata] -name = arte +name = artetv_dl home-page = https://git.neodarz.net/neodarz/scripts/arte.tv-dl.git summary = Download videos from arte.tv description-file = @@ -22,7 +22,7 @@ classifier = [files] packages = - arte + artetv_dl [extras] devel= @@ -33,7 +33,7 @@ devel= [entry_points] console_scripts = - arte = arte.__main__:main + artetv-dl = artetv_dl.__main__:main [wheel] universal = 1 -- cgit v1.2.1