Created
September 13, 2021 04:49
-
-
Save daviirodrig/46af3c1edc6cd872897537f6936ee2a8 to your computer and use it in GitHub Desktop.
Python script to auto skip spotify ads and display lyrics on terminal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import os | |
import lyricsgenius | |
import win32gui | |
import win32api | |
from win32con import VK_MEDIA_NEXT_TRACK, KEYEVENTF_EXTENDEDKEY | |
np = "" | |
def get_song_name(): | |
windows = [] | |
def find_spotify_uwp(hwnd, windows): | |
text = win32gui.GetWindowText(hwnd) | |
classname = win32gui.GetClassName(hwnd) | |
if classname == "Chrome_WidgetWin_0" and len(text) > 0: | |
windows.append(text) | |
win32gui.EnumWindows(find_spotify_uwp, windows) | |
try: | |
return windows[0] | |
except IndexError: | |
return "Spotify Closed" | |
def detect_ad(song): | |
if song == "Spotify Free": return False | |
if song in ("Advertisement", "Spotify"): return True | |
def show_lyrics(song): | |
global np | |
if detect_ad(song): | |
win32api.keybd_event(VK_MEDIA_NEXT_TRACK, 0, KEYEVENTF_EXTENDEDKEY, 0) | |
return | |
if song in (np, "Spotify Free", "Spotify Closed"): | |
return | |
genius = lyricsgenius.Genius('GENIUS-API-KEY') | |
os.system('cls') | |
musica = genius.search_song(song, get_full_info=False) | |
if musica == "No results": | |
return | |
while musica is None: | |
musica = genius.search_song(song, get_full_info=False) | |
os.system('cls') | |
printar = musica.artist.strip(' ') + ' - ' + musica.title.strip(' ') | |
np = song | |
print(f'\033[1;32;49m{printar}\033[m') | |
print() | |
print(f'\033[1;33;49m{musica.lyrics}\033[m') | |
while True: | |
song = get_song_name() | |
show_lyrics(song) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment