Advertisement
JustUsChickens

Project Free TV Shell Script / Download TV Shows / PHP

Feb 17th, 2013
1,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.95 KB | None | 0 0
  1. #!/usr/bin/php -q
  2. <?php
  3.  
  4. /*
  5.  *  PHP CLI script to download tv shows from from "Project - Free TV"
  6.  *  http://www.free-tv-video-online.me
  7.  *
  8.  *  Notes
  9.  *
  10.  *      this is a quick and dirty script to download TV shows from the command line
  11.  *      it is not polished and only supports a few video hosts.  Future versions may be better
  12.  *      structured, supporting video site drivers as loadable objects, but this meets my needs for
  13.  *      now.
  14.  *
  15.  *      It is easily used by other shell scripts to do things like scheduled batch downloads
  16.  *      of TV series with less risk or bandwidth requirement than bittorrent.
  17.  *
  18.  *      Downloaded video files are usually in .flv or .mp4 format and can be played with VLC,
  19.  *      mplayer, etc.
  20.  *
  21.  *      Keep it neat: tabs are 4 spaces
  22.  *
  23.  *  Installation
  24.  *
  25.  *      This script is written for common Debian-derived linux systems, but may me made to work
  26.  *      on any OS with a little tinkering.  To install one will first need PHP CLI:
  27.  *
  28.  *          sudo apt-get install php5-cli php5-curl youtube-dl
  29.  *
  30.  *      Then copy this script somewhere in global PATH and make executable:
  31.  *
  32.  *          sudo cp ./pftv /usr/bin/pftv
  33.  *          sudo chmod +x /usr/bin/pftv
  34.  *
  35.  *  Extending
  36.  *
  37.  *      It should be a simple matter to add other video hosting services such as youtube to the
  38.  *      set which this script can use, expecially if one can assume other scripts such as
  39.  *      youtube-dl.
  40.  *
  41.  *      It should also be a fairly simple matter to extend this to download movies linked from the
  42.  *      Project - Free TV site.  Have not done so since the quality of move links is so unreliable.
  43.  *
  44.  *  @version:   0.0 alpha
  45.  *  @author:    Anonymous
  46.  *  @date:      2013-02-01
  47.  */
  48.  
  49.     /*
  50.      *  Globals (ugly ugly globals)
  51.      */
  52.  
  53.     $a_show = '';               //  Show name, eg 'the_wire', 'futurama' [string]
  54.     $a_season = '';             //  Show season, integer as string [string]
  55.     $a_episode = '';            //  Episode number in this season , eg "e1", "e12" [string[
  56.     $a_link = '';               //  Link number, eg "l0", "l3" [string]
  57.  
  58.     /*
  59.      *  Interpret command line args
  60.      */
  61.  
  62.     if (false == array_key_exists(1, $argv)) { printHelp(); die(); }
  63.  
  64.     if (true == array_key_exists(1, $argv)) {
  65.         if (('--list' == $argv[1]) || ('-l' == $argv[1])) { listShows(); die(); }
  66.         if (('--help' == $argv[1]) || ('-h' == $argv[1])) { printHelp(); die(); }
  67.        
  68.         if (('--version' == $argv[1]) || ('-v' == $argv[1])) {
  69.             echo "Project - Free TV CLI\n";
  70.             echo "Version: 0.0 alpha\n";
  71.             die();
  72.         }
  73.  
  74.     }
  75.  
  76.     if (true == array_key_exists(1, $argv)) { $a_show = $argv[1]; }
  77.     if (true == array_key_exists(2, $argv)) { $a_season = str_replace('s', '', $argv[2]); }
  78.     if (true == array_key_exists(3, $argv)) { $a_episode = $argv[3]; }
  79.     if (true == array_key_exists(4, $argv)) { $a_link = $argv[4]; }
  80.  
  81.     if (5 == count($argv)) { downloadEpisode($a_show, $a_season, $a_episode, $a_link); die(); }
  82.     if (4 == count($argv)) { printEpisode($a_show, $a_season, $a_episode); die(); }
  83.     if (3 == count($argv)) { printSeason($a_show, $a_season); die(); }
  84.  
  85.     printHelp();
  86.     die();
  87.  
  88.     /**
  89.      *  Built in documentation
  90.      */
  91.  
  92.     function printHelp() {
  93.         echo ''
  94.          . "Project - Free TV CLI Script\n"
  95.          . "Usage: pftv [show] [season] [episode] [link]\n"
  96.          . "Usage: pftv --list\n\n"
  97.          . "Examples:\n\n"
  98.          . "    pftv --list\n"
  99.          . "    List shows available on the site.\n\n"
  100.          . "    pftv breaking_bad s2\n"
  101.          . "    List episodes and links for season two of 'Breaking Bad'\n\n"
  102.          . "    pftv futurama s4 e3\n"
  103.          . "    List links for Futurama s04e03 'Anthology of Interest II'\n\n"
  104.          . "    pftv futurama s4 e3 l0\n"
  105.          . "    Download Futurama s04e03 'Anthology of Interest II' from default link.\n\n"
  106.          . "    pftv --version\n"
  107.          . "    Print version of this script.\n\n"
  108.          . "    pftv --help\n"
  109.          . "    If you're reading this you've figured it out.\n\n"
  110.          . "\n";
  111.     }
  112.  
  113.     /**
  114.      *  Print list of shows currently available on http://www.free-tv-video-online.me/
  115.      */
  116.  
  117.     function listShows() {
  118.         $listingUrl = 'http://www.free-tv-video-online.me/internet/';
  119.         $raw = implode(file($listingUrl));
  120.         $lines = explode("\n", $raw);
  121.         foreach($lines as $line) {
  122.             if (false != strpos($line, 'class="mnlcategorylist"')) {
  123.                 $title = strip_tags($line);
  124.                 $showId = str_delim($line, 'href="', '/"');
  125.                 //echo "$showId ==> $title\n";
  126.                 echo "show: $showId\n";
  127.             }
  128.         }
  129.     }
  130.  
  131.     /**
  132.      *  Print a season listing
  133.      *  @param  $show       Identifier of a tv show, eg 'the_wire', 'american_dad' [string]
  134.      *  @param  $season     Eg '1', '2', '3' [string]
  135.      */
  136.  
  137.     function printSeason($show, $season) {
  138.         echo "Finding episodes for $show season $season\n";
  139.         $list = listSeason($show, $season);
  140.         foreach($list as $eId => $episode) {
  141.             echo $eId . ": " . $episode['title'] . "\n";
  142.             foreach($episode['links'] as $lId => $link) {
  143.                 $link = str_replace('http://www.free-tv-video-online.me/player/', '../', $link);
  144.                 echo "    " .  $lId . ": " . $link . " (" . $list[$eId]['ratings'][$lId] . ")\n";
  145.             }
  146.             echo "\n";
  147.         }
  148.     }
  149.  
  150.     /**
  151.      *  Print list of links for an episode
  152.      *  @param  $show       Identifier of a tv show, eg 'the_wire', 'american_dad' [string]
  153.      *  @param  $season     Eg '1', '2', '3' [string]
  154.      *  @param  $episode    Eg '1', '2', '3' [string]
  155.      */
  156.  
  157.     function printEpisode($show, $season, $episode) {
  158.         echo "Finding links for $show season $season episode $episode \n";
  159.         $list = listSeason($show, $season);
  160.         $found = false;
  161.         foreach($list as $eId => $epData) {
  162.             if ($eId == $episode) {
  163.                 $found = true;
  164.                 echo $eId . ": " . $epData['title'] . "\n";
  165.                 foreach($epData['links'] as $lId => $link) {
  166.                     $link = str_replace('http://www.free-tv-video-online.me/player/', '../', $link);
  167.                     echo $lId . ": " . $link . " (" . $list[$eId]['ratings'][$lId] . ")\n";
  168.                 }
  169.             }
  170.         }
  171.         if (false == $found) {
  172.             echo "Unknown episode.\n";
  173.         }
  174.     }
  175.  
  176.  
  177.     /**
  178.      *  Read a season listing
  179.      *
  180.      *  This returns a nested array of episodes:
  181.      *
  182.      *  'e1' =>
  183.      *      [listing] => 'Some show season X'
  184.      *      [title] => 'Title of episode 1'
  185.      *      [links] => ['l1' => 'http://e1link1/', 'l2' => 'http://e1link2/', ...etc...]
  186.      *      [ratings] => ['l1' => '', 'l2' => '', ...etc...]
  187.      *  'e2' =>
  188.      *      [listing] => 'Some show season X'
  189.      *      [title] => 'Title of episode 2'
  190.      *      [links] => ['l1' => 'http://e2link1/', 'l2' => 'http://e2link2/', ...etc...]
  191.      *      [ratings] => ['l1' => '', 'l2' => '', ...etc...]
  192.      *
  193.      *  @param  $show   Show identifier as given by --list option
  194.      *  @param  $season '1', '2', etc
  195.      */
  196.  
  197.     function listSeason($show, $season) {
  198.         $retVal = array();
  199.        
  200.         $seasonUrl = "http://www.free-tv-video-online.me/internet/{$show}/season_{$season}.html";
  201.         $seasonPage = implode(file($seasonUrl));
  202.         $lines = explode("\n", $seasonPage);
  203.         $listing = '';
  204.         $episodeTitle = '';
  205.  
  206.         $eidx = 0;
  207.         $lidx = 0;
  208.  
  209.         foreach($lines as $line) {
  210.             //  get show / season title
  211.             if (false !== strpos($line, 'mnlbreadcrumbs')) {
  212.                 $listing = trim(strip_tags($line));
  213.                 //echo "Season Title: $listing\n";
  214.             }
  215.  
  216.             //  get episode title
  217.             if (false !== strpos($line, '<td class="episode">')) {
  218.                 $eidx++;
  219.                 $lidx = -1;
  220.                 $episodeTitle = trim(strip_tags($line));
  221.                 //echo "[e" . $eidx . "] Episode: $episodeTitle\n";
  222.                 $retVal['e' . $eidx] = array(
  223.                     'listing' => $listing,
  224.                     'title' => $episodeTitle,
  225.                     'links' => array(),
  226.                     'ratings' => array()
  227.                 );
  228.             }
  229.            
  230.             //  get episode links
  231.             if (
  232.                 (false !== strpos($line, 'http://www.free-tv-video-online.me/player/vreer')) ||
  233.                 (false !== strpos($line, 'http://www.free-tv-video-online.me/player/nowvideo')) ||
  234.                 (false !== strpos($line, 'http://www.free-tv-video-online.me/player/novamov')) ||
  235.                 (false !== strpos($line, 'http://www.free-tv-video-online.me/player/divxstage')) ||
  236.                 (false !== strpos($line, 'http://www.free-tv-video-online.me/player/gorillavid'))
  237.                 /* add your own download drivers here :-) */
  238.             ) {
  239.                 $lidx++;
  240.                 $playerUrl = str_delim($line, 'href="', '"');
  241.                 //echo "[e" . $eidx . "][l" . $lidx . "] $playerUrl\n";
  242.                 $retVal['e' . $eidx]['links']['l' . $lidx] = $playerUrl;
  243.             }
  244.  
  245.             //  get episode ratings
  246.             if (false !== strpos($line, '% Said Work')) {
  247.                 $line = trim(strip_tags($line));
  248.                 $line = str_replace('&nbsp;', '', $line);
  249.                 $retVal['e' . $eidx]['ratings']['l' . $lidx] = $line;
  250.             }
  251.  
  252.         }
  253.  
  254.         return $retVal;
  255.     }
  256.  
  257.     /**
  258.      *  Download an episode if specified
  259.      *
  260.      *  @param  $show       Show identifier as given by --list
  261.      *  @param  $season     '1', '2', etc
  262.      *  @param  $episode    'e1', 'e2', etc
  263.      *  @param  $link       'l1', 'l2', etc
  264.      */
  265.  
  266.     function downloadEpisode($show, $season, $episode, $link) {
  267.         echo "Downloading $show season $season episode $episode link $link\n";
  268.         $list = listSeason($show, $season);
  269.         $t = '';
  270.         $found = false;
  271.         foreach($list as $eId => $epData) {
  272.             if ($eId == $episode) {
  273.                 $t = $epData['title'];
  274.                 echo "Episode: " . $epData['title'] . "\n";
  275.                 foreach($epData['links'] as $lId => $url) {
  276.                     if ($lId == $link) {
  277.                         $found = true;
  278.                         echo "Emedded on: $url\n";
  279.  
  280.                         /*  Download scripts are dispatched from here *****************************/
  281.  
  282.                         if (false !== strpos($url, 'vreer.php')) { downloadVreer($url, $t); }
  283.                         if (false !== strpos($url, 'nowvideo.php')) { downloadEuroplayer($url, $t); }
  284.                         if (false !== strpos($url, 'novamov.php')) { downloadEuroplayer($url, $t); }
  285.                         if (false !== strpos($url, 'divxstage.php')) { downloadEuroplayer($url, $t); }
  286.                         if (false !== strpos($url, 'gorillavid.php')) { downloadGorilla($url, $t); }
  287.                         //  add your own download drivers here :-)
  288.                     }
  289.                 }
  290.             }
  291.         }
  292.  
  293.         if (false == $found) { echo "Unknown episode or link.\n"; }
  294.     }
  295.  
  296.     /**
  297.      *  Helper function to extract a substring
  298.      *  @param  $line       Just a string
  299.      *  @param  $begins     Opening delimeter
  300.      *  @param  $ends       Closing delimeter
  301.      *  @return             Substring
  302.      */
  303.  
  304.     function str_delim($line, $begins, $ends) {
  305.         $start = strpos($line, $begins);
  306.         if (false == $start) { return ''; }
  307.         $start = $start + strlen($begins);
  308.         $end = strpos($line, $ends, $start + 1);
  309.         if (false == $end) { return ''; }
  310.         return substr($line, $start, $end - $start);
  311.     }
  312.  
  313.     /**
  314.      *  Helper function to clean titles of non-alphanumeric chars
  315.      *  @param  $title      String to make a filename from
  316.      *  @return             Filename component
  317.      */
  318.  
  319.     function makeFileName($title) {
  320.         return preg_replace("/[^A-Za-z0-9 ]/", '', $title);
  321.     }
  322.  
  323.     /**
  324.      *  Helper function to download a file with cURL
  325.      *  @param  $url        To be retrieved via GET request
  326.      */
  327.  
  328.     function curlGet($url) {
  329.         return implode(file($url));
  330.         //TODO: debugme
  331.         $ch = curl_init($url);
  332.         curl_setopt($ch, 'CURLOPT_RETURNTRANSFER', true);
  333.         $result = curl_exec($ch);
  334.         echo "Downloaded " . strlen($result) . " bytes\n";
  335.         return $result;
  336.     }
  337.  
  338.     /**
  339.      *  helper function to download from vreer.com
  340.      *  @param  $link       Embedded iFrame URL
  341.      *  @param  $title      Name of this episode
  342.      */
  343.  
  344.     function downloadVreer($link, $title) {
  345.         $containerPage = curlGet($link);
  346.         $lines = explode("\n", $containerPage);
  347.         $vreerUrl = '';
  348.  
  349.         foreach($lines as $line) {
  350.             if (false !== strpos($line, 'IFRAME SRC="http://vreer.com/')) {
  351.                 $vreerUrl = str_delim($line, 'SRC="', '"');
  352.                 echo "Extracting iframe: " . $vreerUrl . "\n";
  353.             }
  354.         }
  355.  
  356.         if ('' == $vreerUrl) {
  357.             echo "[error] Vreer.com iframe not found in $link \n";
  358.             return '';
  359.         }
  360.  
  361.         $containerPage = curlGet($vreerUrl);
  362.         $lines = explode("\n", $containerPage);
  363.        
  364.         foreach($lines as $line) {
  365.             if (false !== strpos($line, 'file: "')) {
  366.                 $dnLink = str_delim($line, 'file: "', '"');
  367.                 echo "Download link: " . $dnLink . "\n";
  368.                 echo "Downloading, please wait... \n";
  369.                 $shellCmd = 'wget'
  370.                  . ' --output-document="' . makeFileName($title) . '.flv"'
  371.                  . ' "' . $dnLink . '"';
  372.  
  373.                 shell_exec($shellCmd);
  374.            
  375.                 echo "Done.\n";
  376.             }
  377.         }
  378.     }
  379.  
  380.     /**
  381.      *  helper function to download from nowvideo.eu, divxstage.eu, etc
  382.      *
  383.      *  Example of auth script called by embedded flash player
  384.      *
  385.      *   http://www.nowvideo.eu/api/player.api.php?
  386.      *      file=i7joob3q1aqo9&
  387.      *      pass=undefined&
  388.      *      cid2=undefined&
  389.      *      key=196%2E215%2E173%2E187%2Df4e8269b0947e8f55c272631b52f881d&
  390.      *      cid3=undefined&
  391.      *      user=undefined&
  392.      *      cid=undefined
  393.      *
  394.      *  @param  $link       Embedded iFrame URL
  395.      *  @param  $title      Name of this episode
  396.      */
  397.  
  398.     function downloadEuroplayer($link, $title) {
  399.         $containerPage = implode(file($link));
  400.         $lines = explode("\n", $containerPage);
  401.         $ifUrl = '';
  402.         $domain = '';
  403.  
  404.         foreach($lines as $line) {
  405.             if (false !== strpos($line, 'http://embed.nowvideo.eu/')) {
  406.                 $ifUrl = str_delim($line, 'src="', '"');
  407.                 $domain = 'www.nowvideo.eu';
  408.                 echo "Extracting iframe: " . $ifUrl . "\n";
  409.             }
  410.             if (false !== strpos($line, 'http://embed.divxstage.eu/')) {
  411.                 $ifUrl = str_delim($line, 'src="', '"');
  412.                 $domain = 'www.divxstage.eu';
  413.                 echo "Extracting iframe: " . $ifUrl . "\n";
  414.             }
  415.             if (false !== strpos($line, 'http://www.novamov.com/embed.php')) {
  416.                 $ifUrl = str_delim($line, "src='", "'");
  417.                 $domain = 'www.novamov.com';
  418.                 echo "Extracting iframe: " . $ifUrl . "\n";
  419.             }
  420.         }
  421.  
  422.         if ('' == $ifUrl) {
  423.             echo "[error] Vreer.com iframe not found in $link \n";
  424.             return '';
  425.         }
  426.  
  427.         $containerPage = implode(file($ifUrl));
  428.         $lines = explode("\n", $containerPage);
  429.        
  430.         $fileId = '';
  431.         $fileKey = '';
  432.  
  433.         foreach($lines as $line) {
  434.  
  435.             if (false !== strpos($line, 'flashvars')) {
  436.                 echo $line . "\n";
  437.             }
  438.  
  439.             if (false !== strpos($line, 'flashvars.file=')) {
  440.                 $fileId = str_delim($line, 'file="', '"');
  441.                 echo "Found fileId: $fileId\n";
  442.             }
  443.  
  444.             if (false !== strpos($line, 'flashvars.filekey=')) {
  445.                 $fileKey = str_delim($line, 'filekey="', '"');
  446.                 echo "Found fileKey: $fileKey\n";
  447.             }
  448.  
  449.         }
  450.  
  451.         if ('' == $fileId) { echo "No fileId\n"; return; }
  452.         if ('' == $fileKey) { echo "No fileKey\n"; return; }
  453.  
  454.         $fileKey = urlencode($fileKey);
  455.         $fileKey = str_replace('.', '%2E', $fileKey);
  456.         $fileKey = str_replace('-', '%2D', $fileKey);
  457.  
  458.         $validateUrl = "http://" . $domain . "/api/player.api.php?file=" . $fileId
  459.          . "&pass=undefined"
  460.          . "&cid2=undefined"
  461.          . "&key=" . $fileKey
  462.          . "&cid3=undefined"
  463.          . "&user=undefined"
  464.          . "&cid=undefined";
  465.  
  466.         echo "Validation URL:" . $validateUrl . "\n";
  467.  
  468.         $authData = implode(file($validateUrl));
  469.         $parts = explode('&', $authData);
  470.  
  471.         $dnLink = '';
  472.  
  473.         foreach($parts as $part) {
  474.             $kv = explode('=', $part, 2);
  475.             echo "AuthData: " . $part . "\n(" . $kv[0] . " => " . $kv[1] . ")\n";
  476.             if ('url' == $kv[0]) { $dnLink = $kv[1]; }
  477.         }
  478.  
  479.         echo "Download link: " . $dnLink . "\n";
  480.         echo "Downloading, please wait... \n";
  481.         $shellCmd = 'wget'
  482.          . ' --output-document="' . makeFileName($title) . '.flv"'
  483.          . ' "' . $dnLink . '"';
  484.  
  485.         echo $shellCmd . "\n";
  486.         shell_exec($shellCmd);
  487.         echo "Done.\n";
  488.  
  489.  
  490.     }
  491.  
  492.     /**
  493.      *  helper function to download from Gorillavid.in
  494.      *  @param  $link       Embedded iFrame URL
  495.      *  @param  $title      Name of this episode
  496.      */
  497.  
  498.     function downloadGorilla($link, $title) {
  499.         $containerPage = curlGet($link);
  500.         $lines = explode("\n", $containerPage);
  501.         $ifUrl = '';
  502.  
  503.         foreach($lines as $line) {
  504.             if (false !== strpos($line, 'IFRAME SRC="http://gorillavid.in/')) {
  505.                 $ifUrl = str_delim($line, 'SRC="', '"');
  506.                 echo "Extracting iframe: " . $ifUrl . "\n";
  507.             }
  508.         }
  509.  
  510.         if ('' == $ifUrl) {
  511.             echo "[error] gorillavid.in iframe not found in $link \n";
  512.             return '';
  513.         }
  514.  
  515.         $containerPage = curlGet($ifUrl);
  516.         $lines = explode("\n", $containerPage);
  517.        
  518.         foreach($lines as $line) {
  519.             if (false !== strpos($line, 'file:"')) {
  520.                 $dnLink = str_delim($line, 'file:"', '"');
  521.                 echo "Download link: " . $dnLink . "\n";
  522.                 echo "Downloading, please wait... \n";
  523.                 $shellCmd = 'wget'
  524.                  . ' --output-document="' . makeFileName($title) . '.flv"'
  525.                  . ' "' . $dnLink . '"';
  526.  
  527.                 echo $shellCmd . "\n";
  528.                 shell_exec($shellCmd);
  529.            
  530.                 echo "Done.\n";
  531.             }
  532.         }
  533.     }
  534.  
  535.     /**
  536.      *  helper function to download from smotri.com (INCOMPLETE)
  537.      *
  538.      *  TODO: finish this
  539.      *
  540.      *  @param  $link       Embedded iFrame URL
  541.      *  @param  $title      Name of this episode
  542.      */
  543.  
  544.  
  545.     function downloadSmotri($link, $title) {
  546.         $containerPage = curlGet($link);
  547.         $lines = explode("\n", $containerPage);
  548.         $flashUrl = '';
  549.  
  550.         foreach($lines as $line) {
  551.             if (false !== strpos($line, '<a href="http://smotri.com/video/view/')) {
  552.                 $flashUrl = str_delim($line, 'href="', '"');
  553.                 echo "Extracting iframe: " . $flashUrl . "\n";
  554.             }
  555.         }
  556.  
  557.         if ('' == $flashUrl) {
  558.             echo "[error] smotri flash not found in $link \n";
  559.             return '';
  560.         }
  561.  
  562.         //  POST TO: http://smotri.com/video/view/url/bot/
  563.         //
  564.         //  context=
  565.         //  &p%5Fid%5B2%5D=2
  566.         //  &getvideoinfo=1
  567.         //  &p%5Fid%5B1%5D=1
  568.         //  &p%5Fid%5B0%5D=7
  569.         //  &devid=LoadupFlashPlayer
  570.         //  &u%5Funiq=adv%5Fuid1131590999219%2E5173     <--- player ID?
  571.         //  &ticket=u16451225cfc                        <--- file ID
  572.         //  &frame%5Furl=1
  573.         //
  574.         //  THEN
  575.         //
  576.         //  ticket=u16451083805
  577.         //  &p%5Fid%5B2%5D=4
  578.         //  &p%5Fid%5B6%5D=7
  579.         //  &p%5Fid%5B1%5D=3
  580.         //  &p%5Fid%5B5%5D=6
  581.         //  &p%5Fid%5B7%5D=9
  582.         //  &begun=1
  583.         //  &p%5Fid%5B41%5D=5
  584.         //  &context=
  585.         //  &p%5Fid%5B4%5D=5
  586.         //  &p%5Fid%5B71%5D=9
  587.         //  &video%5Furl=1
  588.         //  &p%5Fid%5B42%5D=5
  589.         //  &p%5Fid%5B74%5D=9
  590.         //  &p%5Fid%5B44%5D=5
  591.         //  &p%5Fid%5B75%5D=9
  592.         //  &p%5Fid%5B43%5D=5
  593.         //  &p%5Fid%5B73%5D=9
  594.         //  &p%5Fid%5B72%5D=9
  595.         //  &p%5Fid%5B45%5D=5
  596.         //  &devid=LoadupFlashPlayer
  597.         //  &u%5Funiq=adv%5Fuid1131590999219%2E5173
  598.         //
  599.         //  Referrer: http://pics.smotri.com/scrubber_custom8.swf?
  600.         //      file=u16451083805
  601.         //      &bufferTime=3
  602.         //      &autoStart=false
  603.         //      &str_lang=rus
  604.         //      &xmlsource=http%3A%2F%2Fpics%2Esmotri%2Ecom%2Fcskins%2Fblue%2Fskin%5Fcolor%2Exml
  605.         //      &xmldatasource=http%3A%2F%2Fpics%2Esmotri%2Ecom%2Fcskins%2Fblue%2Fskin%5Fng%2Exml/[[DYNAMIC]]/1
  606.  
  607.  
  608.  
  609.  
  610.         $containerPage = curlGet($flashUrl);
  611.         $lines = explode("\n", $containerPage);
  612.        
  613.         foreach($lines as $line) {
  614.             if (false !== strpos($line, 'file:"')) {
  615.                 $dnLink = str_delim($line, 'file:"', '"');
  616.                 echo "Download link: " . $dnLink . "\n";
  617.                 echo "Downloading, please wait... \n";
  618.                 $shellCmd = 'wget'
  619.                  . ' --output-document="' . makeFileName($title) . '.flv"'
  620.                  . ' "' . $dnLink . '"';
  621.  
  622.                 echo $shellCmd . "\n";
  623.                 shell_exec($shellCmd);
  624.            
  625.                 echo "Done.\n";
  626.             }
  627.         }
  628.     }
  629.  
  630. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement