I have a program that generates an rss feed by reading each line in a linux directory which contains mp3s and printing it out. This works fine.
I was asked to modify the program so that some of the fields in the MP3s ID3 tag are included on the line. I was able to write a program to extract the fields I need in the tag, so I knew I had the right info. (A section is below). I just want to add those fields to the first program so that they print on the same line with the other mp3 info on the rss feed. When I tried to incorporate it into the rss program, I get errors that I do not understand. I am not a perl programmer but my background and the internet allowed me to get the first part done.
Any help would be appreciated.
Thanks so much.
*******************
## my code which pulls the fields I need from the ID3 tag
foreach $frame (keys %$frames)
{
($value, $desc) = $mp3->{ID3v2}->get_frame($frame);
SWITCH: {
$frame eq 'TIT2' && do {
$mp3title = $value;
last SWITCH;
};
$frame eq 'TYER' && do {
$mp3year = $value;
last SWITCH;
};
last SWITCH;
};
}
## current program to generate rss with mp3s in directory
#ADD THE ITEMS TO THE RSS DOCUMENT.
my $counter = 0;
foreach my $file ( @sortedfileinfo ) {
if ( $counter > $maxItems ) {
last;
}
if (!($file->{filename} =~ m/\.([^.]+)$/) || !$mimeTypes->{$1}) {
#Skip files without extensions or whose extensions we don't know about.
next;
}
my $item = $doc->createElement('item');
my $title = $doc->createElement('title');
$title->appendChild($doc->createTextNode($file->{filename}));
$item->appendChild($title);
my $url = $urlBase . '/' . $file->{filename};
my $guid = $doc->createElement('guid');
$guid->appendChild($doc->createTextNode($url));
$item->appendChild($guid);
my $enclosure = $doc->createElement('enclosure');
$enclosure->setAttribute('url', $url);
$enclosure->setAttribute('length', $file->{size});
$enclosure->setAttribute('type', $mimeTypes->{$1});
$item->appendChild($enclosure);
$channel->appendChild($item);
$counter++;
}
print $xml_pi->toString;
print $rss->toString;
print "\n";
-----------------------------------------------------------
I was asked to modify the program so that some of the fields in the MP3s ID3 tag are included on the line. I was able to write a program to extract the fields I need in the tag, so I knew I had the right info. (A section is below). I just want to add those fields to the first program so that they print on the same line with the other mp3 info on the rss feed. When I tried to incorporate it into the rss program, I get errors that I do not understand. I am not a perl programmer but my background and the internet allowed me to get the first part done.
Any help would be appreciated.
Thanks so much.
*******************
## my code which pulls the fields I need from the ID3 tag
foreach $frame (keys %$frames)
{
($value, $desc) = $mp3->{ID3v2}->get_frame($frame);
SWITCH: {
$frame eq 'TIT2' && do {
$mp3title = $value;
last SWITCH;
};
$frame eq 'TYER' && do {
$mp3year = $value;
last SWITCH;
};
last SWITCH;
};
}
## current program to generate rss with mp3s in directory
#ADD THE ITEMS TO THE RSS DOCUMENT.
my $counter = 0;
foreach my $file ( @sortedfileinfo ) {
if ( $counter > $maxItems ) {
last;
}
if (!($file->{filename} =~ m/\.([^.]+)$/) || !$mimeTypes->{$1}) {
#Skip files without extensions or whose extensions we don't know about.
next;
}
my $item = $doc->createElement('item');
my $title = $doc->createElement('title');
$title->appendChild($doc->createTextNode($file->{filename}));
$item->appendChild($title);
my $url = $urlBase . '/' . $file->{filename};
my $guid = $doc->createElement('guid');
$guid->appendChild($doc->createTextNode($url));
$item->appendChild($guid);
my $enclosure = $doc->createElement('enclosure');
$enclosure->setAttribute('url', $url);
$enclosure->setAttribute('length', $file->{size});
$enclosure->setAttribute('type', $mimeTypes->{$1});
$item->appendChild($enclosure);
$channel->appendChild($item);
$counter++;
}
print $xml_pi->toString;
print $rss->toString;
print "\n";
-----------------------------------------------------------