-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathytdownload.py
68 lines (65 loc) · 2.25 KB
/
ytdownload.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
66
67
68
"""import fetchLink
from pytube import YouTube
from conf import SAMPLE_INPUTS,SAMPLE_OUTPUTS,SAMPLES
from moviepy.editor import *
import os
import glob
import re,wget
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
os.chdir(SAMPLE_INPUTS)
def downloader(word):
word = list(word.split(" "))
for w in word:
link=fetchLink.getLink(w)
#print("*****************************",link,"******************************")
if link==0:
clips = [None]*len(w)
for i,l in enumerate(w):
filename= l+".mp4"
os.chdir(SAMPLES)
filepath = os.path.join("alphabets", filename)
#print(filepath)
clip= VideoFileClip(filepath)
clips[i]=clip
clip = concatenate_videoclips(clips,method='compose')
os.chdir(SAMPLE_INPUTS)
filename= w+".mp4"
clip.write_videofile(filename)
elif re.match('^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+$',link):
clip = YouTube(link)
clip.streams.first().download()
else:
wget.download(link,out=SAMPLE_INPUTS)
"""
import fetchLink
from pytube import YouTube
from conf import SAMPLE_INPUTS,SAMPLE_OUTPUTS
from moviepy.editor import *
import os
import re,wget
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
os.chdir(SAMPLE_INPUTS)
def downloader(word):
word = list(word.split(" "))
for w in word:
link=fetchLink.getLink(w)
print("**********",link,"***********")
if link==0:
clips = [None]*len(w)
for i,l in enumerate(w):
filename= l+".mp4"
filepath = os.path.join("alphabets", filename)
print(filepath)
clip= VideoFileClip(filepath)
clips[i]=clip
clip = concatenate_videoclips(clips,method='compose')
os.chdir(SAMPLE_INPUTS)
filename= w+".mp4"
clip.write_videofile(filename)
elif re.match('^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+$',link):
clip = YouTube(link)
clip.streams.first().download()
else:
wget.download(link,out=SAMPLE_INPUTS)