-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstube.py
More file actions
32 lines (25 loc) · 869 Bytes
/
stube.py
File metadata and controls
32 lines (25 loc) · 869 Bytes
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
#Simple script that downloads videos from youtube.
#Usage: $ python3 stube.py URL_OF_YOUTUBE_VIDEO
#If the dependency pytube does not work correctly try this:
#Go in the cipher.py from pytube and replace line 30, which is:
#var_regex = re.compile(r"^\w+\W")
#Replace with:
#var_regex = re.compile(r"^\$*\w+\W")
#Imports
import sys
from pytube import YouTube
from pytube.cli import on_progress
def main():
URLS = sys.argv[1:]
def on_complete(x, y):
print()
for i in URLS:
video = YouTube(i, on_progress_callback=on_progress, on_complete_callback=on_complete, use_oauth=False, allow_oauth_cache=False)
print("Printing video information...")
print(f"Video title: {video.title}")
stream = video.streams.get_highest_resolution()
print(f"Downloading video: {i}")
stream.download()
print("Done!")
if __name__ == "__main__":
main()