-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconverter.py
72 lines (50 loc) · 1.69 KB
/
converter.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
69
70
71
72
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class YTDownloader:
def __init__(self):
"""Initializes Chromedriver and sets common url"""
self.driver = webdriver.Chrome()
self.base_url = "https://ytmp3.cc/en13/"
def new_link(self):
"""Asks user for youtube link(s)"""
self.link = input("Please paste Youtube video link :)\n")
# ask user for multiple video links
# store links in list and loop downloading
# print("How many videos would you like me to download?\n")
# self.downloads = int(input())
# print("Please paste link for video(s) :)")
# self.multiple = []
# if self.downloads == 1:
# print("Thanks!")
# elif self.downloads > 1:
# self.link = input(""),
# self.multiple.append(self.link)
# print(self.multiple)
def nav(self):
"""Bot goes to landing page"""
self.driver.get(self.base_url)
# self.driver.maximize_window()
time.sleep(1)
def convert(self):
"""Paste link and click on convert button click()"""
self.driver.find_element_by_id("input").send_keys(self.link)
time.sleep(1)
self.driver.find_element_by_id("submit").click()
def download(self):
"""Click on download button"""
time.sleep(2)
self.driver.find_element_by_link_text("Download").click()
def _multiple(self):
# loop through links
pass
def close(self):
"""Window closes"""
time.sleep(15)
self.driver.close()
yt = YTDownloader()
yt.new_link()
yt.nav()
yt.convert()
yt.download()
yt.close()