Skip to content

Instantly share code, notes, and snippets.

@n2nco
Created March 6, 2023 18:14
Show Gist options
  • Save n2nco/d79d7af05c29220ec42d19eda7b4d072 to your computer and use it in GitHub Desktop.
Save n2nco/d79d7af05c29220ec42d19eda7b4d072 to your computer and use it in GitHub Desktop.
Skip Spotify Ads & Bypass captcha
import pyautogui
from functools import partial
import mss
import webbrowser
import time
screen_size = pyautogui.size()
def clicked_captchas (btn1, btn2, input):
position1 = pyautogui.locateCenterOnScreen(btn1, grayscale=True, confidence=0.9)
position2 = pyautogui.locateCenterOnScreen(btn2 ,grayscale=True, confidence=0.9)
i_position = pyautogui.locateCenterOnScreen(input, grayscale=True, confidence=0.9)
print("positon1 ", position1, " position2: ", position2, " i_position: ", i_position)
if position1 is not None:
pyautogui.moveTo(position1.x/2,position1.y/2)
pyautogui.mouseDown(button='left')
pyautogui.mouseUp()
print("clicked btn 1")
elif position2 is not None:
pyautogui.moveTo(position2.x/2,position2.y/2)
pyautogui.mouseDown(button='left')
pyautogui.mouseUp()
print("clicked btn 3")
if i_position is not None:
pyautogui.moveTo(i_position.x/2,i_position.y/2)
pyautogui.click(i_position.x/2,i_position.y/2)
# Type some text into the textarea
text_to_type = "This is a test sentence typed by PyAutoGUI!"
pyautogui.typewrite(text_to_type, interval=0.1)
print("clicked input")
else:
return False
btn1 = "btn.png"
btn2 = "boxbtn.png"
input = "t_i.png"
while not clicked_captchas(btn1, btn2, input):
time.sleep(1)
# while not skipped_spotify_ad(slider_image, end_of_slider_image, ad_image):
# # Wait for a little while before searching again
# time.sleep(1)
def skipped_spotify_ad(slider_image, end_of_slider_imag, ad_image):
# pyautogui.moveTo(100, 150)
#coords = pyautogui.locateOnScreen(image)
position = pyautogui.locateCenterOnScreen(slider_image, grayscale=True, confidence=0.9)
positionEnd = pyautogui.locateCenterOnScreen(end_of_slider_image,grayscale=True, confidence=0.9)
positionAd = pyautogui.locateCenterOnScreen(ad_image, grayscale=True, confidence=0.9)
print("positons - Slider ", position, " End of Slider: ", positionEnd, " Ad: ", positionAd)
if position is not None and positionAd is not None:
pyautogui.moveTo(position.x/2,position.y/2)
pyautogui.mouseDown(button='left')
#drag all the way to the right
#don't necessarily need to now position end
x = positionEnd.x if positionEnd is not None and positionEnd.x >= position.x else 2000
y = positionEnd.y if positionEnd is not None else 800
print('dragging')
pyautogui.dragTo(x, y, button='left')
pyautogui.mouseUp()
print('Ad skipped :)')
else:
return False
slider_image = 'slider.png'
end_of_slider_image = 'end_of_slider.png'
ad_image = 'advertisement.png'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment