View Single Post
  #6  
Old 05-27-2010, 12:40 PM
alexthunder alexthunder is offline
Senior Member
 
Join Date: Dec 2006
Posts: 202
alexthunder is on a distinguished road
Default

Re: www.tsr.ch - не могу стянуть с ТСР флэш фильм


You are welcome! I got an RTMP stream with Replay Media Catcher, so I don't know how you've managed to get it with wget

Вольный перевод, для тех, кто в танке :
Quote:
Originally Posted by elch View Post
Вот хз какой-то скрипт, который я написал несколько месяцев назад. Он, кажется, все еще работает отлично:

Code:
$ cat tsr-scan 
#!/usr/bin/php
<?php

error_reporting(E_ALL);

$subscriptions = array (
        '55', // temps present
        '97', // services religieux
        '90'  // nouvo
);

$fp = fopen('tsrdl.sh', 'w');

fwrite($fp, '#!/bin/sh' . PHP_EOL);

$path = '/mnt/usb/Series';

foreach ($subscriptions as $id) {
        $url = "http://search2.tsr.ch/solr/select?q=xobix_program_id:$id;broadcast_date%20desc,%20xobix_broadcast_position%20asc&wt=xml";
        $contents = file_get_contents($url);

        preg_match('/<str name="source_name">(.*)<\/str>/Umis', $contents, $matches);

        if (!$matches[1]) {
                echo $id . ' is invalid!';
                continue;
        }

        $title = $matches[1];

        fwrite($fp, PHP_EOL);
        fwrite($fp, '# ' . $title . PHP_EOL);
        fwrite($fp, '# -----------------------------------' . PHP_EOL);

        preg_match_all('/<str name="subtitle">(.*)<\/str>/Umis', $contents, $matches2);
        preg_match_all('/<arr name="media_file_info">(.*)<\/arr>/Umis', $contents, $matches3);

        foreach ($matches2[1] as $key => $subtitle) {
                $urls = $matches3[1][$key];

                preg_match_all('/<str>(.*)<\/str>/Umis', $urls, $matchesUrls);

                for ($i = count($matchesUrls[1]) - 1; $i >= 0; $i--) {
                        preg_match('/"url" : \'(.*)\'/', $matchesUrls[1][$i], $match);
                        $url = $match[1];

                        if (stripos($url, 'real.xobix.ch') !== false) {
                                continue;
                        }

                        fwrite($fp, PHP_EOL);
                        fwrite($fp, '# ' . $subtitle . PHP_EOL);

                        $fullpath = $path . '/' . $title . '/' . $subtitle;
                        $filepath =     $fullpath . '/'. substr(basename($url), 0, strrpos(basename($url), '?'));

                        $comment = '';
                        if ((stripos($subtitle, 'Version courte') !== false) || file_exists($fullpath)) {
                                        $comment = '# ';
                        }

                        fwrite($fp, $comment . 'mkdir -p ' . escapeshellarg($fullpath) . PHP_EOL);
                        fwrite($fp, $comment . 'wget ' . escapeshellarg($url) . ' -O ' . escapeshellarg($filepath) . ' || exit 1' . PHP_EOL);

                        break;
                }
        }

        fwrite($fp, PHP_EOL);

        sleep(1);
}

shell_exec('chmod +x tsrdl.sh');
Затем используйте ./tsrdl.sh для скачивания.

Исправлено: О да, и это только для Линукс, но портировать в Винду должно быть достаточно просто, т.к. wget там тоже есть. Только последнюю компанду нужно изменить, потому что в Винде нет флага для исполняемых файлов, насколько я знаю.
Reply With Quote