Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- from urllib.request import urlopen
- def findLink(txt):
- template = re.compile(r"(?:https?:\\\\\\\/\\\\\\\/)(?:[\w\.]+)\.(?:[a-z]{2,6}\.?)(?:\\\\\\\/[\w\.]*)*(?:\.mp4)")
- return re.findall(template, txt)
- txt = urlopen(str(input("Введите ссылку на видео: "))).read().decode("cp1251")
- numList = ["240", "360", "480", "720"]
- videoList = findLink(txt)
- print("Выберите качество видео: ")
- for i in range(len(videoList)):
- videoList[i] = re.sub(r"\\\\\\\/", "/", videoList[i])
- print(i+1, ": ", numList[i])
- num = int(input())
- fileName = input("Введите имя сохраняемого файла (можете оставить пустым): ")
- print("Загружаем...")
- video = urlopen(videoList[num-1]).read()
- if fileName == "":
- fileName = numList[num-1]+".mp4"
- else:
- if not fileName.endswith(".mp4"):
- fileName += ".mp4"
- f = open(fileName, "wb")
- f.write(video)
- f.close()
- print("Готово :)")
Add Comment
Please, Sign In to add comment