|
Revision 360
(checked in by miyagawa, 2 years ago)
|
nuked exec bit
|
| Line | |
|---|
| 1 |
package Plagger::Plugin::Publish::Playlog; |
|---|
| 2 |
use strict; |
|---|
| 3 |
use warnings; |
|---|
| 4 |
use base qw( Plagger::Plugin ); |
|---|
| 5 |
use XML::Atom::Client; |
|---|
| 6 |
use XML::Atom::Entry; |
|---|
| 7 |
|
|---|
| 8 |
sub register { |
|---|
| 9 |
my($self, $context) = @_; |
|---|
| 10 |
$context->register_hook( |
|---|
| 11 |
$self, |
|---|
| 12 |
'publish.entry' => \&entry, |
|---|
| 13 |
); |
|---|
| 14 |
} |
|---|
| 15 |
|
|---|
| 16 |
sub entry { |
|---|
| 17 |
my($self, $context, $args) = @_; |
|---|
| 18 |
|
|---|
| 19 |
my $api = XML::Atom::Client->new; |
|---|
| 20 |
$api->username($self->conf->{username}); |
|---|
| 21 |
$api->password($self->conf->{password}); |
|---|
| 22 |
|
|---|
| 23 |
my $entry = XML::Atom::Entry->new; |
|---|
| 24 |
my $otolog = XML::Atom::Namespace->new(otolog => 'http://otolog.org/ns/music#'); |
|---|
| 25 |
for my $key (keys %{$args->{entry}->meta}){ |
|---|
| 26 |
$entry->set($otolog, 'otolog:' . $key, $args->{entry}->meta->{$key}); |
|---|
| 27 |
} |
|---|
| 28 |
$context->log( info => $args->{entry}->meta->{artist} . ' ' . $args->{entry}->meta->{track}); |
|---|
| 29 |
$api->createEntry('http://mss.playlog.jp/playlog', $entry); |
|---|
| 30 |
} |
|---|
| 31 |
|
|---|
| 32 |
1; |
|---|
| 33 |
__END__ |
|---|
| 34 |
|
|---|
| 35 |
=head1 NAME |
|---|
| 36 |
|
|---|
| 37 |
Plagger::Plugin::Publish::Playlog - Publish music data to playlog.jp |
|---|
| 38 |
|
|---|
| 39 |
=head1 SYNOPSIS |
|---|
| 40 |
|
|---|
| 41 |
- module: Publish::Playlog |
|---|
| 42 |
config: |
|---|
| 43 |
username: your-playlog-id |
|---|
| 44 |
password: xxxxxxxx |
|---|
| 45 |
rule: |
|---|
| 46 |
module: Fresh |
|---|
| 47 |
mtime: |
|---|
| 48 |
path: /tmp/iTunesRecentPlay.tmp |
|---|
| 49 |
autoupdate: 1 |
|---|
| 50 |
|
|---|
| 51 |
=head1 DESCRIPTION |
|---|
| 52 |
|
|---|
| 53 |
This plugin publish music data to playlog.jp with AtomPP. |
|---|
| 54 |
|
|---|
| 55 |
=head1 CONFIG |
|---|
| 56 |
|
|---|
| 57 |
=over 4 |
|---|
| 58 |
|
|---|
| 59 |
=item username, password |
|---|
| 60 |
|
|---|
| 61 |
Your playlog ID and password to login. |
|---|
| 62 |
|
|---|
| 63 |
=back |
|---|
| 64 |
|
|---|
| 65 |
=head1 AUTHOR |
|---|
| 66 |
|
|---|
| 67 |
Gosuke Miyashita, E<lt>gosukenator@gmail.comE<gt> |
|---|
| 68 |
|
|---|
| 69 |
=head1 SEE ALSO |
|---|
| 70 |
|
|---|
| 71 |
L<Plagger> |
|---|
| 72 |
|
|---|
| 73 |
=cut |
|---|