Aozora2Epub

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "Convert Aozora Bunko XHTML to EPUB",
   "author" : [
      "Yoshimasa Ueno <saltyduck@gmail.com>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Milla version v1.0.22, Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Convert Aozora Bunko XHTML to EPUB'
author:
  - 'Yoshimasa Ueno <saltyduck@gmail.com>'
build_requires:
  Test::Base: '0'
  Test::More: '0.96'
  YAML: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
  File::ShareDir::Install: '0.06'
dynamic_config: 0

Makefile.PL  view on Meta::CPAN


use ExtUtils::MakeMaker;

use File::ShareDir::Install;
$File::ShareDir::Install::INCLUDE_DOTFILES = 1;
$File::ShareDir::Install::INCLUDE_DOTDIRS = 1;
install_share dist => "share";


my %WriteMakefileArgs = (
  "ABSTRACT" => "Convert Aozora Bunko XHTML to EPUB",
  "AUTHOR" => "Yoshimasa Ueno <saltyduck\@gmail.com>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0,
    "File::ShareDir::Install" => "0.06"
  },
  "DISTNAME" => "Aozora2Epub",
  "EXE_FILES" => [
    "script/aozora2epub"
  ],
  "LICENSE" => "perl",

README  view on Meta::CPAN

NAME

    Aozora2Epub - Convert Aozora Bunko XHTML to EPUB

SYNOPSIS

      use Aozora2Epub;
    
      my $book = Aozora2Epub->new("https://www.aozora.gr.jp/cards/000262/files/48074_40209.html");
      $book->to_epub;
    
      # 合本の作成
      $book = Aozora2Epub->new();

lib/Aozora2Epub.pm  view on Meta::CPAN

        my $xhtml_uri = URI->new($xhtml_url)->abs(URI->new($xhtml));
        return _get_content($xhtml_uri->as_string);
    }
    if ($xhtml =~ m{/files/\d+_\d+\.html$}) { # XHTML
        unless ($xhtml =~ m{^https?://}) { # $xhtml shuld be \d+/files/xxx_xxx.html
            $xhtml = "$AOZORA_CARDS_URL/$xhtml";
        }
        my $text = _get_file($xhtml);
        return ($text, _base_url($xhtml));
    }
    # XHTML string
    return (qq{<div class="main_text">$xhtml</div>}, undef);
}

sub new {
    my ($class, $content, %options) = @_;
    my $self =  bless {
        files => [],
        epub => Aozora2Epub::Epub->new,
        title => undef,
        author => undef,

lib/Aozora2Epub.pm  view on Meta::CPAN

    my $self = shift;
    return join('', map { $_->as_html } @{$self->files});
}
1;
__END__

=encoding utf-8

=head1 NAME

Aozora2Epub - Convert Aozora Bunko XHTML to EPUB

=head1 SYNOPSIS

  use Aozora2Epub;

  my $book = Aozora2Epub->new("https://www.aozora.gr.jp/cards/000262/files/48074_40209.html");
  $book->to_epub;

  # 合本の作成
  $book = Aozora2Epub->new();

script/aozora2epub  view on Meta::CPAN

    }
    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



( run in 0.655 second using v1.01-cache-2.11-cpan-49f99fa48dc )