Nachfolgendes Script wurde basierend auf einer Anfrage
![Arrow :arrow:](./images/smilies/icon_arrow.gif)
Die Situation: Spotify ermöglicht das 'disliken' von Songs, allerdings nur unter Android/iOS (und/oder weiteren mir unbekannten Voraussetzungen).
Diese Funktion fehlt jedoch für den Spotify WebPlayer im (Chrome/Edge) Browser.
Verwendet wurde …
Google Chrome Browser (v98). Info dazu in 'Chrome > Hilfe > Über Google Chrome'
Optionale Chrome Extension: Spotify Web Player Hotkeys - Alexandre Macabies.
Anmerkung: Das script läuft auch ohne diese Browser Extension, und dient lediglich dazu das Vor-/Zurückspringen von Songs per Tastendruck an das (geschlossene) Browserfenster zu ermöglichen (bei mir zu Testzwecken). Wer ein Gerät mit 'Mediakeys' hat kann es auch damit probieren.
a) für die 'Testumgebung' wurde ein Album von Snoop Dog gewählt (mit ausreichend 'explicit content'
![Mr. Green :mrgreen:](./images/smilies/icon_mrgreen.gif)
![Silent :silent:](./images/smilies/icon_silent.gif)
b) das Script ermittelt bei 'laufendem Betrieb' den Songtitel (benötigt im Tab den Aktivitätsnachweis "Audiowiedergabe" als Unterscheidungsmerkmal).
c) zum Test wurde der dritte Song im Album disliked ("Drop It Like It's Hot · Snoop Dogg, Pharrell Williams – Audiowiedergabe")
d) mittels der Chrome-Extension wird beim Erfassen eines 'Übeltäters' die Tastenkombination STRG+Rechts ("^{Right"}) AKA "Nächster Song" an den Browser gesendet.
Anmerkung: soll dies auch bei minimiertem Browser funktionieren, ist die Tastenkombination in der Extension auf 'Global' zu setzen.
e) zum Testen einfach mal versuchen den dritten Song im Player mittels Click abzuspielen - es wird zum nächsten Song geskipped.
So here we go... https://open.spotify.com/artist/7hJcb9fa4alzcOq3EaNPoG
![Thumbup :thumbup:](./images/smilies/icon_thumbup.gif)
Wunschliste:
1)
2)
3)
![Silent :silent:](./images/smilies/icon_silent.gif)
4) es lassen sich noch einige Infos im Browser abgreifen (z.B. der Pfad des aktuell gespielten Songs), ich weiss nur nicht wirklich wie dies bei Child-Dingens zu machen wäre??
Code: Select all
; 'https://open.spotify.com'
; 'https://open.spotify.com/artist/7hJcb9fa4alzcOq3EaNPoG' - Snoop Dog
; 'https://chrome.google.com/webstore/detail/spotify-web-player-hotkey/pdcbjjmgfakcbbchppeemlfpfgkdmjji' - Spotify Web Player Hotkeys by Alexandre Macabies
#SingleInstance, Force
#Include Acc.Ahk ; https://github.com/Drugoy/Autohotkey-scripts-.ahk/blob/master/Libraries/Acc.ahk
SetBatchLines, -1
SetWorkingDir, A_ScriptDir
SetTimer, dropThatShit, 500 ; check every 500ms..
Return
dropThatShit:
file := !InStr(getChromeUrl(),"open.spotify.com") ; extract spotify media ID from URL to create specific '<blacklist ID>.txt'
? "" ; bc no spotify URL/instance has been identified no blacklist file/ID
: StrSplit(getChromeUrl(),"/").3 . ".txt" ; creating '<blacklist ID>.txt'
ToolTip % validate(getChromeTab("Audiowiedergabe"),file)=1 ; validation against '<blacklist ID>.txt'
? spotifyKey("^{Right}") ; therefore, let's skip that sh...
: "" ; Still cruisin'..." ; Calm down Buddy & let's listen!
Return
getChromeUrl() {
local
hWnd := WinExist("ahk_class Chrome_WidgetWin_1")
oAcc := Acc_Get("Object", "4.1.1.2.1.2.5.3", 0, "ahk_id " hWnd)
if !IsObject(oAcc) || !(oAcc.accName(0) = "Address and search bar")
oAcc := Acc_Get("Object", "4.1.1.2.1.2.5.3", 0, "ahk_id " hWnd) ; '4.1.1.2.1.2.5.3' (Chrome v98 address bar path). Use ACCViewer.ahk to update accordingly.
vUrl := oAcc.accValue(0)
oAcc := ""
return vUrl
}
getChromeTab(playIndicator:="") {
WinExist("ahk_class Chrome_WidgetWin_1") ; 'https://www.autohotkey.com/boards/viewtopic.php?p=436429#p436429'
For each, oChild in Acc_Children(Acc_Get("Object", TABS := "4.1.1.2.1.1.1")) ; '4.1.1.2.1.1.1' (Chrome v98 TAB bar path). Use ACCViewer.ahk to update accordingly.
vRes .= InStr(oChild.accName(0), playIndicator) ; 'playIndicator' = string the browser will add (ie "Audiowiedergabe") to a TAB indicating a playing media file.
? oChild.accName(0) . "`r`n" ; press Alt+c to identify your language specific string that is trailing the character.
: Return
Return Trim(vRes,"`r`n")
}
validate(currSong,file,sep:="`r`n") {
if !FileExist(file) ; if a blacklist doesn't exist...
Return 0 ; ...there are no blacklisted songs: 0/false
FileRead, content,% file ; otherwise parse '<blacklist ID>.txt'
array := StrSplit(Trim(content,sep),sep) ; remove trailing `n from blacklist content, otherwise a detected 'empty tab' will be considered a match
Loop % array.Count() {
} Until i:=(currSong=Trim(array[A_Index],"`r`n")) ? 1 : 0 ; matching song 1/true 0/false
Return i
}
spotifyKey(key) { ; ternary operator can't handle legacy commands, so 'outsourced' it into a function.
Send % key
}
!g:: clipboard := getChromeTab() ; get all TAB strings to the clipboard.
!b::
if (getChromeTab("Audiowiedergabe") = "")
Return
FileAppend,% getChromeTab("Audiowiedergabe") "`n",% file ; adding the playing song to '<blacklist ID>.txt'
Return
!r:: Run % file ; review '<blacklist ID>.txt'
!c:: clipboard := getChromeTab("Audiowiedergabe") ; showing currently playing songs' title (and keep it at the clipboard)
~Left:: spotifyKey("^{Left}") ; moving left to select the previous track (for testing)
~Right::spotifyKey("^{Right}") ; moving right to select the next track (for testing)
![Cool 8-)](./images/smilies/icon_cool.gif)
Tags: spotify | playlist | hide | dislike | web player | windows | skip | song