Jump to content

aaron832

Members
  • Posts

    3
  • Joined

  • Last visited

aaron832's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Hello everyone. Just wanted to share my Disney Plus automated script in the hopes that others might be able to make improvements to some of the brute force stuff I have done. I use this script with google home to request "I want to watch X on Disney Plus." Improvements: * I would like to be able to choose a profile. * Remove keyboard inputs for tabbing to select buttons / shows. #include <IE.au3> #include <Constants.au3> #include <Misc.au3> #include "commonfunc.au3" _Singleton("start_playsearchdisney") if Not ($CmdLine[0] >= 1) Then MsgBox(0, "Play Search Netflix", "No paramters... searching Moana") ;Exit 1 EndIf $searchtext = "Moana" if($CmdLine[0] >= 1) Then $searchtext = $CmdLine[1] EndIf CloseAll() TurnOnTV() SetAudioTV() Local $oIE = _IECreate("disneyplus.com/search") If @error Then Exit MsgBox(48, "", "_IECreate() Error", 3) Sleep (5000) ;5 second sleep to make sure everything loads. ;Get the search box element $oForm = _IEGetObjById($oIE, "search-input") if @error Then MsgBox(0, "Play Search Disney Error", "Couldnt get search form.", 5) _IEQuit($oIE) Exit EndIf ;Enter our search result into the field. _IEFormElementSetValue($oForm, $searchtext) ;Submit Send("{ENTER}") ;Brute force select the resulting show. 3 tabs required for IExplorer for some reason. Sleep (2000) Send("{TAB}") Send("{TAB}") Send("{TAB}") Send("{ENTER}") Sleep (4000) Send("{TAB}") ;Skip to content Sleep (500) Send("{ENTER}") ;Skip to content enter Send("{ENTER}") ;Play button ;Move the mouse out of the way. MouseMove(500,500) Also, including my netflix script in which I was able to avoid keyboard input for navigation. Also a profile can be used. #include <IE.au3> #include <Constants.au3> #include <Misc.au3> #include "commonfunc.au3" _Singleton("start_playsearchnetflix") if Not ($CmdLine[0] >= 1) Then MsgBox(0, "Play Search Netflix", "Bad number of params: " & $CmdLine[0]) Exit 1 EndIf CloseAll() TurnOnTV() SetAudioTV() Local $profileHash = "xxxxxxxxxxxxxx" if ($CmdLine[0] >= 2) Then Switch $CmdLine[2] Case "User2" $profileHash = "xxxxxxxxxxxxx" Case "User3" $profileHash = "xxxxxxxxxxxxx" EndSwitch EndIf CloseAll() MouseMove(0,0) Local $oIE = _IECreate("www.netflix.com/SwitchProfile?tkn=" & $profileHash) If @error Then Exit MsgBox(48, "", "_IECreate() Error", 3) Sleep (2000) Local $oApp = _IEGetObjById($oIE,"appMountPoint") $oApp.childnodes.item(0).childnodes.item(0).childnodes.item(0).childnodes.item(0).childnodes.item(2).childnodes.item(0).childnodes.item(0).childnodes.item(0) $tags = $oIE.document.GetElementsByTagName("button") For $tag in $tags $class_value = $tag.className If $class_value = "searchTab" Then Local $oSearchBox = $tag ExitLoop EndIf Next if Not ($oSearchBox.className == "searchTab") Then MsgBox(0, "Play Search Netflix Error", "Unable to locate searchTab page element. Did netflix change their site?", 5) _IEQuit($oIE) Exit EndIf _IEAction($oSearchBox, "click") sleep(500) Send($CmdLine[1]) Send("{ENTER}") Sleep (2000) Local $oCard = _IEGetObjById($oIE,"title-card-0-0") if @error Then MsgBox(0, "Play Search Netflix Error", "Sorry, no shows found.", 5) _IEQuit($oIE) Exit EndIf _IENavigate($oIE, $oCard.childnodes.item(0).childnodes.item(0).href) Sleep(5000) MouseMove(500,500)
  2. Thanks Simon! Noticed mine was not working and made your changes. I had to add some sleeps between the commands... maybe because the computer is a bit slow.... but it works! Yeah, the Ctrl Right arrow never worked for me either. Honestly I am kinda fed up with Spotify's crappy client. You can find and download older versions of the client that have better automation capability ( and disable upgrading ). I might do that again to avoid having to update scripts. I used to run a script on an older spotify client (pre- 1.0) that would select the current song, grab its name (for writing to a file) and delete it. Was cool for "blowing up" songs.
  3. Wow thanks for this script! For different versions of spotify this will have problems for sure.. only because spotify sux. The version I am running 1.0.86.337.ga8d5cef9 does not work with just your script. I had to make the following adjustments: 1) Always close spotify at the beginning (to ensure tab selection is reset) 2) Just pressing enter does not play the playlist. Need to shift tab 3x times, press enter, then press tab 2x times, then press enter. Also the retry was triggering even though the song was playing, so I got rid of that. I also added the ability to pass in a parameter to play a playlist ;****************************************************************** ;Spotify Automation: Start spotify and play a playlist ;v1.01 27/04/2018 ;------------------------------------------------------------------ ;by Daniel Barnes ;------------------------------------------------------------------ ;v1.01 27/04/2018 ;restarts spotify if it fails the first time ;works on computers that minimize Spotify to tray ;instead of closing it, and have a different ui element selected ;such as the Devices available option when spotify is started ;------------------------------------------------------------------ ;v1.00 25/04/2018 ;initial version ;------------------------------------------------------------------ Local $uriIndex[][2] = [ _ ["OFF", "OFF"], _ ["playlistname1", "spotify:user:user:playlist:UIRCODE"], _ ["playlistname2", "spotify:user:user:playlist:UIRCODE"], _ ["playlistname3", "spotify:user:user:playlist:UIRCODE"] _ ] ;Replace the below with the Spotify URI ;If you right click the playlist> share> copy spotify uri ;you can find the uri $spotifyURI = "" ;****************************************************************** ;if this script breaks in the future, figure this out using the AutoIt Window Info Tool Const $SpotifyWindowIdentifier = "[Title:Spotify;Class:Chrome_WidgetWin_0]" ;NOTE ABOUT SHUFFLE: ;I couldn't automate turning shuffling on or off ;I can toggle it, but I cannot figure out the current state ;If you want to shuffle, turn on shuffle in Spotify prior ;to running this script if($CmdLine[0] == 0) Then MsgBox(0, "Spotify Au3 Script Error", "No Parameters") ElseIf($CmdLine[0] >= 1) Then Local $spotifyURI = "" for $i = 0 To UBound($uriIndex)-1 Step 1 if($CmdLine[1] = $uriIndex[$i][0]) Then $spotifyURI = $uriIndex[$i][1] ExitLoop EndIf Next if($spotifyURI = "") Then MsgBox(0, "Spotify Au3 Error", "Unable to find spotify uri with key: " & $CmdLine[1]) Else if($spotifyURI = "OFF") Then ProcessClose("Spotify.exe") Else PlaySpotifyPlaylist($spotifyURI) Endif EndIf EndIf Func PlaySpotifyPlaylist($spotifyURI,$retry = 0) ;terminate spotify process on subsequent attempts ;If $retry Then echo ("Closing existing Spotify process") ProcessClose("Spotify.exe") ;endif echo ("Launching Spotify URI") ShellExecute($spotifyURI) ;Pause any existing song playing (if there is any) ;this is because Spotify's window title is only 'Spotify' when it is not playing any songs If Not WinExists($SpotifyWindowIdentifier) Then echo ("Pausing existing song (To find spotify window)") $timer = TimerInit() While Not WinExists($SpotifyWindowIdentifier) Send("{MEDIA_PLAY_PAUSE}") Sleep(500) If TimerDiff($timer) > 5 * 1000 Then ErrorMsg ("Timed out trying pause existing song") WEnd endif ;Get Spotify Window Handle $hwndSpotify = WinGetHandle($SpotifyWindowIdentifier) echo ("Attempting to play playlist") $timer = TimerInit() ;While WinGetTitle($hwndSpotify) = "Spotify" ;once it is playing the song, the title changes to the name of the song Sleep(5000) WinActivate($hwndSpotify) ;ControlSend($hwndSpotify,"","","{ENTER}") ;space will play what was previously playing (even another playlist or song), enter will play the playlist ;) ControlSend($hwndSpotify,"","","+{TAB}") ControlSend($hwndSpotify,"","","+{TAB}") ControlSend($hwndSpotify,"","","+{TAB}") ControlSend($hwndSpotify,"","","{ENTER}") ControlSend($hwndSpotify,"","","{TAB}") ControlSend($hwndSpotify,"","","{TAB}") ControlSend($hwndSpotify,"","","{ENTER}") ;Sleep(1000) ;If TimerDiff($timer) > 5 * 1000 Then ; If $retry Then ; ErrorMsg ("Timed out trying to play playlist") ; else ; Return PlaySpotifyPlaylist($spotifyURI,$retry+1) ; endif ;endif ;WEnd EndFunc Func echo($text) ConsoleWrite ($text&@CRLF) EndFunc Func ErrorMsg($text) MsgBox(16,StringTrimRight(@ScriptName,4),$text) Exit EndFunc
×
×
  • Create New...