From df5edfdc36e22a48793e9ce5df1601afcd548fae Mon Sep 17 00:00:00 2001 From: ibajrami Date: Wed, 18 May 2016 12:01:06 -0400 Subject: [PATCH 1/2] Added option to select network interface --- AdobeHDS.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/AdobeHDS.php b/AdobeHDS.php index 939f069..cfa2fce 100644 --- a/AdobeHDS.php +++ b/AdobeHDS.php @@ -98,12 +98,12 @@ function getParam($name) class cURL { - var $headers, $user_agent, $compression, $cookie_file; + var $headers, $user_agent, $compression, $cookie_file, $network_interface; var $active, $cert_check, $fragProxy, $maxSpeed, $proxy, $response; var $mh, $ch, $mrc; static $ref = 0; - function __construct($cookies = true, $cookie = 'Cookies.txt', $compression = 'gzip', $proxy = '') + function __construct($cookies = true, $cookie = 'Cookies.txt', $compression = 'gzip', $proxy = '', $network_interface = '') { $this->headers = $this->headers(); $this->user_agent = 'Mozilla/5.0 (Windows NT 5.1; rv:41.0) Gecko/20100101 Firefox/41.0'; @@ -115,6 +115,7 @@ function __construct($cookies = true, $cookie = 'Cookies.txt', $compression = 'g $this->fragProxy = false; $this->maxSpeed = 0; $this->proxy = $proxy; + $this->network_interface = $network_interface; self::$ref++; } @@ -167,6 +168,8 @@ function get($url) } if ($this->proxy) $this->setProxy($process, $this->proxy); + if ($this->network_interface) + curl_setopt($process, CURLOPT_INTERFACE, $this->network_interface); $this->response = curl_exec($process); if ($this->response !== false) $status = curl_getinfo($process, CURLINFO_HTTP_CODE); @@ -203,6 +206,8 @@ function post($url, $data) } if ($this->proxy) $this->setProxy($process, $this->proxy); + if ($this->network_interface) + curl_setopt($process, CURLOPT_INTERFACE, $this->network_interface); $return = curl_exec($process); curl_close($process); return $return; @@ -263,6 +268,8 @@ function addDownload($url, $id) } if ($this->fragProxy and $this->proxy) $this->setProxy($download['ch'], $this->proxy); + if ($this->network_interface) + curl_setopt($download['ch'], CURLOPT_INTERFACE, $this->network_interface); if ($this->maxSpeed > 0) curl_setopt($download['ch'], CURLOPT_MAX_RECV_SPEED_LARGE, $this->maxSpeed); curl_multi_add_handle($this->mh, $download['ch']); @@ -2039,6 +2046,7 @@ function value_in_array_field($needle, $needle_field, $value_field, $haystack, $ 'fixwindow' => 'timestamp gap between frames to consider as timeshift', 'manifest' => 'manifest file for downloading of fragments', 'maxspeed' => 'maximum bandwidth consumption (KB) for fragment downloading', + 'networkinterface' => 'this can be an interface name, an IP address or a host name', 'outdir' => 'destination folder for output file', 'outfile' => 'filename to use for output file', 'parallel' => 'number of fragments to download simultaneously', @@ -2122,6 +2130,8 @@ function value_in_array_field($needle, $needle_field, $value_field, $haystack, $ $f4f->parallel = $cli->getParam('parallel'); if ($cli->getParam('proxy')) $cc->proxy = $cli->getParam('proxy'); + if ($cli->getParam('networkinterface')) + $cc->network_interface = $cli->getParam('networkinterface'); if ($cli->getParam('quality')) $f4f->quality = $cli->getParam('quality'); if ($cli->getParam('referrer')) From d88b8c5f0484ba011a674b497d0d5b1a9b5c977f Mon Sep 17 00:00:00 2001 From: ibajrami Date: Wed, 18 May 2016 12:18:39 -0400 Subject: [PATCH 2/2] Moved the network interface option to respect order --- AdobeHDS.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AdobeHDS.php b/AdobeHDS.php index cfa2fce..7ec8a84 100644 --- a/AdobeHDS.php +++ b/AdobeHDS.php @@ -2122,6 +2122,8 @@ function value_in_array_field($needle, $needle_field, $value_field, $haystack, $ $manifest = $cli->getParam('manifest'); if ($cli->getParam('maxspeed')) $maxSpeed = $cli->getParam('maxspeed'); + if ($cli->getParam('networkinterface')) + $cc->network_interface = $cli->getParam('networkinterface'); if ($cli->getParam('outdir')) $outDir = $cli->getParam('outdir'); if ($cli->getParam('outfile')) @@ -2130,8 +2132,6 @@ function value_in_array_field($needle, $needle_field, $value_field, $haystack, $ $f4f->parallel = $cli->getParam('parallel'); if ($cli->getParam('proxy')) $cc->proxy = $cli->getParam('proxy'); - if ($cli->getParam('networkinterface')) - $cc->network_interface = $cli->getParam('networkinterface'); if ($cli->getParam('quality')) $f4f->quality = $cli->getParam('quality'); if ($cli->getParam('referrer'))