Streamen mit iTunes

Aus VDR Wiki
Wechseln zu: Navigation, Suche

Zum Streaming von Radiosendungen zu iTunes kann einfach über eine statische Playlist erfolgen.

DVB-Radio Playlist lokal per XML

Erstellen einer iTunes Playlist mit den VDR-Radiokanälen

Wer keinen mt-daap-Server laufen hat, aber trotzdem von allen Clients im Netz per iTunes auf DVB-Radio zugreifen will, der kann sich auch eine statische Playlist mit der URL bauen. Das funktioniert auch schon mit iTunes4.

Mit diesem Skript wird eine iTunes-kompatible XML-Playlist erstellt, die nur noch in iTunes importiert werden muss:

Datei
build_itunes_dvb_playlist.pl
#!/usr/bin/perl -w
use strict;

# ------------------------------------------------
# initial vars: configure here !
# ------------------------------------------------
my $channels="/etc/vdr/channels.conf";
my $baseurl="192.168.1.200";
my $port="3000";
my $playlistpath="/musik/";    # MUST ALREADY EXIST!
my $playlistfile="dvbstreams.xml";
my $playlistname="DVB Radio-Streams";

# ------------------------------------------------
# no need to configure below (hope so...)
# ------------------------------------------------
my $stationnr=time();
my $shellcommand='';
my $shelloutput='';
my @radiostation=();
my @output_row=();
my $playlistheader='';
my $playliststation='';
my $playlistfooter='';
my $playlistsum='';

$shellcommand ='cat '.$channels.' | ';
$shellcommand .= 'egrep \'^[^:]*\:[^:]*\:[^:]*\:[^:]*\:[^:]*\:0.*\' |';
$shellcommand .= 'sed \'s/^\([^\;]*\)[^:]*\:\([^:]*\:[^:]*\)\:\([^:]*\)\:\([^:]*\:[^:]*\:[^:]*\:[^:]*\:[^:]*\:\)\([^:]*\)\:\([^:]*\)\:\([^:]*\)\:\(.*\)$/'.$baseu
rl.':'.$port.'\/ES\/\3-\6-\7-\5#\1/g\' ';
$shelloutput=`$shellcommand`;
open(DATEI, ">".$playlistpath."/".$playlistfile) || die "Datei nicht gefunden";

$playlistheader.='<?xml version="1.0" encoding="UTF-8"?>'."\n";
$playlistheader.='<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'."\n";
$playlistheader.='<plist version="1.0">'."\n";
$playlistheader.='<dict>'."\n";
$playlistheader.='<key>Major Version</key><integer>1</integer>'."\n";
$playlistheader.='<key>Minor Version</key><integer>1</integer>'."\n";
$playlistheader.='<key>Application Version</key><string>4.7.1</string>'."\n";
$playlistheader.='<key>Music Folder</key><string></string>'."\n";
$playlistheader.='<key>Library Persistent ID</key><string></string>'."\n";
$playlistheader.='<key>Tracks</key>'."\n";
$playlistheader.='<dict>'."\n";

print DATEI $playlistheader;
if ($shelloutput) {
        @output_row=split ( /\n/, $shelloutput);
        foreach (@output_row) {
                $stationnr++;
                @radiostation=split ( /#/, $_);
                $playliststation.='<key>'.$stationnr.'</key>'."\n";
                $playliststation=' <dict>'."\n";
                $playliststation.='<key>Track ID</key><integer>'.$stationnr.'</integer>'."\n";
                $playliststation.='<key>Name</key><string>'.$radiostation[1].'</string>'."\n";
                $playliststation.='<key>Kind</key><string>MPEG-Audio-Stream</string>'."\n";
                $playliststation.='<key>Date Added</key><date>2005-09-24T15:02:16Z</date>'."\n";
                $playliststation.='<key>Bit Rate</key><integer>320</integer>'."\n";
                $playliststation.='<key>Sample Rate</key><integer>48000</integer>'."\n";
                $playliststation.='<key>Play Count</key><integer>4</integer>'."\n";
                $playliststation.='<key>Play Date</key><integer>-1084540920</integer>'."\n";
                $playliststation.='<key>Play Date UTC</key><date>2005-09-24T15:06:16Z</date>'."\n";
                $playliststation.='<key>Track Type</key><string>URL</string>'."\n";
                $playliststation.='<key>Location</key><string>'.$radiostation[0].'</string>'."\n";
                $playliststation.='</dict>'."\n";
                $playlistsum.='<dict>'."\n";
                $playlistsum.='<key>Track ID</key><integer>'.$stationnr.'</integer>'."\n";
                $playlistsum.='</dict>'."\n";
        print DATEI $playliststation;
        }
        $playlistfooter.= '</dict>'."\n";
        $playlistfooter.= '<key>Playlists</key>'."\n";
        $playlistfooter.= '<array>'."\n";
        $playlistfooter.= '<dict>'."\n";
        $playlistfooter.= '<key>Name</key><string>'.$playlistname.'</string>'."\n";
        $playlistfooter.= '<key>Playlist ID</key><integer>100258'.$stationnr.'</integer>'."\n";
        $playlistfooter.= '<key>Playlist Persistent ID</key><string>98E7F981487EBA3C</string>'."\n";
        $playlistfooter.= '<key>All Items</key><true/>'."\n";
        $playlistfooter.= '<key>Playlist Items</key>'."\n";
        $playlistfooter.= '<array>'."\n";
        $playlistfooter.= $playlistsum;
        $playlistfooter.= '</array>'."\n";
        $playlistfooter.= '</dict>'."\n";
        $playlistfooter.= '</array>'."\n";
        $playlistfooter.= '</dict>'."\n";
        $playlistfooter.= '</plist>'."\n";
        print DATEI $playlistfooter;
        close(DATEI);
}



Links