NAME

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

SYNOPSIS

use WWW::NicoSound::Download qw( can_find_homepage get_id get_ids get_raw save_mp3 );

eval { can_find_homepage( ) };
die $@
    if $@;

eval {
    my $uri = "http://nicosound.anyap.info/sm0000000";
    my $id  = get_id( $url );

    save_mp3( $id );

    # Or get raw to the memory.
    my $raw_ref = get_raw( $id );
    # ..some modification.
};

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

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.

METHODS

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_ids( "webpage.html" )

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

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.

SEE ALSO

WWW::NicoSound::Download::Error

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.