return $series_number;
}
-# Determine the book title by reading the book meta information
-sub find_title {
- my ($book) = @_;
- my $title = ""; my $line = "";
- open (BOOK, "head -100 $book | ") || die ("Could not read $book: $!");
- while ($title eq "" && ( $line = <BOOK> ) ) {
- chomp $line;
- if ( $line =~ /<title>(.*?)<\/title>/ ) {
- $title = $1;
- }
- }
- close BOOK;
-
- if ( $title eq "" ) {
- print STDERR "WARN: Cannot find title for book '$book'\n";
- $title = "[Undefined]";
- }
-
- return convert_entities($title);
-}
-
-# Determine the book author by reading the book meta information
-sub find_author {
- my ($book) = @_;
- my $author = "";
- my $line = "";
- open (BOOK, "head -100 $book |") || die ("Could not read $book: $!");
-
- my $find_line = 0;
- while ($author eq "" && ( $line = <BOOK> ) ) {
- chomp $line;
- if ( $find_line == 1 && $line =~ /<line>(.*?)<\/line>/ ) {
- $author = $1;
- }
- $find_line = 1 if ( $line =~ /<creator class="medium">/ );
- $find_line = 0 if ( $line =~ /<\/creator>/ );
- if ( $line =~ /<creator class="author">(.*?)<\/title>/ ) {
- $author = $1;
- }
- }
- close BOOK;
-
- if ( $author eq "" ) {
- print STDERR "WARN: Cannot find author for book '$book'\n";
- $author = "[Undefined]";
- }
-
-
- return $author;
-}
-
-# Determine the book illustrator by reading the book meta information
-sub find_illustrator {
- my ($book) = @_;
- my $illustrator = "";
- my $line = "";
- open (BOOK, "head -100 $book | ") || die ("Could not read $book: $!");
-
- my $find_line = 0;
- while ($illustrator eq "" && ( $line = <BOOK> ) ) {
- chomp $line;
- if ( $find_line == 1 && $line =~ /<line>Illustrated by (.*?)<\/line>/ ) {
- $illustrator = $1;
- }
- $find_line = 1 if ( $line =~ /<creator class="medium">/ );
- $find_line = 0 if ( $line =~ /<\/creator>/ );
- if ( $line =~ /<creator class="illustrator">(.*?)<\/title>/ ) {
- $illustrator = $1;
- }
- }
- close BOOK;
-
- if ( $illustrator eq "" ) {
- print STDERR "WARN: Cannot find illustrator for book '$book'\n";
- $illustrator = "[Undefined]";
- }
- if ( $language eq "en" ) {
- $illustrator = "Illustrated by ".$illustrator;
- } elsif ( $language eq "es" ) {
- $illustrator = "Illustrado por ".$illustrator;
- }
-
- return $illustrator;
-}
-
-sub convert_entities {
# Convert character entities to their correspondent values
+sub convert_entities {
my ($text) = @_;
$text =~ s/\<ch.apos\/\>/'/g;