Skip to content

Instantly share code, notes, and snippets.

@L3viathan
Last active August 27, 2018 01:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L3viathan/4bb4a9f2efc6e94fc3a2 to your computer and use it in GitHub Desktop.
Save L3viathan/4bb4a9f2efc6e94fc3a2 to your computer and use it in GitHub Desktop.
Using the undocumented kinox.to API, extract stream URLs from a query.
#!/bin/sh
# Get stream URLs for the second episode of the seventh season of futurama:
# kinox.sh futurama 7 2
# for shows with spaces, insert a plus sign instead:
# kinox.sh it+crowd 3 1
# grab the stream by searching for the show on kinox.to, filtering to only show english versions, and extracting the internal show name
export stream_page=$(curl -sL "http://kinox.to/Search.html?q=$1" | pcregrep -M 'lng\/2\.png(\n|.)+?class="Title"' | pcregrep -o1 'Stream\/(.+?)\.html' | head -n 1)
# get the show's page, with the undocumented additional parameters for season and episode, and grab the "rel" attribute of the hoster list
export stream_rel=$(curl -sL http://kinox.to/Stream/$stream_page.html,s$2e$3 |grep rel= | pcregrep -o1 '<li i.+?rel="(.+?)"' | perl -pe 's/&amp;/&/g')
# for every rel attribute (which will contain season, episode, hoster id and mirror id)
while read -r line; do
# call the "secret" API. This will yield a JSON object, but since we're only interested in one attribute, we'll throw some regex on top and print the list of stream urls
curl -sL "http://kinox.to/aGET/Mirror/$line" | pcregrep -o1 'map> <a href=\\"(.+?)\\"' | tr -d '\' |perl -pe 's/\/Out\/\?s=//g'
done <<< "$stream_rel"
@TomAtGithub
Copy link

Hey really nice code. How did you found out about the kinox api ?

@vbprofi
Copy link

vbprofi commented Dec 13, 2017

Hi,
do you have an example for kodi's livestreams pro?
I need an example in python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment