aboutsummaryrefslogtreecommitdiff
path: root/artetv_dl
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-10-06 18:16:56 +0200
committerneodarz <neodarz@neodarz.net>2018-10-06 18:16:56 +0200
commitd8a4c4016ce30c14ef1df4019cdfb7cc89159a20 (patch)
treea444e2d72a7d77677e2d3d4a925d95f82ec4d414 /artetv_dl
parent440f1a26ef243f83f1bb2ce43d3e0e7835cf1c1a (diff)
downloadarte.tv-dl-d8a4c4016ce30c14ef1df4019cdfb7cc89159a20.tar.xz
arte.tv-dl-d8a4c4016ce30c14ef1df4019cdfb7cc89159a20.zip
rename module and command
Diffstat (limited to 'artetv_dl')
-rw-r--r--artetv_dl/__init__.py0
-rwxr-xr-xartetv_dl/__main__.py48
2 files changed, 48 insertions, 0 deletions
diff --git a/artetv_dl/__init__.py b/artetv_dl/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/artetv_dl/__init__.py
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]+" <arte.tv_link>")
+ 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()