Repository navigation
Expand file tree
/
Copy pathSpotifyBot.py
More file actions
44 lines (34 loc) · 1.93 KB
/
Copy pathSpotifyBot.py
File metadata and controls
44 lines (34 loc) · 1.93 KB
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
import time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("https://accounts.spotify.com/en/login")
# Wait for the username field to load and enter the username
wait = WebDriverWait(driver, 10)
username = wait.until(EC.presence_of_element_located((By.ID, "login-username")))
username.click()
username.send_keys("matttaylornz@gmail.com")
# Wait for the password field to load and enter the password
wait = WebDriverWait(driver, 10)
password = wait.until(EC.presence_of_element_located((By.ID, "login-password")))
password.click()
password.send_keys("taylor02")
# Wait for the login button to load and click it
wait = WebDriverWait(driver, 10)
login_button = wait.until(EC.presence_of_element_located((By.ID, "login-button")))
login_button.click()
time.sleep(5)
driver.get("https://open.spotify.com/album/0mCWqN0VvChqQh8ITK92W4")
# Wait for the play button to load and click it
wait = WebDriverWait(driver, 10)
play_button = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#main > div > div.Root__top-container > div.Root__main-view > div.main-view-container > div.os-host.os-host-foreign.os-theme-spotify.os-host-resize-disabled.os-host-scrollbar-horizontal-hidden.main-view-container__scroll-node.os-host-transition.os-host-overflow.os-host-overflow-y > div.os-padding > div > div > div.main-view-container__scroll-node-child > main > section > div.os-host.os-host-foreign.os-theme-spotify.os-host-resize-disabled.os-host-scrollbar-horizontal-hidden.os-host-scrollbar-vertical-hidden.os-host-transition > div.os-padding > div > div > div > div > div > button")))
play_button.click()
human_timeout = 60
for i in range(10):
print("Song Playing...")
time.sleep(human_timeout)
play_button.click()
driver.quit()