forked from rubykat/WWW-FetchStory
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweaking for Dist::Zilla; still barebones.
- Loading branch information
Showing
4 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ META.yml | |
Makefile.PL | ||
_build/ | ||
blib | ||
|
||
releases | ||
WWW-FetchStory* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
name = WWW-FetchStory | ||
main_module = lib/WWW/FetchStory.pm | ||
version = 0.01 | ||
|
||
author = Kathryn Andersen <perlkat@katspace.org> | ||
license = Perl_5 | ||
copyright_holder = Kathryn Andersen | ||
copyright_year = 2010 | ||
|
||
[GatherDir] | ||
[PruneCruft] | ||
[ManifestSkip] | ||
|
||
[AutoPrereq] | ||
[PkgVersion] | ||
[PodVersion] | ||
[MetaYAML] | ||
[License] | ||
[Readme] | ||
|
||
[PodCoverageTests] | ||
[PodSyntaxTests] | ||
[ExtraTests] | ||
|
||
[ModuleBuild] | ||
[Manifest] | ||
[TestRelease] | ||
|
||
[ArchiveRelease] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,117 @@ | ||
use strict; | ||
use warnings; | ||
package WWW::FetchStory; | ||
=head1 NAME | ||
1; | ||
WWW::FetchStory - Fetch a story from a fiction website | ||
=head1 SYNOPSIS | ||
use WWW::FetchStory qw(:all); | ||
my %story_info = fetch_story( | ||
url=>$url, | ||
basename=>$basename); | ||
=head1 DESCRIPTION | ||
This will fetch a story from a fiction website, intelligently | ||
dealing with the formats from various different fiction websites | ||
such as fanfiction.net; it deals with multi-file stories, | ||
and strips all the extras from the HTML (such as navbars and javascript) | ||
so that all you get is the story text and its formatting. | ||
=cut | ||
|
||
use HTML::SimpleParse; | ||
use File::Temp qw(tempdir); | ||
use File::Find::Rule; | ||
|
||
require Exporter; | ||
|
||
our @ISA = qw(Exporter); | ||
|
||
# Items to export into callers namespace by default. Note: do not export | ||
# names by default without a very good reason. Use EXPORT_OK instead. | ||
# Do not simply export all your public functions/methods/constants. | ||
|
||
# This allows declaration | ||
# use Text::ParseStory ':all'; | ||
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||
# will save memory. | ||
our %EXPORT_TAGS = ( | ||
'all' => [ | ||
qw( | ||
get_story_info | ||
) | ||
] | ||
); | ||
|
||
our @EXPORT_OK = (@{$EXPORT_TAGS{'all'}}); | ||
|
||
our @EXPORT = qw( | ||
); | ||
|
||
=head1 FUNCTIONS | ||
=head2 fetch_story | ||
my %story_info = fetch_story( | ||
url=>$url, | ||
basename=>$basename); | ||
=cut | ||
sub fetch_story (%) { | ||
my %args = ( | ||
file=>'', | ||
columns=>undef, | ||
url=>'', | ||
verbose=>0, | ||
@_ | ||
); | ||
|
||
my %story_info = (); | ||
foreach my $col (@{$args{columns}}) | ||
{ | ||
$story_info{$col} = ''; | ||
} | ||
if ($args{file} =~ /.txt$/) | ||
{ | ||
extract_info_from_text(vals=>\%story_info, %args); | ||
} | ||
elsif ($args{file} =~ /.zip$/) | ||
{ | ||
extract_info_from_zip(vals=>\%story_info, %args); | ||
} | ||
else | ||
{ | ||
extract_info_from_html(vals=>\%story_info, %args); | ||
} | ||
return %story_info; | ||
} # fetch_story | ||
|
||
=head1 Private Functions | ||
=head2 fetch_from_ffn | ||
Fetch a story from fanfiction.net. | ||
=cut | ||
sub fetch_from_ffn (%) { | ||
my %args = ( | ||
url=>'', | ||
basename=>undef, | ||
@_ | ||
); | ||
|
||
} # fetch_from_ffn | ||
|
||
=head1 BUGS | ||
Please report any bugs or feature requests to the author. | ||
=cut | ||
|
||
1; # End of Text::ParseStory | ||
__END__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use Test::More tests => 1; | ||
|
||
BEGIN { | ||
use_ok( 'Text::ParseStory' ); | ||
} | ||
|
||
diag( "Testing Text::ParseStory ${Text::ParseStory::VERSION}" ); |