Skip to content

Instantly share code, notes, and snippets.

@JEEN
Created December 20, 2012 13:40
Show Gist options
  • Select an option

  • Save JEEN/4345372 to your computer and use it in GitHub Desktop.

Select an option

Save JEEN/4345372 to your computer and use it in GitHub Desktop.
그거!
#!/usr/bin/env perl
package TorrentdownCommenter;
use Any::Moose;
use namespace::autoclean;
use Config::Pit;
use WWW::Mechanize;
has mech => (
is => 'rw',
isa => 'WWW::Mechanize',
default => sub {
WWW::Mechanize->new;
}
);
has config => (
is => 'rw',
isa => 'HashRef',
lazy_build => 1,
);
has _auth => (
is => 'rw',
isa => 'Bool',
);
sub BUILD {
my $self = shift;
$self->auth;
}
sub _build_config {
Config::Pit::pit_get('playtoda.com', require => {
username => 'Your username on torrentdown.kr',
password => 'Your password on torrentdown.kr',
latest_id => 'Your Latest fetch id on torrentdown.kr',
});
}
sub auth {
my $self = shift;
my $res = $self->mech->post('http://playtoda.com/bbs/bbs/login_check.php',
[
mb_id => $self->config->{username},
mb_password => $self->config->{password},
]
);
$self->_auth(1) if $res->decoded_content =~ /location\.replace/;
}
sub memoize {
my ($self, $id) = @_;
Config::Pit::set('playtoda.com', data => {
username => $self->config->{username},
password => $self->config->{password},
latest_id => $id,
});
}
sub get_point {
my $self = shift;
die "Auth Failed" unless $self->_auth;
my $from_id = $self->config->{latest_id} || 1;
my $dest = $from_id + 20;
for my $id ($from_id .. $dest) {
$self->comment($id);
$self->like($id);
}
$self->memoize($dest+1);
$self->attend();
}
sub like {
my ($self, $id) = @_;
$self->mech->get('http://www.playtoda.com/bbs/bbs/good.php', [
bo_table => 'torrentother',
wr_id => $id,
good => 'goood'
]);
}
sub attend {
my ($self) = @_;
$self->mech->get('http://playtoda.com/modules_tt/atten/check_atten.php', [
str => '댓글은 정성스럽게 다는 플토인이 되어요~'
]);
}
sub comment {
my ($self, $id) = @_;
my $res = $self->mech->post('http://playtoda.com/bbs/bbs/write_comment_update_bumy.php',
[
w => 'c',
bo_table => 'freeboard',
wr_id => $id,
wr_content => '감사합니다.'
]
);
sleep 10;
print "OK : $id \n" if $res->decoded_content =~ /location\.replace/;
}
__PACKAGE__->meta->make_immutable;
package main;
my $broker = TorrentdownCommenter->new;
$broker->get_point;
@JEEN

JEEN commented Dec 20, 2012

Copy link
Copy Markdown
Author

$ perl get_playtoda_point.pl

@JEEN

JEEN commented Dec 20, 2012

Copy link
Copy Markdown
Author

당연히 모듈 깔아야 됨은 물론이고

@JEEN

JEEN commented Dec 20, 2012

Copy link
Copy Markdown
Author

그리고 ~/.pit/default.yaml 이라는 파일을 만들어 두고 계정 알아서 집어 넣으세요.


---
"playtoda.com": 
  "latest_id": 52000
  "password": your-password
  "username": your-username

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment