NAME

WWW::NicoSound::Download - Get mp3 file from NicoSound web service

SYNOPSIS

use WWW::NicoSound::Download qw( get_id save_mp3 get_raw get_ids can_find_homepage );
die "Sorry, in this environment, can not reach to the server"
    unless can_find_homepage( );
my $uri = "http://nicosound.anyap.info/sm0000000";
my $id  = get_id( $url )
    or die "Could not get NicoSound's ID.";
eval { save_mp3( $id ) };  # Using original name.
die $@ if $@;
eval { save_mp3( $id, "filename.mp3" ) };  # Specify name.
die $@ if $@;

# Use following method if you want to modify MP3 data.
my $raw_ref = eval { get_raw( $id ) };
die $@ if $@;
# ..some modification.

# Get MP3 from a local-file of web-page.
my @ids = get_ids( "somepage.html" );
eval { save_mp3( $_ ) }
    foreach @ids;

# To see module messages, set flag to true.
$WWW::NicoSound::Download::IS_RIOT = 1;

DESCRIPTION

In this module, you can preserve a MP3 file from NicoSound.

NicoSound's URL is "http://nicosound.anyap.info/".

EXPORT

None by default.

can_find_homepage( )

This function tests that perl can reach to the NicoSound in default(180) seconds.

get_id( "http://nicosound.anyap.info/sm0000000" )

This function parses URL, and returns NicoSound's ID.

get_raw( "nm0000000" )

This function reads the MP3 data to the memory. It is used to raw modification. Use save_mp3 if only saving MP3 data.

save_mp3( "nm0000000" )

This function preserves MP3 data to a file. And returns filename that was preserved.

Second parameter is filename. If it is not defined, this function tries to get original name. If could not, preserve as "<process ID>.<number>.mp3", but this case is odd. This naming function is use to saving data from some fatal error. Do not try next ID.

get_ids( "webpage.html" )

This function obtains some IDs from web page. Web page is a HTML file that from NicoSound.

SEE ALSO

AUTHOR

Kuniyoshi Kouji, <kuniyoshi@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Kuniyoshi Kouji

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.