Skip to content

Instantly share code, notes, and snippets.

@ibraabada
Last active October 14, 2020 21:52
Show Gist options
  • Save ibraabada/5a4852aae0cc32b4478b8eb5557c9582 to your computer and use it in GitHub Desktop.
Save ibraabada/5a4852aae0cc32b4478b8eb5557c9582 to your computer and use it in GitHub Desktop.
Genius x Musixmatch - Lyrics Finder
property my_title : "Ibra Itunes/Spotify Lyrics Search"
property baseURLGenius : "https://genius.com/search?q="
property baseURLMusicxmatch : "https://www.musixmatch.com/fr/search/"
tell application "Spotify"
set precNom to ""
repeat
if player state is not stopped then
set theTrack to current track
else if selection is not {} then
set theTrack to (item 1 of selection)
else
display notification "Aucune musique en cours ..." with title ("IbraScript")
return
end if
try
tell theTrack to set {nom, art} to {get name, get artist}
on error
display notification "Impossible d'accèder aux informations ..." with title ("IbraScript")
return
end try
if ((precNom as string) is not equal to (nom as string)) then
display notification nom & " - " & art with title ("Ibra's Script")
set geniusUrl to baseURLGenius & my rawURLEncode(nom & " " & art) as text
set musixUrl to baseURLMusicxmatch & my rawURLEncode(nom & " " & art) as text
my close_old_tab()
delay 1
my open_location(musixUrl)
delay 1
my open_location(geniusUrl)
set precNom to nom
end if
delay 2
end repeat
end tell
to open_location(theURL)
tell application "Google Chrome" to open location theURL
end open_location
to close_old_tab()
tell application "Google Chrome"
set windowList to every tab of every window
repeat with tabList in windowList
set tabList to tabList as any
repeat with tabItr in tabList
set tabItr to tabItr as any
delete tabItr
end repeat
end repeat
end tell
end close_old_tab
on rawURLEncode(str)
return do shell script "/bin/echo -n " & quoted form of str & " | php -r ' echo rawurlencode(fgets(STDIN)); '"
end rawURLEncode
@ibraabada
Copy link
Author

Make sure you got the following applications installed on your macbook :

Chrome browser
Spotify

Open the spotlight search bar (on the right top of your screen)
Search for 'Applescript Editor'
Select 'Editeurs de Script.app"
Click on 'Fichier'
Select 'Nouveau'
Copie Paste the following script code on your blank script page
Save the file somewhere
Click on the PLAY button on the top left of the script editor

Open Spotify
Launch a music an the magic happen

by Ibra for Alix ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment