This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Twitch.Tv / Justin.Tv stream links.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
b
bosseb
Voice
Posts: 8
Joined: Mon Dec 24, 2012 7:28 pm

Twitch.Tv / Justin.Tv stream links.

Post by bosseb »

Hi

The request is for a script that'll make eggdrop give out links to hls streams from twitch.tv/justin.tv
!tw esltv_sc2

or

!tw esltv_sc2 720p
!tw elstv_sc2 1080p
!tw elstv_sc2 source
!tw elstv_sc2 all

Mainly it should respond with the hls stream(s), and of course if nothing is live then it should respond with offline or something.
the reason for using the hls streams is that everyone can use them, you can watch them directly in vlc,mpc etc. thus not having to
defile your computer with adobe flash, and also giving you a lot more options with your video player.

being able to set default stream quality as configuration would be nice, as would being able to set min/max quality shown
and also what should be shown when there are no arguments provided.


Of course giving a bit of info about the stream would be nice as well (name/title/game/etc).

and having the links shortened would be nice as well (tinyurl or similar)
since they are quite long.

things that might help are listed below..

(Twitch: esltv_sc2 -- Polt vs. MaNa - Group C - IEM Cologne (StarCraft II: Heart of the Swarm), 32593 viewers)
^- this is already output from another twitch script (twitch.tcl by manellermus)


Below is a python script which takes streamname as argument and returns the link to the hls stream
http://www.johannesbader.ch/2014/01/fin ... roadcasts/
------------------------------------------------------------------------------------------------------
import requests
import json
import re
import argparse

USHER_API = 'http://usher.twitch.tv/select/{channel}.json' +\
'?nauthsig={sig}&nauth={token}&allow_source=true'
TOKEN_API = 'http://api.twitch.tv/api/channels/{chan ... cess_token'

def get_token_and_signature(channel):
url = TOKEN_API.format(channel=channel)
r = requests.get(url)
txt = r.text

data = json.loads(txt)
sig = data['sig']
token = data['token']
return token, sig

def get_live_stream(channel):
token, sig = get_token_and_signature(channel)
url = USHER_API.format(channel=channel, sig=sig, token=token)
r = requests.get(url)
txt = r.text
for line in txt.split('\n'):
if re.match('https?://.*', line):
return line

if __name__=="__main__":
parser = argparse.ArgumentParser('get video url of twitch channel')
parser.add_argument('channel_name')
args = parser.parse_args()
print( get_live_stream(args.channel_name) )
----------------------------------------------------------------------------

This page: http://bog.no-ip.biz/sc2/stream2vlc.php lets a user select quality wanted
and then gives you a stream.

https://github.com/justintv/twitch-api
there is the twitch api..

:)
Post Reply