From 9745989d7c25c7582885b43d07123fcf1f02bd39 Mon Sep 17 00:00:00 2001 From: NeodarZ Date: Sat, 14 Apr 2018 18:38:25 +0200 Subject: Initial commit --- README.md | 22 ++++++++++++++++++++++ arte.tv-dl.py | 43 +++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 66 insertions(+) create mode 100644 README.md create mode 100755 arte.tv-dl.py create mode 100644 requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..21ccef3 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# arte.tv-dl.sh + +This little script can download a video from arte.tv website. + +## Installation + +Juste run the following command for install requirements on your system: + +``` +pip install -r requirements.txt +``` + +## Usage + +``` +./arte.tv-dl.sh +``` + +## Licence + +All code in this repository are written by neodarz and +under GPL-3 licence. diff --git a/arte.tv-dl.py b/arte.tv-dl.py new file mode 100755 index 0000000..bc61bdf --- /dev/null +++ b/arte.tv-dl.py @@ -0,0 +1,43 @@ +#!/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/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cd91942 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +beautifulsoup4==4.6.0 -- cgit v1.2.1