Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Debdut committed Aug 12, 2017
0 parents commit aa88cac
Show file tree
Hide file tree
Showing 13 changed files with 777 additions and 0 deletions.
19 changes: 19 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2015 Debdut

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#### hotstarlivestreamer #### and #### starsportslivesreamer ####

##linux

first you can delete tools folder and hotstarlivestreamer.bat and starsportslivesreamer.bat it's for windows users

Dependencies livestreamer and PHP

run hotstarlivestreamer.sh or starsportslivesreamer.sh in terminal

./hotstarlivestreamer.sh or ./starsportslivesreamer.sh

and follow the instructions

by default the videos are downloaded in videos/
212 changes: 212 additions & 0 deletions hotstarlivestreamer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
<?php

$last=substr($argv[1], -1);

$testl="c";

if ($last==$testl){

$argv[1] = substr($argv[1], 0, strrpos($argv[1], "-"));

$argv[1] = substr($argv[1], strrpos($argv[1], "-"), 20);

$pidc=str_replace("-","",$argv[1]);

$collec="http://account.hotstar.com/AVS/besc?action=GetAggregatedContentDetails&channel=PCTV&contentId=$pidc";

$options = array('http' => array('user_agent' => 'custom user agent string'));

$context = stream_context_create($options);

$showc = file_get_contents($collec, false, $context);

$resultObj=json_decode($showc)->resultObj;

$contentInfo=$resultObj->{'contentInfo'};

$contentInfo2=($contentInfo[0]);

$realpidc = $contentInfo2->categoryId;

$collecs="http://account.hotstar.com/AVS/besc?action=GetArrayContentList&categoryId=$realpidc&channel=PCTV";

$showcs = file_get_contents($collecs, false, $context);

$resultObjs=json_decode($showcs)->resultObj;

$contentList=$resultObjs->{'contentList'};

if(isset($argv[2])){

$title="http://account.hotstar.com/AVS/besc?action=GetAggregatedContentDetails&channel=PCTV&contentId=$argv[2]";

$show = file_get_contents($title, false, $context);

$resultObj=json_decode($show)->resultObj;

$contentInfo=$resultObj->{'contentInfo'};

$contentInfo2=($contentInfo[0]);

$contentTitle = $contentInfo2->contentTitle; $contentTitle=str_replace(" ","-",$contentTitle);

$episodeTitle = $contentInfo2->episodeTitle; $episodeTitle=str_replace(" ","-",$episodeTitle);

$episodeNumber= $contentInfo2->episodeNumber; $episodeNumber="episode$episodeNumber";

$filename= "'$contentTitle'_'$episodeNumber'_'$episodeTitle'";

$filename=iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $filename);

$filename = preg_replace('/[^A-Za-z0-9_\. -]/', '', $filename);

$json="http://getcdn.hotstar.com/AVS/besc?action=GetCDN&asJson=Y&channel=TABLET&id=$argv[2]&type=VOD";

$test=file_get_contents($json, false, $context);

$obj=json_decode($test)->resultObj;

$hls=$obj->{'src'};

$testhttps=strpos($hls, 'https');

if($testhttps){
$m3u8p=str_replace("https","hlsvariant://https",$hls);
}
else{
$m3u8p=str_replace("http","hlsvariant://http",$hls);
}

$m3u8=str_replace("2000,_STAR.","2000,3000,4500,_STAR.",$m3u8p);

$badformat = array("4500","3000","2000","1300","800","400","180","106","54","16");

$googformat = array("1080p", "900p","720p","404p","360p","234p","","","","");

$quality = str_replace($badformat, $googformat, $m3u8);

$endq= strrpos($quality, ','); $beginq= strpos($quality, ','); $endrq = $endq - $beginq ;
$bitrate= substr($quality, $beginq , $endrq); $bitrate=str_replace(","," ",$bitrate);

if(isset($argv[3])){
}
else{
echo "Available streams: $bitrate\n";
}

}
else{
foreach($contentList as $r){
echo "Id:".$r->contentId." "."episodeTitle:".$r->episodeTitle." "."contentTitle:".$r->contentTitle."\n";
}
}
if(isset($argv[3]) AND isset($argv[2])){

echo "Starting livestreamer...\n\n";
echo shell_exec("$argv[5]livestreamer \"$m3u8\" \"$argv[3]\" -o \"$argv[4]$filename.ts\" &");
echo "Done.\n";
}
else{
}

}
else{

$folder = "";

$ppid= strrpos($argv[1], '/');

$id = substr($argv[1], $ppid);

$pid=str_replace("/","",$id);
$pid = substr($pid, -10);

$title="http://account.hotstar.com/AVS/besc?action=GetAggregatedContentDetails&channel=PCTV&contentId=$pid";

$json="http://getcdn.hotstar.com/AVS/besc?action=GetCDN&asJson=Y&channel=TABLET&id=$pid&type=VOD";

$options = array('http' => array('user_agent' => 'custom user agent string'));

$context = stream_context_create($options);

$show = file_get_contents($title, false, $context);

$resultObj=json_decode($show)->resultObj;

$contentInfo=$resultObj->{'contentInfo'};

$contentInfo2=($contentInfo[0]);

$contentTitle = $contentInfo2->contentTitle; $contentTitle=str_replace(" ","-",$contentTitle);

$episodeTitle = $contentInfo2->episodeTitle; $episodeTitle=str_replace(" ","-",$episodeTitle);

$episodeNumber= $contentInfo2->episodeNumber; $episodeNumber="episode$episodeNumber";

$filename= "'$contentTitle'_'$episodeNumber'_'$episodeTitle'";

$filename=iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $filename);

