main
widevinedump 9 months ago
parent d4d86d2657
commit 5cdfeb268f
  1. 2
      README.md
  2. 3
      sparksport/.htaccess
  3. 10
      sparksport/att.bin
  4. BIN
      sparksport/cert_license_widevine_com.bin
  5. 18
      sparksport/get_channel_info.php
  6. 28
      sparksport/includes/config.php
  7. 174
      sparksport/includes/utils.php
  8. 0
      sparksport/index.php
  9. 99
      sparksport/key.php
  10. BIN
      sparksport/sparksport/.DS_Store
  11. 3
      sparksport/sparksport/.htaccess
  12. 10
      sparksport/sparksport/att.bin
  13. BIN
      sparksport/sparksport/cert_license_widevine_com.bin
  14. 18
      sparksport/sparksport/get_channel_info.php
  15. 28
      sparksport/sparksport/includes/config.php
  16. 174
      sparksport/sparksport/includes/utils.php
  17. 0
      sparksport/sparksport/index.php
  18. 99
      sparksport/sparksport/key.php

@ -1,2 +1,4 @@
# Sparks Sports IPTV Script
live iptv script
Full update script in next commit

@ -0,0 +1,3 @@
RewriteEngine on
RewriteRule ^widevine/proxy$ key.php
RewriteRule ^channel/info$ get_channel_info.php

@ -0,0 +1,10 @@

