-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.py
106 lines (92 loc) · 3.5 KB
/
app.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import sys
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
import os, time, glob
filename = "songlist.txt"
def getublock():
s = Service(ChromeDriverManager().install())
options = webdriver.ChromeOptions()
options.add_argument('--lang=en')
dir = os.getcwd()
prefs = {'download.default_directory': dir}
options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(service=s, chrome_options=options)
driver.get(
"https://clients2.google.com/service/update2/crx?response=redirect&prodversion=100.0.4896.127&acceptformat=crx2,crx3&x=id%3Dcjpalhdlnbpafiamejdnhcphjbkeiagm%26uc")
time.sleep(10)
driver.close()
def dl_click():
dl_button = driver.find_element(By.XPATH, "//button[text()='Download']")
driver.implicitly_wait(1.5)
dl_button.click()
def quality_click():
driver.implicitly_wait(1.5)
if quality == "1":
ActionChains(driver).move_to_element(driver.find_element(By.ID, "mp3-128")).click().perform()
elif quality == "2":
ActionChains(driver).move_to_element(driver.find_element(By.ID, "mp3-320")).click().perform()
elif quality == "3":
ActionChains(driver).move_to_element(driver.find_element(By.ID, "flac")).click().perform()
def download():
c = 0
with open(filename, encoding='utf-8') as fp:
Lines = fp.readlines()
for line in Lines:
c += 1
time.sleep(2)
driver.find_element(By.CLASS_NAME, 'input').clear()
time.sleep(1)
search_box = driver.find_element(By.CLASS_NAME, "input")
search_button = driver.find_element(By.ID, "snd")
query = line.strip()
search_box.send_keys(query)
time.sleep(1)
search_button.click()
time.sleep(2)
dl_click()
if c == 1:
quality_click()
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(10)
dl_click()
c += 1
time.sleep(5)
else:
quality_click()
dl_click()
c += 1
time.sleep(5)
driver.execute_script("window.history.go(-1)")
time.sleep(1)
print(line.strip(), "downloaded")
def start_script():
driver.get("https://free-mp3-download.net")
vpn_check = driver.find_element(By.XPATH, ".//*[contains(text(), 'Search using our VPN')]")
vpn_check.click()
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
download()
time.sleep(60)
if __name__ == "__main__":
print("!!! REMEMBER: YOU NEED TO CHECK CAPTCHA EVERY 15 MINUTES !!!")
adb = ""
for file in glob.glob("*.crx"):
adb = file
time.sleep(2)
if adb.endswith('.crx'):
quality = input("Insert 1 for MP3 (128k), 2 MP3 (320k) or 3 for FLAC: ")
try:
int(quality)
except:
print("You haven't inserted an integer number, please re-run the tool")
sys.exit()
options = webdriver.ChromeOptions()
options.add_extension(adb)
options.add_argument('--lang=en')
s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s, chrome_options=options)
start_script()
else:
getublock()