RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Twitch.tv System

    Scheduled Pinned Locked Moved Ideas and Development
    emulatiostationsystemstwitch tv
    5 Posts 2 Posters 1.6k Views
    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.
    • K
      kinduff
      last edited by kinduff

      Hey all,

      I've been discovering how ES works for a few days, so far so good. What I'm trying to achieve is to have an entry in the systems list (main screen) where I can watch my favorite Twitch channels. This is for a Raspberry Pi 3 using Retropie.

      I'm posting here to share my progress so anyone with more experience can help out.

      Here's what I have so far:

      • First of all, I installed streamlink, a python cli tool to play videos from different services, including Twitch, it has omxplayer support.
      • I created a es_system.cfg file under /.emulationstation to override all the systems and be able to test faster.
      <?xml version="1.0"?>
      <systemList>
        <system>
          <name>twitch</name>
          <fullname>Twitch.tv</fullname>
          <path>/home/pi/twitch</path>
          <extension>.twitch</extension>
          <command>/home/pi/runner.sh %ROM%</command>
          <platform>twitch</platform>
          <theme>twitch</theme>
        </system>
      </systemList>
      
      • As you can see from the es_systems.cfg file, I'm calling runner.sh as the command.
      #!/bin/bash
      twitchName=$(basename "$1" .twitch)
      twitchUrl="twitch.tv/$twitchName"
      streamlink $twitchUrl best --player "omxplayer --win '0 0 800 480'" --player-http
      # modify --win '0 0 width height' flag to fit your resolution
      
      • Finally the "rom" saved in /home/pi/twitch, which is just a file using the username of the Twitch channel using .twitch extension: username.twitch

      Here's a demo:

      (sorry for bad quality)

      It works as expected, when you log into ES, I can see the Twitch system, the "rom" and when I click it, I'm able to stream a live Twitch channel.

      Some notes:

      • I can't exit if omxplayer is active with a controller (haven't tested with a keyboard tho).
      • I could create the gamelist.xml file to add some metadata, but I'm skipping that since I assume it works.
      • No way to hide (right now) "roms" that are not live. If they are not live, streamlink will try to stream and then exit.

      How can this be improved? What's a better solution?

      Thanks for reading.

      1 Reply Last reply Reply Quote 1
      • K
        kinduff
        last edited by

        Found this https://raw.githubusercontent.com/popcornmix/omxplayer/master/dbuscontrol.sh to control the omxplayer through dbus.

        Is there a way to bind some of these when running the command (clicking a rom)?

        mediamogulM 1 Reply Last reply Reply Quote 0
        • mediamogulM
          mediamogul Global Moderator @kinduff
          last edited by mediamogul

          @kinduff

          This is all very impressive, but why not just run the Twitch Addon through Kodi? You'd be able to browse all the channels, follow, unfollow, choose the quality of your video on the fly, etc. Don't get me wrong, I love tackling big homegrown tasks like your attempting myself sometimes, for no other reason than the challenge. I just want to make sure you know there's a ready-made alternative.

          RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

          K 1 Reply Last reply Reply Quote 0
          • K
            kinduff @mediamogul
            last edited by

            @mediamogul I considered that option as I already have Kodi + Twitch installed in the Pi, but I want to tackle this problem from Emulation Statation. If I manage to get a stable version of this, plus the features I'm thinking, I'll be able to tackle other problems that are similar.

            mediamogulM 1 Reply Last reply Reply Quote 0
            • mediamogulM
              mediamogul Global Moderator @kinduff
              last edited by

              @kinduff

              I gotta say, it's a very intriguing use of ES. I commend your efforts.

              RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

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

              Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

              Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.