$filename = preg_replace('/[^A-Za-z0-9_\. -]/', '', $filename);

$test=file_get_contents($json, false, $context);

$obj=json_decode($test)->resultObj;

$hls=$obj->{'src'};

$testhttps=strpos($hls, 'https');

if($testhttps){
$m3u8p=str_replace("https","hlsvariant://https",$hls);

}
else{
$m3u8p=str_replace("http","hlsvariant://http",$hls);
}
$testhttps2=strpos($m3u8p, 'https');
if($testhttps2){
$m3u8=str_replace("2000,_STAR.","2000,3000,4500,_STAR.",$m3u8p);

}
else{
$m3u8=str_replace("2000,_STAR.","2000,_STAR.",$m3u8p);
}




$badformat = array("4500","3000","2000","1300","800","400","180","106","54","16");

$googformat = array("1080p", "900p","720p","404p","360p","234p","","","","");

$quality = str_replace($badformat, $googformat, $m3u8);

$endq= strrpos($quality, ','); $beginq= strpos($quality, ','); $endrq = $endq - $beginq ;
$bitrate= substr($quality, $beginq , $endrq);

$bitrate=str_replace(","," ",$bitrate);


if(isset($argv[2])){
if(isset($argv[2]) AND ($argv[5]=='d')){


echo "Starting livestreamer...\n\n";
echo shell_exec("$argv[4]livestreamer \"$m3u8\" \"$argv[2]\" -o \"$argv[3]$filename.ts\" &");
echo "Done.\n";
}
else{
echo "Starting livestreamer...\n\n";
echo shell_exec("$argv[4]livestreamer \"$m3u8\" \"$argv[2]\" &");
echo "Done.\n";
}
}
else{ echo "Available streams: $bitrate\n";
}



}

?>
21 changes: 21 additions & 0 deletions hotstarlivestreamer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#/bin/bash
echo "paste the link"
read link
last=${link: -1}
folder=$PWD/videos/
livestreamer=""
php hotstarlivestreamer.php "$link"
if [[ "$last" = "c" ]]
then echo "enter the Id of the video (example write 1000021386)"
read id
php hotstarlivestreamer.php "$link" "$id"
echo "write quality (example write 720p)"
read quality
php hotstarlivestreamer.php "$link" "$id" "$quality" "$folder" "$livestreamer"
else
echo "write quality (example write 720p)"
read quality
echo "play or download? (write p or d)"
read choice
php hotstarlivestreamer.php "$link" "$quality" "$folder" "$livestreamer" "$choice"
fi
113 changes: 113 additions & 0 deletions starsportslivestreamer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

$options = array('http' => array('user_agent' => 'custom user agent string'));

$context = stream_context_create($options);

