I created this little perl program that creates an RSS feed from a set of video files (.mp4). This is useful to wirelessly transfer files to the PSP. The files will be saved in the VIDEO folder of the PSP.
You’ll need to install MP4::Info and HTTP::Daemon from CPAN first.
<span class='line'>#!/usr/bin/perl -w
</span><span class='line'>
</span><span class='line'># this small program starts a http daeomon listening on port 1111 and provides a RSS feed
</span><span class='line'># to all .mp4 files stored in the 'videos' folder.
</span><span class='line'># This program is intended to transfer movie files via wireless. Using the sony psp RSS feed utility
</span><span class='line'># 1. Start the server with ./rssstandaloneserver.pl
</span><span class='line'># 2. Copy some video files on videos subfolder
</span><span class='line'># 3. Point you PSP browser to the http://<address>:<port>/ and the psp browser will display a page to
</span><span class='line'># subscribe to the feed.
</span><span class='line'># 4. Go to Psp->Network->RSS Channel and select the new feed
</span><span class='line'># 5. A list of items should appear and pressing X will download the video files to your VIDEO folder
</span><span class='line'># on the PSP memory stick
</span><span class='line'># Please note that depending of your firmware and the encoder you used on your files PSP may refuse
</span><span class='line'># to play those files from the VIDEO folder. The VIDEO folder is not just like the MP_ROOT/100ANV01
</span><span class='line'># folder, it behaves a different way. So please first check and transfer some of your files via USB to the
</span><span class='line'># VIDEO folder and check that the PSP is able to play them from there.
</span><span class='line'># If you encode your files using the Media Manager for PSP software then those files will work in any folder.
</span><span class='line'># If you use 3GP encoder and QVGA MPEG-4 then those also will work in the VIDEO folder. but if you use
</span><span class='line'># another resolution or AVC codec then it won't work.
</span><span class='line'>use HTTP::Daemon;
</span><span class='line'>use HTTP::Status;
</span><span class='line'>use XML::RSS;
</span><span class='line'>use MP4::Info;
</span><span class='line'>use File::stat;
</span><span class='line'>use Time::localtime;
</span><span class='line'>use URI::Escape;
</span><span class='line'>use Encode;
</span><span class='line'>use LWP::MediaTypes;
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>#configuration
</span><span class='line'>my $feedtitle = "Perl Video Feed";
</span><span class='line'>my $feeddesc = "ecerulm perl video feed";
</span><span class='line'>my $hostname = "192.168.1.3";
</span><span class='line'>my $port = 1111;
</span><span class='line'>my $debug = 1;
</span><span class='line'>#end of configuration
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>my $rootaddr="http://" . $hostname . ":" . $port;
</span><span class='line'>my $ct = "video/m4v";
</span><span class='line'>
</span><span class='line'>LWP::MediaTypes::add_type($ct => qw(mp4 MP4));
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>my $d = HTTP::Daemon->new(LocalPort => $port) || die;
</span><span class='line'>
</span><span class='line'>print "Please contact me at: <URL:", $d->url, ">\n";
</span><span class='line'>while (my $c = $d->accept) {
</span><span class='line'> while (my $r = $c->get_request) {
</span><span class='line'>
</span><span class='line'> my $url = URI::Escape::uri_unescape($r->url->path);
</span><span class='line'> print $r->method . " " . "$url\n" if $debug;
</span><span class='line'> if ($r->method eq 'GET' and $url eq "/") {
</span><span class='line'> print "sending index.htm\n";
</span><span class='line'> $c->send_file_response("index.htm");
</span><span class='line'> } elsif ($url eq "/index.rss") {
</span><span class='line'> print "generating RSS content\n";
</span><span class='line'> my $rss = new XML::RSS (version => '2.0');
</span><span class='line'> $rss->channel(title => $feedtitle,
</span><span class='line'> link => $rootaddr,
</span><span class='line'> description => $feeddesc,
</span><span class='line'> );
</span><span class='line'>
</span><span class='line'> $rss->image(title => 'Perl video feed',
</span><span class='line'> url => $rootaddr . "/images/feedimage.jpg",
</span><span class='line'> link => $rootaddr,
</span><span class='line'> width => 88,
</span><span class='line'> height => 115,
</span><span class='line'> description => 'feed logo'
</span><span class='line'> );
</span><span class='line'>
</span><span class='line'>
</span><span class='line'> # videos
</span><span class='line'> my @fileList = <videos/*.MP4>;
</span><span class='line'> foreach $file (@fileList) {
</span><span class='line'> my $tag = get_mp4tag($file) or die "No TAG info";
</span><span class='line'> $date_string = ctime(stat($file)->mtime);
</span><span class='line'>
</span><span class='line'> #my $enclosurelink = "http://192.168.1.3:1111/" . URI::Escape::uri_escape_utf8($file);
</span><span class='line'> my $enclosurelink = $rootaddr . "/" . URI::Escape::uri_escape_utf8($tag->{NAM}) . ".MP4";
</span><span class='line'> #my $enclosurelink =~ s/videos%2F/videos\//;
</span><span class='line'> $rss->add_item(title => $tag->{NAM},
</span><span class='line'> enclosure => {
</span><span class='line'> url=>$enclosurelink,
</span><span class='line'> type=>$ct,
</span><span class='line'> },
</span><span class='line'> description => $tag->{NAM},
</span><span class='line'> pubDate=>$date_string
</span><span class='line'>
</span><span class='line'> );
</span><span class='line'> }
</span><span class='line'> # or save it to a file
</span><span class='line'> my $rs = new HTTP::Response(RC_OK);
</span><span class='line'> $rs->header('Content-type', "application/rss+xml");
</span><span class='line'> $rs->content($rss->as_string) if $r->method eq 'GET';
</span><span class='line'> $c->send_response($rs);
</span><span class='line'> print "RSS content sent\n" if $debug;
</span><span class='line'>
</span><span class='line'> } elsif (-e "." . $url) {
</span><span class='line'> print "the $url maps directly to a file in the filesystem\n" if $debug;
</span><span class='line'> if ($r->method eq 'GET') {
</span><span class='line'> print "sending " . $r->method . " " . $url . "\n";
</span><span class='line'> $c->send_file_response("." . $url) if $r->method eq 'GET';
</span><span class='line'> } else {
</span><span class='line'> print "sending HEAD " . $url . "\n";
</span><span class='line'> $c->send_basic_header;
</span><span class='line'> print $c "Content-type: $ct\n\n";
</span><span class='line'> }
</span><span class='line'> } else {
</span><span class='line'> print "$url doesn't map to file directly. We assume the url is the movie title\n" if $debug;
</span><span class='line'> my $t = $url;
</span><span class='line'> $t = Encode::decode("UTF-8", $t);
</span><span class='line'> $t = substr($t,1,-4); #remove the ".mp4" part.
</span><span class='line'> print "looking for a file with movie title: $t\n" if $debug;
</span><span class='line'>
</span><span class='line'>
</span><span class='line'> my @files = <videos/*.MP4>;
</span><span class='line'> my $found = 0;
</span><span class='line'> foreach $f (@files) {
</span><span class='line'> my $tag = get_mp4tag($f) or next;
</span><span class='line'> if ($tag->{NAM} eq $t) {
</span><span class='line'> print "sending " . $f . " file\n";
</span><span class='line'> $c->send_file_response($f);
</span><span class='line'> $found = 1;
</span><span class='line'> last;
</span><span class='line'> }
</span><span class='line'> }
</span><span class='line'> unless ($found) {
</span><span class='line'> print "cannot find " . $url . " using method " . $r->method . "\n";
</span><span class='line'> $c->send_error(RC_NOT_FOUND);
</span><span class='line'> }
</span><span class='line'> }
</span><span class='line'> }
</span><span class='line'> $c->close;
</span><span class='line'> undef($c);
</span><span class='line'>}</span>