View Single Post
  #5  
Old 04-11-2010, 09:12 AM
elch elch is offline
Member
 
Join Date: Mar 2010
Posts: 78
elch is on a distinguished road
Default

liveweb.arte.tv: [Tutorial] Downloading from arte live web using rtmpdump


I've written a small script for downloading from arte live web:

Code:
#!/usr/bin/php
<?php

if (!isset($_SERVER['argv'][1])) {
        die();
}

if (is_numeric($_SERVER['argv'][1])) {
        $eventId = $_SERVER['argv'][1];
} else {
        $contents = file_get_contents($_SERVER['argv'][1]);

        preg_match('/eventId=(.*)\&mode/', $contents, $matches);
        $eventId = $matches[1];
}

$contents = file_get_contents("http://arte.vo.llnwd.net/o21/liveweb/events/event-$eventId.xml");

preg_match('/<urlHd>rtmp:\/\/(.*)net\/(.*)\/MP4:(.*)<\/urlHd>/', $contents, $matches);

if (isset($matches[3])) {
        $host = $matches[1] . 'net';
        $app = $matches[2];
        $path = 'MP4:' . $matches[3];
        $file = basename($path);
        $live = '';
} else {
        preg_match('/<liveUrl>rtmp:\/\/(.*)\/(.*)\/(.*)<\/liveUrl>/', $contents, $matches);
        $host = $matches[1];
        $app = $matches[2];
        $path = $matches[3];
        $file = basename($path) . '.mp4';
        $live = '--live';
}

preg_match_all('/<nameFr>(.*)<\/nameFr>/', $contents, $matches);
$category = htmlspecialchars_decode($matches[1][1]);
$title = htmlspecialchars_decode($matches[1][2]);

preg_match('/<urlFr>(.*)<\/urlFr>/', $contents, $matches);
$source = $matches[1];

echo "echo \"category: $category\n";
echo "title: $title\n";
echo "source: $source\" > $file.meta\n";

echo "\n";

echo "rtmpdump --host $host --app $app --playpath $path $live --flv $file\n";
Use it like this:
Code:
php arte http://liveweb.arte.tv/fr/video/One_Shot_Not___Sting/
Then it generates two commands. The first one is for creating a meta file (might come in handy when you want some information about a particular recording and it isn't available over the arte site anymore). The second one is just for calling rtmpdump, i.e. downloading the file.
Reply With Quote