*
sfԹeG ;bNsfԹeG ;bN (f(?WϨ_qwPy_[rp6JҼTfS;u( 'p'!{d4gT*]ݓ
w69>E=) V
q8d'27
" 5RU/6WO) G,CLQQB{4rr>% (2* bSD P
D:s
дbZ,",y|:}iBaEL8HOft{<(8|&
*3~ǼQ5dK|=0u)E[˺4[okG%"KLU /hxTm6˼|(e"lnA.&ɷXmOaa;K7:&&K0ێ;#1])jKo6](83M!W/].{xe:3
116.3.2 Built on Aug 24 2020 14:41:03 (1598305263)@X

@ -0,0 +1,18 @@
<?php
require_once("includes/config.php");
require_once("includes/utils.php");
header("Content-Type: text/plain");
if (!isset($_GET["id"]))
{
echo "Bad request";
exit();
}
$id = $_GET["id"];
$channelMpd = GetChannelMPD($id);
echo $channelMpd;

@ -0,0 +1,28 @@
<?php
/*
================================
LICENSE SERVER
Script configuration
================================
*/
$SPARK_ACCOUNT_USERNAME = "bryan@simpsonsinnott.co.nz";
$SPARK_ACCOUNT_PASSWORD = "thomas1512";
//For get the Account Device ID run this command in python (future improvement: do this auto)
// deviceid = str(uuid.uuid3(uuid.UUID("124f1611-0232-4336-be43-e054c8ecd0d5"), str("roger@hockeyinfo.org.nz")))
// print(deviceid)
// copy the result and insert in the $SPARK_ACCOUNT_DEVICE_ID variable
$SPARK_ACCOUNT_DEVICE_ID = "c4a5f4fc-d582-398c-9f4b-be67b4faee39";
$SPARK_DEFAULT_TOKEN = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiYXBpIiwidWlkIjoiIiwiYW5vbiI6ZmFsc2UsInBlcm1pc3Npb25zIjpudWxsLCJhcGlLZXkiOiIzODgyZGQ0My1lZGMwLTQ1YzktYTk5My05YWU0MzRhMWJlNjAiLCJvcmlnaW5hbFRlbmFudCI6IiIsImV4cCI6MzExNTY0NTQ0MiwiaWF0IjoxNTM4ODQ1NDQyLCJpc3MiOiJPcmJpcy1PQU0tVjEiLCJzdWIiOiIzODgyZGQ0My1lZGMwLTQ1YzktYTk5My05YWU0MzRhMWJlNjAifQ.E5Kos46Qp6YPh5-t6cqLf854i2IAEQEZ_MNDQDBcEKzQpGXY3RGAjG1-pe9qeQZOaqHq8OoyVIXiHyYg0tGllw";
$SPARK_DEFAULT_USERAGENT = "Spark Sport/0.1.1-0 (Linux;Android 8.1.0) ExoPlayerLib/2.9.2";
$SPARK_DEFAULT_DEVICE_USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36";
$SPARK_USER_TOKEN_API = "https://platform.prod.dtc.istreamplanet.net/oam/v1/user/tokens";
$SPARK_STOP_STREAM_API = "https://platform.prod.dtc.istreamplanet.net/oxm/v1/streams/";
$SPARK_CHANNELS_API = "https://platform.prod.dtc.istreamplanet.net/ocm/v2/epg/stations";
$SPARK_MPD_API = "https://platform.prod.dtc.istreamplanet.net/ocm/v2/assets/";
$SPARK_ENTITLEMENT_TOKEN = "https://platform.prod.dtc.istreamplanet.net/oem/v2/entitlement?tokentype=isp-atlas";
$SPARK_DRM_WIDEVINE_PROXY = "https://widevine.license.istreamplanet.com/widevine/api/license/0f6160eb-bbd3-4c70-8e4d-0d485e7cb055";

@ -0,0 +1,174 @@
<?php
function GetLoginToken()
{
global $SPARK_USER_TOKEN_API;
global $SPARK_ACCOUNT_USERNAME;
global $SPARK_ACCOUNT_PASSWORD;
global $SPARK_ACCOUNT_DEVICE_ID;
global $SPARK_DEFAULT_TOKEN;
global $SPARK_DEFAULT_USERAGENT;
if (file_exists("login.token"))
{
$currentTime = time();
$tt = explode('.',file_get_contents("login.token"))[1];
$json = json_decode(base64_decode($tt));
$expTime = $json->exp;
if ($currentTime < $expTime)
{
return file_get_contents("login.token");
}
else
{
$ch = curl_init($SPARK_USER_TOKEN_API);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . $SPARK_DEFAULT_TOKEN,
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'{"username":"' . $SPARK_ACCOUNT_USERNAME . '", "password":"' . $SPARK_ACCOUNT_PASSWORD . '", "deviceID": "' . $SPARK_ACCOUNT_DEVICE_ID . '"}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content);
file_put_contents("login.token",$json->sessionToken);
return $json->sessionToken;
}
}
else
{
$ch = curl_init($SPARK_USER_TOKEN_API);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . $SPARK_DEFAULT_TOKEN,
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'{"username":"' . $SPARK_ACCOUNT_USERNAME . '", "password":"' . $SPARK_ACCOUNT_PASSWORD . '", "deviceID": "' . $SPARK_ACCOUNT_DEVICE_ID . '"}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content);
file_put_contents("login.token",$json->sessionToken);
return $json->sessionToken;
}
}
function PutOffLastChannel()
{
global $SPARK_STOP_STREAM_API;
global $SPARK_DEFAULT_USERAGENT;
if (file_exists("last_channel.id"))
{
$lastChannelID = file_get_contents("last_channel.id");
$ch = curl_init($SPARK_STOP_STREAM_API . $lastChannelID . "/stopped");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . GetLoginToken(),
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
//
unlink("last_channel.id");
}
}
function GetChannelAssetID($id)
{
global $SPARK_CHANNELS_API;
global $SPARK_DEFAULT_USERAGENT;
$ch = curl_init($SPARK_CHANNELS_API);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . GetLoginToken(),
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content,1);
foreach($json["epg/stations"] as $stations)
{
if ($stations["id"] == $id)
{
return $stations["assetIDs"][0];
}
}
return "not-found";
}
function GetChannelMPD($id)
{
global $SPARK_MPD_API;
global $SPARK_DEFAULT_USERAGENT;
$channelAssetID = GetChannelAssetID($id);
$ch = curl_init($SPARK_MPD_API . $channelAssetID);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . GetLoginToken(),
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content,1);
return $json["assets"][0]["liveURLs"]["dash"]["primary"];
}
function GetEntitlementToken($id,$mpdUrl)
{
global $SPARK_ENTITLEMENT_TOKEN;
global $SPARK_ACCOUNT_DEVICE_ID;
global $SPARK_DEFAULT_USERAGENT;
$channelAssetID = GetChannelAssetID($id);
$ch = curl_init($SPARK_ENTITLEMENT_TOKEN);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . GetLoginToken(),
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'{"assetID":"' . $id . '", "playbackUrl":"' . $mpdUrl . '", "deviceID": "' . $SPARK_ACCOUNT_DEVICE_ID . '"}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content);
return $json->entitlementToken;
}

@ -0,0 +1,99 @@
<?php
require_once("includes/config.php");
require_once("includes/utils.php");
//Set comments here in PROD
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
header('Access-Control-Allow-Origin: *');
function stringToBinary($string)
{
$characters = str_split($string);
$binary = [];
foreach ($characters as $character) {
$data = unpack('H*', $character);
$binary[] = base_convert($data[1], 16, 2);
}
return implode(' ', $binary);
}
function binaryToJsonChallenge($split)
{
$count = count($split);
$conv = array();
for($i=0;$i<$count;$i++)
{
array_push($conv,bindec(stringToBinary($split[$i])));
}
return json_encode($conv);
}
if (!isset($_GET["id"]))
{
header("Content-Type: text/plain");
echo "Bad request";
exit();
}
if (!isset($_GET["mpd"]))
{
header("Content-Type: text/plain");
echo "Bad request";
exit();
}
$id = $_GET["id"]; //"67d48a06-73c9-4aff-83ba-24f9b06b2af5"
$mpdUrl = base64_decode($_GET["mpd"]); //"https://spark.akamaized.net/dash/live/2014359/spark/trackside1_spark/master.mpd"
$ch = curl_init();
$postdata = file_get_contents("php://input");
if(base64_encode($postdata) == 'CAQ=')
{
$split = str_split($postdata);
}
else
{
$split = str_split($postdata);
}
curl_setopt($ch, CURLOPT_URL, $SPARK_DRM_WIDEVINE_PROXY);
curl_setopt($ch, CURLOPT_USERAGENT, $SPARK_DEFAULT_DEVICE_USERAGENT);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Origin: https://www.sparksport.co.nz',
'Host: widevine.license.istreamplanet.com',
'Referer: https://www.sparksport.co.nz/epg/a9240df1-c6c7-4d2a-96a6-9ff28da0fd07',
'User-Agent: ' . $SPARK_DEFAULT_DEVICE_USERAGENT,
'X-ISP-TOKEN: ' . GetEntitlementToken($id,$mpdUrl),
'Origin: https://www.sparksport.co.nz',
'Accept-Language: es-419,es;q=0.9,en;q=0.8',
'Accept-Encoding: gzip, deflate, br'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$result = curl_exec($ch);
if (curl_errno($ch))
{
echo 'CURL ERROR: ' . curl_error($ch);
}
curl_close($ch);
file_put_contents('challenge.bin', base64_encode($postdata));
file_put_contents('response.bin', base64_encode($result));
echo $result;

Binary file not shown.

@ -0,0 +1,3 @@
RewriteEngine on
RewriteRule ^widevine/proxy$ key.php
RewriteRule ^channel/info$ get_channel_info.php

@ -0,0 +1,10 @@

*
sfԹeG ;bNsfԹeG ;bN (f(?WϨ_qwPy_[rp6JҼTfS;u( 'p'!{d4gT*]ݓ
w69>E=) V
q8d'27
" 5RU/6WO) G,CLQQB{4rr>% (2* bSD P
D:s
дbZ,",y|:}iBaEL8HOft{<(8|&
*3~ǼQ5dK|=0u)E[˺4[okG%"KLU /hxTm6˼|(e"lnA.&ɷXmOaa;K7:&&K0ێ;#1])jKo6](83M!W/].{xe:3
116.3.2 Built on Aug 24 2020 14:41:03 (1598305263)@X

@ -0,0 +1,18 @@
<?php
require_once("includes/config.php");
require_once("includes/utils.php");
header("Content-Type: text/plain");
if (!isset($_GET["id"]))
{
echo "Bad request";
exit();
}
$id = $_GET["id"];
$channelMpd = GetChannelMPD($id);
echo $channelMpd;

@ -0,0 +1,28 @@
<?php
/*
================================
LICENSE SERVER
Script configuration
================================
*/
$SPARK_ACCOUNT_USERNAME = "bryan@simpsonsinnott.co.nz";
$SPARK_ACCOUNT_PASSWORD = "thomas1512";
//For get the Account Device ID run this command in python (future improvement: do this auto)
// deviceid = str(uuid.uuid3(uuid.UUID("124f1611-0232-4336-be43-e054c8ecd0d5"), str("roger@hockeyinfo.org.nz")))
// print(deviceid)
// copy the result and insert in the $SPARK_ACCOUNT_DEVICE_ID variable
$SPARK_ACCOUNT_DEVICE_ID = "c4a5f4fc-d582-398c-9f4b-be67b4faee39";
$SPARK_DEFAULT_TOKEN = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiYXBpIiwidWlkIjoiIiwiYW5vbiI6ZmFsc2UsInBlcm1pc3Npb25zIjpudWxsLCJhcGlLZXkiOiIzODgyZGQ0My1lZGMwLTQ1YzktYTk5My05YWU0MzRhMWJlNjAiLCJvcmlnaW5hbFRlbmFudCI6IiIsImV4cCI6MzExNTY0NTQ0MiwiaWF0IjoxNTM4ODQ1NDQyLCJpc3MiOiJPcmJpcy1PQU0tVjEiLCJzdWIiOiIzODgyZGQ0My1lZGMwLTQ1YzktYTk5My05YWU0MzRhMWJlNjAifQ.E5Kos46Qp6YPh5-t6cqLf854i2IAEQEZ_MNDQDBcEKzQpGXY3RGAjG1-pe9qeQZOaqHq8OoyVIXiHyYg0tGllw";
$SPARK_DEFAULT_USERAGENT = "Spark Sport/0.1.1-0 (Linux;Android 8.1.0) ExoPlayerLib/2.9.2";
$SPARK_DEFAULT_DEVICE_USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36";
$SPARK_USER_TOKEN_API = "https://platform.prod.dtc.istreamplanet.net/oam/v1/user/tokens";
$SPARK_STOP_STREAM_API = "https://platform.prod.dtc.istreamplanet.net/oxm/v1/streams/";
$SPARK_CHANNELS_API = "https://platform.prod.dtc.istreamplanet.net/ocm/v2/epg/stations";
$SPARK_MPD_API = "https://platform.prod.dtc.istreamplanet.net/ocm/v2/assets/";
$SPARK_ENTITLEMENT_TOKEN = "https://platform.prod.dtc.istreamplanet.net/oem/v2/entitlement?tokentype=isp-atlas";
$SPARK_DRM_WIDEVINE_PROXY = "https://widevine.license.istreamplanet.com/widevine/api/license/0f6160eb-bbd3-4c70-8e4d-0d485e7cb055";

@ -0,0 +1,174 @@
<?php
function GetLoginToken()
{
global $SPARK_USER_TOKEN_API;
global $SPARK_ACCOUNT_USERNAME;
global $SPARK_ACCOUNT_PASSWORD;
global $SPARK_ACCOUNT_DEVICE_ID;
global $SPARK_DEFAULT_TOKEN;
global $SPARK_DEFAULT_USERAGENT;
if (file_exists("login.token"))
{
$currentTime = time();
$tt = explode('.',file_get_contents("login.token"))[1];
$json = json_decode(base64_decode($tt));
$expTime = $json->exp;
if ($currentTime < $expTime)
{
return file_get_contents("login.token");
}
else
{
$ch = curl_init($SPARK_USER_TOKEN_API);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . $SPARK_DEFAULT_TOKEN,
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'{"username":"' . $SPARK_ACCOUNT_USERNAME . '", "password":"' . $SPARK_ACCOUNT_PASSWORD . '", "deviceID": "' . $SPARK_ACCOUNT_DEVICE_ID . '"}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content);
file_put_contents("login.token",$json->sessionToken);
return $json->sessionToken;
}
}
else
{
$ch = curl_init($SPARK_USER_TOKEN_API);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . $SPARK_DEFAULT_TOKEN,
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'{"username":"' . $SPARK_ACCOUNT_USERNAME . '", "password":"' . $SPARK_ACCOUNT_PASSWORD . '", "deviceID": "' . $SPARK_ACCOUNT_DEVICE_ID . '"}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content);
file_put_contents("login.token",$json->sessionToken);
return $json->sessionToken;
}
}
function PutOffLastChannel()
{
global $SPARK_STOP_STREAM_API;
global $SPARK_DEFAULT_USERAGENT;
if (file_exists("last_channel.id"))
{
$lastChannelID = file_get_contents("last_channel.id");
$ch = curl_init($SPARK_STOP_STREAM_API . $lastChannelID . "/stopped");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . GetLoginToken(),
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
//
unlink("last_channel.id");
}
}
function GetChannelAssetID($id)
{
global $SPARK_CHANNELS_API;
global $SPARK_DEFAULT_USERAGENT;
$ch = curl_init($SPARK_CHANNELS_API);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . GetLoginToken(),
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content,1);
foreach($json["epg/stations"] as $stations)
{
if ($stations["id"] == $id)
{
return $stations["assetIDs"][0];
}
}
return "not-found";
}
function GetChannelMPD($id)
{
global $SPARK_MPD_API;
global $SPARK_DEFAULT_USERAGENT;
$channelAssetID = GetChannelAssetID($id);
$ch = curl_init($SPARK_MPD_API . $channelAssetID);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . GetLoginToken(),
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content,1);
return $json["assets"][0]["liveURLs"]["dash"]["primary"];
}
function GetEntitlementToken($id,$mpdUrl)
{
global $SPARK_ENTITLEMENT_TOKEN;
global $SPARK_ACCOUNT_DEVICE_ID;
global $SPARK_DEFAULT_USERAGENT;
$channelAssetID = GetChannelAssetID($id);
$ch = curl_init($SPARK_ENTITLEMENT_TOKEN);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'User-Agent: ' . $SPARK_DEFAULT_USERAGENT,
'Authorization: Bearer ' . GetLoginToken(),
'X-Forwarded-For: 202.89.4.222'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'{"assetID":"' . $id . '", "playbackUrl":"' . $mpdUrl . '", "deviceID": "' . $SPARK_ACCOUNT_DEVICE_ID . '"}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content);
return $json->entitlementToken;
}

@ -0,0 +1,99 @@
<?php
require_once("includes/config.php");
require_once("includes/utils.php");
//Set comments here in PROD
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
header('Access-Control-Allow-Origin: *');
function stringToBinary($string)
{
$characters = str_split($string);
$binary = [];
foreach ($characters as $character) {
$data = unpack('H*', $character);
$binary[] = base_convert($data[1], 16, 2);
}
return implode(' ', $binary);
}
function binaryToJsonChallenge($split)
{
$count = count($split);
$conv = array();
for($i=0;$i<$count;$i++)
{
array_push($conv,bindec(stringToBinary($split[$i])));
}
return json_encode($conv);
}
if (!isset($_GET["id"]))
{
header("Content-Type: text/plain");
echo "Bad request";
exit();
}
if (!isset($_GET["mpd"]))
{
header("Content-Type: text/plain");
echo "Bad request";
exit();
}
$id = $_GET["id"]; //"67d48a06-73c9-4aff-83ba-24f9b06b2af5"
$mpdUrl = base64_decode($_GET["mpd"]); //"https://spark.akamaized.net/dash/live/2014359/spark/trackside1_spark/master.mpd"
$ch = curl_init();
$postdata = file_get_contents("php://input");
if(base64_encode($postdata) == 'CAQ=')
{
$split = str_split($postdata);
}
else
{
$split = str_split($postdata);
}
curl_setopt($ch, CURLOPT_URL, $SPARK_DRM_WIDEVINE_PROXY);
curl_setopt($ch, CURLOPT_USERAGENT, $SPARK_DEFAULT_DEVICE_USERAGENT);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Origin: https://www.sparksport.co.nz',
'Host: widevine.license.istreamplanet.com',
'Referer: https://www.sparksport.co.nz/epg/a9240df1-c6c7-4d2a-96a6-9ff28da0fd07',
'User-Agent: ' . $SPARK_DEFAULT_DEVICE_USERAGENT,
'X-ISP-TOKEN: ' . GetEntitlementToken($id,$mpdUrl),
'Origin: https://www.sparksport.co.nz',
'Accept-Language: es-419,es;q=0.9,en;q=0.8',
'Accept-Encoding: gzip, deflate, br'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$result = curl_exec($ch);
if (curl_errno($ch))
{
echo 'CURL ERROR: ' . curl_error($ch);
}
curl_close($ch);
file_put_contents('challenge.bin', base64_encode($postdata));
file_put_contents('response.bin', base64_encode($result));
echo $result;
Loading…
Cancel
Save