-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwistia-video-downloader.py
66 lines (52 loc) · 1.57 KB
/
wistia-video-downloader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import urllib, json
import requests
import io
from csv import DictReader
import time
import argparse
from termcolor import colored
import ffmpeg
by = colored("Created by: Mohamed Yaser","blue")
text = """Get multiple wvideoid from text/csv file and download all the videos (format 720p or 1080p)\n"""+str(by)
parser = argparse.ArgumentParser(description=text)
#parser = argparse.ArgumentParser(description=)
parser.add_argument("file", type=str, help="set file text/csv file location")
args = parser.parse_args()
with open(args.file) as f:
link = [row["id"] for row in DictReader(f)]
download1 =[]
a = 0
b = 0
video_name = []
a1 = []
b1 =[]
video_namecheck =[]
for i in link:
ts_rem = "https://fast.wistia.com/embed/medias/"+str(i)+".json"
b1.append(ts_rem)
for b1 in b1:
with urllib.request.urlopen(b1) as url:
data = json.loads(url.read().decode())
if data['media']['assets']['ext' == "mp4"]:
a1.append(data['media']['assets']['height' == "1080" or 'height' == "720"]['url'])
video_name.append(data['media']['name'])
print("Current Total links:",len(a1))
format = ".mp4"
for i in video_name:
if format in i:
video_namecheck.append(i)
else:
i += ".mp4"
video_namecheck.append(i)
b = 1
for i, j in zip(a1, video_namecheck):
print("Downloading file "+str(b)+": "+str(b)+"_"+str(j))
(
ffmpeg
.input(str(i))
.output(str(b)+"_"+str(j), vcodec='copy', **{'loglevel': "panic"})
.run()
)
time.sleep(2)
b +=1
print("Download Complete, total links:",len(a1))