Aozora2Epub

 view release on metacpan or  search on metacpan

script/aozora2epub  view on Meta::CPAN

}

@files or usage(1, 1, "$cmd_name requires one or more arguments");

my $ae = (@files > 1 ? Aozora2Epub->new() : Aozora2Epub->new(shift @files));
$ae->title($title) if $title;
$ae->author($author) if $author;

my %append_options;
$append_options{use_subtitle} = 1 if $use_subtitle;
for my $f (@files) {
    $ae->append($f, %append_options);
}

if ($no_okuzuke) {
    $ae->bib_info(undef);
}

my %options;
$options{output} = $output if $output;
if ($cover) {
    unless (do { my $fh; open $fh, "<", $cover and close $fh; }) {
        print STDERR "$cover: $!\n";
        usage(1);
    }
    $options{cover} = $cover
}

$ae->to_epub(%options);
exit 0;

sub usage {
    my ($exit_status, $short, $mes) = @_;

    print STDERR $mes, "\n" if $mes;
    print STDERR "Usage: $cmd_name [options] aozora-url ...\n\n";
    if ($short) {
        print STDERR "Try `$cmd_name --help` for more options.\n";
    } else {
        print STDERR <<"USAGE";
Options:
 -t,--title      タイトル。デフォルトは本のタイトル
 -a,--author     著者。デフォルトは本の著者
 --use-subtitle  合本を作成する際、章名に各本のタイトルではなくサブタイトルを使う
 -c,--cover      表紙ページのjpegファイル名。デフォルトは表紙ページ無し
 -o,--output     出力するEPUBファイル名。デフォルトは`タイトル'.epub
 --no-okuzuke    奥付を含めない
 -h,--help       このヘルプを表示
 --version       このコマンドのバージョンを表示
USAGE
    }
    exit($exit_status);
}

__END__

=encoding utf-8

=head1 NAME

aozora2epub - Convert Aozora Bunko XHTML to EPUB

=head1 SYNOPSIS

  aozora2epub https://www.aozora.gr.jp/cards/001569/files/59761_74795.html
  aozora2epub https://www.aozora.gr.jp/cards/001569/card59761.html # 図書カードのURLでもOK
  aozora2epub 001569/card59761.html # 上と同じ
  
  # 合本の作成
  aozora2epub --title "中谷宇吉郎作品集" 001569/card59761.html 001569/files/59572_72817.html


=head1 DESCRIPTION

aozora2epub は青空文庫のXHTML形式の本をEPUBに変換するコマンドです。

複数の本を指定すると、合本が作られます。

=head1 ARGUMENTS

本の指定は以下のいずれかの形式で行います。
いずれも、URL先頭の B<https://www.aozora.gr.jp/cards/>の部分を省略することが可能です。

=over 4

=item B<図書カードのURL>

青空文庫の図書カードのURLです。以下に例を示します。

  https://www.aozora.gr.jp/cards/001569/card59761.html
  
  001569/card59761.html # 先頭部分を省略

=item B<XHTMLのURL>

青空文庫のXHTMLファイルのURLです。以下に例を示します。

  https://www.aozora.gr.jp/cards/001569/files/59761_74795.html
  
  001569/files/59761_74795.html # 先頭部分を省略

=back

引数を省略した場合、かつ標準入力がターミナルでない場合は、本の指定を標準入力から読み込みます。
このときは、各行が上記のいずれかの形式でなければなりません。各行のC<#>以降はコメントとして無視されます。また、各行の前後の空白文字および空行は無視されます。

=head1 OPTIONS

=over 4

=item B<-t>, B<--title>

出力するEPUBファイルのタイトルを指定します。
デフォルトは、引数に指定した青空文庫の本のタイトルです。
合本の場合は最初に指定した本のタイトルが使われます。

=item B<-a>, B<--author>

出力するEPUBファイルの著者を指定します。
デフォルトは、引数に指定した青空文庫の本の著者です。
合本の場合は最初に指定した本の著者が使われます。



( run in 0.967 second using v1.01-cache-2.11-cpan-39bf76dae61 )