Skip to content

Instantly share code, notes, and snippets.

@hubgit
Last active September 26, 2015 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hubgit/50086412ffb6f0e830e6 to your computer and use it in GitHub Desktop.
Save hubgit/50086412ffb6f0e830e6 to your computer and use it in GitHub Desktop.
Play the ITV Player live stream (MP4) in system media player
<?php
// pip install livestreamer
$doc = new DOMDocument;
$doc->load('http://www.itv.com/ukonly/mediaplayer/xml/sim1static.xml');
$xpath = new DOMXPath($doc);
$url = $xpath->evaluate('string(//ManifestFile/URL)');
$arg = sprintf(
'%s pvswf="%s"',
preg_replace('/^http:/', 'hds:', $url),
'https://www.itv.com/mediaplayer/ITVMediaPlayer.swf'
);
// add --output="filename.mp4" to save to a file
$command = sprintf('livestreamer %s best', escapeshellarg($arg));
//print $command;
exec($command);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment