TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Open Specific Netflix Movie with Alexa

    Windows
    8
    40
    9.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dlaugh14
      last edited by Russ

      Requirements: Echo with "Trigger Command" Alexa Skill, TriggerCMD installed on desired computer, Nodejs - I recently upgraded to 8.9.3 - Just make sure you're not far behind on your installed Nodejs, I'm using Windows 10 - I believe you can get selenium-webdriver for MAC and LINUX.
      LINK FOR REFERENCE: http://seleniumhq.github.io/selenium/docs/api/javascript/

      INSTRUCTIONS

      1. Open https://www.npmjs.com/package/selenium-webdriver
      2. Open windows command prompt
      3. cd to desired directory (I'm a web developer) so htdocs folder for me THEN type npm install selenium-webdriver.
      4. Once selenium-webdriver is installed you may need to install additional components - There are links/downloads for these components in my LINK FOR REFERENCE above. I did not need to install this for Firefox. I guess I already had this installed. (If you need this the link is just to download whichever browsers developer browser executable to use with selenium. You will need to add a PATH variable to the directory of the executables.)
      5. Open your IDE of choice and navigate to node_modules->selenium-webdrivers->examples->google_search.js. Try running this. You can do so by running the script from the command line->
      node C:\MAMP\htdocs\automation\node_modules\selenium-webdriver\example>node google_search.js
      

      If your component was installed correctly this will open up your browser and do a google search. Then you know its working and you can use my code below to have Alexa open up a specific movie.

      // or more contributor license agreements.  See the NOTICE file
      // distributed with this work for additional information
      // regarding copyright ownership.  The SFC licenses this file
      // to you under the Apache License, Version 2.0 (the
      // "License"); you may not use this file except in compliance
      // with the License.  You may obtain a copy of the License at
      //
      //   http://www.apache.org/licenses/LICENSE-2.0
      //
      // Unless required by applicable law or agreed to in writing,
      // software distributed under the License is distributed on an
      // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
      // KIND, either express or implied.  See the License for the
      // specific language governing permissions and limitations
      // under the License.
      
      /**
       * @fileoverview An example WebDriver script.
       *
       * Before running this script, ensure that Mozilla's geckodriver is present on
       * your system PATH: <https://github.com/mozilla/geckodriver/releases>
       *
       * Usage:
       *   // Default behavior
       *   node selenium-webdriver/example/google_search.js
       *
       *   // Target Chrome locally; the chromedriver must be on your PATH
       *   SELENIUM_BROWSER=chrome node selenium-webdriver/example/google_search.js
       *
       *   // Use a local copy of the standalone Selenium server
       *   SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \
       *     node selenium-webdriver/example/google_search.js
       *
       *   // Target a remote Selenium server
       *   SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \
       *     node selenium-webdriver/example/google_search.js
       */
      
      const {Builder, By, Key, until} = require('..');
      
      var driver = new Builder()
          .forBrowser('firefox')
          .build();
      
      
      var command = "";
      ///GETTING COMMAND FROM AGRUMENTS
       process.argv.map((value, index) => {
              if(index > 2) {
                 return command = command + " " + value;
              } else if( index === 2) {
                  return command = value;
              }
      });
      // .then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
      
      driver.get('https://www.netflix.com/login')
          .then(_ =>
      driver.findElement(By.name('email')).sendKeys('netflixuser@gmail.com'))
      .then(_ =>
      driver.findElement(By.name('password')).sendKeys('netflixpassword'), Key.ENTER)
      .then(_ =>
      driver.sleep(2000))
      .then(_ =>
          driver.findElement(By.className('login-button')).click())
      .then(_ =>
          driver.sleep(1000))
      .then(_ =>
      driver.findElement(By.xpath('/html/body/div[1]/div/div/div[2]/div/div/ul/li[1]/div/a/div/div')).click())
      .then(_ =>
      driver.findElement(By.className('searchTab')).click())
      .then(_ =>
      driver.findElement(By.css('.searchInput > input:nth-child(2)')).sendKeys(command))
      .then(_ =>
      driver.sleep(3000))
      .then(_ =>
      driver.findElement(By.id('title-card-0-0')).click())
      .then(_ =>
      driver.sleep(2000))
      .then(_ =>
      driver.findElement(By.className('play')).click())
      .then(_ =>
      driver.sleep(2000))
      .then(_ =>
          driver.findElement(By.css('body')).click());
      
      1. Run Test with Netflix script -> Lets say you want to just copy my code and replace the google_search.js file you tested with. In your command prompt cd to your selenium-webdriver->example directory and in the command prompt type "node google_search.js boss baby and press enter. This will run the script and open up boss baby.

      Here's mine.

      C:\MAMP\htdocs\automation\node_modules\selenium-webdriver\example>node google_search.js boss baby
      

      So, "boss baby" is the parameter that you are going to pass to "Alexa". Once you have the Alexa skill enabled and the script working just say the command you created. Such as: "Alexa open trigger command and movie with parameter boss baby"
      0_1513571752649_upload-9081311b-3e03-472e-8891-6e0cd2040c4d
      I realize you cannot see my full command its just the same path as the google_search.js script above - C:\MAMP\htdocs\automation\node_modules\selenium-webdriver\example>node google_search.js

      If you have any troubles with this let me know. I have noticed that there are times when the script fails because it says that an element on the page isn't there yet. You can increase the sleep time on the script. Like instead of 2 seconds (2000) change to three (3000). Now you can start building your own scripts. The driver class methods being used has helpful comments in the C:\MAMP\htdocs\automation\node_modules\selenium-webdriver\lib\webdriver.js file. I used this to learn how to change up the script to my needs (Netflix by specific movie). My kid loves it!

      I split video in two to cut out my login/users page - but this is how it works for me.

      https://drive.google.com/file/d/1_V-5zjNurB_a-DyaBgNE4CljzUBhhqLW/view?usp=sharing
      https://drive.google.com/file/d/1t82l-Y6Tb5JLhKpMElxP4YRD1Ta7Z7TL/view?usp=sharing

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @dlaugh14
        last edited by Russ

        @dlaugh14, wow. That is so awesome. I can't wait to try this. Thank you for posting it.

        EDIT: I tried it. It's awesome. Here's a video showing it working: https://youtu.be/i-Ig8WoJBpI

        Russell VanderMey

        1 Reply Last reply Reply Quote 0
        • D
          dlaugh14
          last edited by

          Glad it worked! Bet you were like...that's not my Netflix account...lol. Thanks for changing that by the way. I need to stop coding at like 10pm.

          I think it would be cool to enable staying in trigger command from Alexa for a while instead of one command at a time and then you have to trigger again. I don't really know if that's possible, but it would fit really well here. You could say less and get more done.

          RussR 1 Reply Last reply Reply Quote 0
          • RussR
            Russ @dlaugh14
            last edited by Russ

            @dlaugh14, I know it's possible to stay in the skill.

            Maybe I could have it exit only if you use the one-shot method:

            Alexa, ask TRIGGERcmd to run X on Y
            

            But if you say,

            Alexa, talk to TRIGGERcmd
            

            ... then it would say, "Triggering X on Y. Anything else?" after each command you run.

            Russell VanderMey

            1 Reply Last reply Reply Quote 0
            • Felipe GuedesF
              Felipe Guedes
              last edited by Felipe Guedes

              Hello guys,

              I'm from Brazil, and i need to know how to configure or talk to alexa to start the command?
              Can you help me?

              Other wise, in chrome driver, you know how to configure full screen when start the movie or serie?

              RussR Felipe GuedesF 2 Replies Last reply Reply Quote 0
              • RussR
                Russ @Felipe Guedes
                last edited by Russ

                @Felipe-Guedes, I'm glad you asked because I forgot to add the Brazil link to this page.

                Have you seen this video yet? It shows the newer Smart Home version of the skill, which I prefer personally because it recognizes your words better.

                If you want to use the original skill, you should be able to say, "Alexa, abrir Execute Comando" to get started, or use this link.

                Also, to answer your other question, no I don't know how to make it go full screen. If you figure that out, please post the solution.

                Russell VanderMey

                1 Reply Last reply Reply Quote 0
                • Felipe GuedesF
                  Felipe Guedes
                  last edited by

                  @Russ sorry i'm very dummy, i don't know how to execute with parameters.
                  I try this several times, but the Execute comando dont recognize my pc.
                  I try to say: "Alexa, abrir Execute Comando", thats perfect, after that, when i say: "Execute automação(That is name to my command) no PC(voice name) com parametro boss baby, doesn't work, Alexa say: Eu não encontrei o dispositivo PC.

                  Can you create a video with a exemple executing something with parameters, and configuration.

                  RussR 1 Reply Last reply Reply Quote 0
                  • RussR
                    Russ @Felipe Guedes
                    last edited by Russ

                    @Felipe-Guedes, before you try to use Alexa, you should make sure your command works the way you expect using the Parameters button.

                    3d81048f-ea11-4817-9304-0e5ae6af1d99-image.png

                    Before the button will show up, you'll need to enable parameters on your command:

                    231ac2b9-3699-4907-992f-bc75d48066d2-image.png

                    Then when you click this button:

                    79353e80-8268-4f1e-ade2-2bd630a0571f-image.png

                    You should have a phrase that ends with X.

                    11dd3808-acd9-41f5-997a-44047bf1a797-image.png

                    When you talk to Alexa, you say your parameter in place of X.

                    Here's a video I made a while ago about how it works with Alexa:
                    https://www.youtube.com/watch?v=P6m9gJIsuxE

                    Russell VanderMey

                    1 Reply Last reply Reply Quote 0
                    • Felipe GuedesF
                      Felipe Guedes
                      last edited by

                      @Russ I dont know why, but de command doesn't execute NODE command.
                      Can you explain to me what i need to do?

                      1 Reply Last reply Reply Quote 0
                      • Felipe GuedesF
                        Felipe Guedes
                        last edited by

                        When i run with parameters, it mark that command is run, but to my nothing happens.

                        RussR 1 Reply Last reply Reply Quote 0
                        • RussR
                          Russ @Felipe Guedes
                          last edited by

                          @Felipe-Guedes, the best way to troubleshoot is make sure it works from a cmd prompt first. If you get an error running the node command at the cmd prompt you probably don't have nodejs installed yet.

                          After you get it working from the cmd prompt, then add it to the TRIGGERcmd agent and include the parameters in the command field at first.

                          This is boss baby example is actually pretty complex to implement, and I realize I didn't include all of the steps. I'm going to be busy this 4th of July weekend but after that I can make a more detailed video if you want.

                          Russell VanderMey

                          1 Reply Last reply Reply Quote 0
                          • Felipe GuedesF
                            Felipe Guedes
                            last edited by

                            Tks @Russ ,
                            The command in node runs very well, but when i try to run in trigger cmd in my windows doenst run, when i try to run by the website, it shows me it did, but it didn't.

                            RussR 1 Reply Last reply Reply Quote 0
                            • RussR
                              Russ @Felipe Guedes
                              last edited by

                              @Felipe-Guedes, what is your command? And does that same command work if you run it in a Windows cmd prompt?

                              Russell VanderMey

                              1 Reply Last reply Reply Quote 0
                              • Felipe GuedesF
                                Felipe Guedes
                                last edited by

                                Yes my command runs very well.

                                RussR 1 Reply Last reply Reply Quote 0
                                • RussR
                                  Russ @Felipe Guedes
                                  last edited by Russ

                                  @Felipe-Guedes, it works from the cmd prompt but not from TRIGGERcmd? If so, maybe in your cmd window you're running it from the directory where the script resides, so the problem with running it via TRIGGERcmd is that the working directory is not where the javascript file is. In which case, you could either create a batch file that changes the working dir to that folder before running the node command, or it might be adequate to specify the full path to the .js file as part of your command like this:

                                  node c:\scripts\scriptdir\script.js
                                  

                                  Russell VanderMey

                                  1 Reply Last reply Reply Quote 0
                                  • Felipe GuedesF
                                    Felipe Guedes
                                    last edited by

                                    Yes, i know that.
                                    Thats my configuration:
                                    {
                                    "trigger": "abrir google",
                                    "command": "node C:\Users\Artista\Documents\node_modules\selenium-webdriver\exemple\google.js",
                                    "ground": "foreground",
                                    "voice": "abrir google",
                                    "voiceReply": "",
                                    "allowParams": "true"
                                    }

                                    And the full path:
                                    c6a209ef-d18f-43ce-a0b0-2ac841491e9d-image.png

                                    When i run directly in cmd, runs very well like i said, but in trggercmd no.

                                    RussR 1 Reply Last reply Reply Quote 0
                                    • RussR
                                      Russ @Felipe Guedes
                                      last edited by

                                      @Felipe-Guedes, thanks for that info. That helps.

                                      I'm still thinking it's a problem with the working directory. Node knows how to find module dependencies based on the working directory. Would you mind trying this?

                                      Create a script called c:\scripts\google.bat with these contents:

                                      cd /d C:\Users\Artista\Documents\node_modules\selenium-webdriver\exemple
                                      node google.js
                                      

                                      Then make this your triggercmd command: c:\scripts\google.bat

                                      Russell VanderMey

                                      1 Reply Last reply Reply Quote 0
                                      • Felipe GuedesF
                                        Felipe Guedes
                                        last edited by

                                        Perfect, now i can execute the command in trigger cmd and i have other problem hhahahahah.
                                        When i say - "Alexa, Execute comando" -> "Execute automacao com parametro boss baby" -> She don't recognize my command. Isn't an exemple with parameters in portuguese.
                                        Help me, we almost there !

                                        1 Reply Last reply Reply Quote 0
                                        • Felipe GuedesF
                                          Felipe Guedes @Felipe Guedes
                                          last edited by

                                          @Felipe-Guedes Otherwise, is this configuration set maximized chrome.

                                          var chrome = require("selenium-webdriver/chrome");
                                          
                                          /** 
                                           * Set chrome command line options/switches
                                          */      
                                          var chromeOptions = new chrome.Options();
                                          chromeOptions.addArguments("test-type");
                                          chromeOptions.addArguments("start-maximized");
                                          chromeOptions.addArguments("--js-flags=--expose-gc");
                                          chromeOptions.addArguments("--enable-precise-memory-info");
                                          chromeOptions.addArguments("--disable-popup-blocking");
                                          chromeOptions.addArguments("--disable-default-apps");
                                          chromeOptions.addArguments("--disable-infobars");
                                          
                                          var driver = new Builder()
                                              .forBrowser('chrome')
                                              .setChromeOptions(chromeOptions)
                                              .build();
                                          

                                          I'm still searching how to set full screen in video, and how to stop and play.
                                          i'll post here when i find

                                          RussR 1 Reply Last reply Reply Quote 0
                                          • RussR
                                            Russ @Felipe Guedes
                                            last edited by Russ

                                            @Felipe-Guedes, does this work?

                                            Alexa, pergunte Execute Comando execute automacao com o parâmetro boss baby.

                                            I think I need to fix the portuguese text on the voice command cheat sheet page.

                                            EDIT: I updated that voice command cheat sheet page. I hope that works better.

                                            Russell VanderMey

                                            Felipe GuedesF 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post