$testlink=strpos($argv[1], '/vod/');
$testlink2=strpos($argv[1], '/live-video');
$testlink3=substr("$argv[1]", -1);
if($testlink){
goto yesvod;
}
else{
goto novod;
}

yesvod:
$prepidb= strpos($argv[1], 'video='); $prepide=strrpos($argv[1], '/'); $prepidef = $prepide - $prepidb ;
$prepid= substr($argv[1], $prepidb , $prepidef); $pid=str_replace("video=","",$prepid);
$json="http://m.starsports.com/syndicationdata/newmobile/video/video_details/$pid.json";
$showc = file_get_contents($json, false, $context);
$Video=json_decode($showc)->Video;
$pid=$Video->{'VideoId'};
goto endtest;



novod:
if($testlink2){
goto yeslive;
}
else{
goto nolive;
}
goto endtest;

yeslive:
$prepids=str_replace("/live-video","",$argv[1]);
$pid=substr("$prepids", -6);
$json="http://matchcentre.starsports.com/syndicationdata/newmobile/sportswire/cricket/match/$pid/videolist.json";
$showc = file_get_contents($json, false, $context);
$prepide= strpos($showc, 'Replay'); $prepidb=$prepide - 150; $prepidef = $prepide - $prepidb ;
$prepid= substr($showc, $prepidb , $prepidef);
$prepidb= strpos($prepid, '"VideoId": "'); $prepide=$prepidb + 19; $prepidef = $prepide - $prepidb ;
$prepid= substr($prepid, $prepidb , $prepidef); $pid = str_replace('"VideoId": "',"",$prepid);
goto endtest;


nolive:
if (eregi("^[0-9]",$testlink3)){
goto yesnumber;
}
else{
goto nonumber;
}
goto endtest;


yesnumber:
$prepid = substr($argv[1], strrpos($argv[1], "-"));
$pid = str_replace("-","",$prepid);
goto endtest;

nonumber:
goto allno;

allno:
$prepidb= strpos($argv[1], 'video='); $prepide=strrpos($argv[1], '/'); $prepidef = $prepide - $prepidb ;
$prepid= substr($argv[1], $prepidb , $prepidef); $pid=str_replace("video=","",$prepid);
$json="http://m.starsports.com/syndicationdata/newmobile/video/video_details/$pid.json";
$showc = file_get_contents($json, false, $context);
$Video=json_decode($showc)->Video;
$pid=$Video->{'VideoId'};
goto endtest;

endtest:

$json="http://www.starsports.com/divadata/output/VideoData/HLS/json/$pid.json";
$showc = file_get_contents($json, false, $context);
$m3u8=json_decode($showc)->videosource;
$rhls="http://m.starsports.com/tokens/portal/test/iOSStream.aspx?url=$m3u8";
$rrhls = file_get_contents($rhls, false, $context);
$m3u8final=json_decode($rrhls)->url;
$filename=json_decode($showc)->SEO;
$m3u8final=str_replace("http","hlsvariant://http",$m3u8final);







if(isset($argv[3])){
if(isset($argv[3]) AND ($argv[5]=='d')){


echo "Starting livestreamer...\n\n";
echo shell_exec("$argv[4]livestreamer \"$m3u8final\" \"$argv[2]\" -o \"$argv[3]$filename.ts\" &");
echo "Done.\n";
}
else{
echo "Starting livestreamer...\n\n";
echo shell_exec("$argv[4]livestreamer \"$m3u8final\" \"$argv[2]\" &");
echo "Done.\n";
}
}
else{
echo "Starting livestreamer...\n\n";
echo shell_exec("$argv[2]livestreamer \"$m3u8final\" &");
}


?>
11 changes: 11 additions & 0 deletions starsportslivestreamer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#/bin/bash
echo "paste the link"
read link
folder=$PWD/videos/
livestreamer=""
php starsportslivestreamer.php "$link" "$livestreamer"
echo "write quality (example write 720p)"
read quality
echo "play or download? (write p or d)"
read choice
php starsportslivestreamer.php "$link" "$quality" "$folder" "$livestreamer" "$choice"
Loading

0 comments on commit aa88cac

Please sign in to comment.