Commit 5028946dd6acf682321e7165d0f067fe9cb99cd3
- Diff rendering mode:
- inline
- side by side
legendas.tv
(32 / 7)
|   | |||
| 5 | 5 | use HTTP::Cookies; | |
| 6 | 6 | use WWW::Mechanize; | |
| 7 | 7 | use Getopt::Euclid; | |
| 8 | use Term::ReadPassword; | ||
| 8 | 9 | ||
| 9 | 10 | use constant COOKIE => "$ENV{HOME}/.legendas.tv.cookie"; | |
| 10 | 11 | ||
| … | … | ||
| 18 | 18 | ||
| 19 | 19 | use constant SELECT_LANG => PT_BR; | |
| 20 | 20 | ||
| 21 | sub clean { | ||
| 22 | my $cookie = shift; | ||
| 23 | say ' * limpando cookie'; | ||
| 24 | $cookie->clear; | ||
| 25 | } | ||
| 26 | |||
| 21 | 27 | my $cookie = HTTP::Cookies->new(file => COOKIE, autosave => 1); | |
| 28 | |||
| 22 | 29 | my $logged = 0; | |
| 23 | 30 | $cookie->scan(sub { | |
| 24 | 31 | my ($key, $expires) = ($_[1], $_[8]); | |
| … | … | ||
| 38 | 38 | $browser->get('http://legendas.tv'); | |
| 39 | 39 | ||
| 40 | 40 | unless ($logged) { | |
| 41 | say ' * entre com seu login e password'; | ||
| 41 | say ' * entre com seu login e senha'; | ||
| 42 | 42 | print ' login: '; chomp(my $LOGIN = <STDIN>); | |
| 43 | print ' password: '; chomp(my $PASSWORD = <STDIN>); | ||
| 43 | my $PASSWORD = read_password(' senha: '); | ||
| 44 | 44 | say ' * logando'; | |
| 45 | 45 | $browser->submit_form( | |
| 46 | 46 | form_name => 'form1', | |
| … | … | ||
| 71 | 71 | } | |
| 72 | 72 | else { | |
| 73 | 73 | say " * nenhuma legenda encontrada!"; | |
| 74 | clean($cookie) if defined $ARGV{'-c'}; | ||
| 74 | 75 | exit -1; | |
| 75 | 76 | } | |
| 76 | 77 | ||
| … | … | ||
| 87 | 87 | chomp(my $n = <STDIN>); | |
| 88 | 88 | last if $n eq 'q'; | |
| 89 | 89 | ||
| 90 | say "\n * baixando legenda $film[$n]->{id}"; | ||
| 90 | say "\n * baixando legenda $film[$n]->{release}"; | ||
| 91 | 91 | $browser->get("http://legendas.tv/info.php?d=$film[$n]->{id}&c=1"); | |
| 92 | 92 | ||
| 93 | 93 | say ' * arquivo ' . $browser->response->filename . ' salvo'; | |
| … | … | ||
| 97 | 97 | chomp($response = <STDIN>); | |
| 98 | 98 | } | |
| 99 | 99 | ||
| 100 | clean($cookie) if defined $ARGV{'-c'}; | ||
| 101 | |||
| 100 | 102 | exit 0; | |
| 101 | 103 | ||
| 102 | 104 | __END__ | |
| 103 | 105 | ||
| 104 | 106 | =head1 NAME | |
| 105 | 107 | ||
| 106 | legendas.tv - pesquisa, exibe, e baixa legendas do legendas.tv | ||
| 108 | legendas.tv - pesquisa e baixa legendas do legendas.tv | ||
| 107 | 109 | ||
| 108 | 110 | =head1 VERSION | |
| 109 | 111 | ||
| 110 | 0.01 | ||
| 112 | 0.02 | ||
| 111 | 113 | ||
| 112 | 114 | =head1 USAGE | |
| 113 | 115 | ||
| 114 | legendas.tv <filme> | ||
| 116 | legendas.tv <filme> [options] | ||
| 115 | 117 | ||
| 116 | =head1 REQUIRED ARGUMENT | ||
| 118 | =head1 REQUIRED ARGUMENTS | ||
| 117 | 119 | ||
| 118 | 120 | =over | |
| 119 | 121 | ||
| … | … | ||
| 127 | 127 | filme.type: string, length(filme) > 2 | |
| 128 | 128 | ||
| 129 | 129 | =back | |
| 130 | |||
| 131 | =head1 OPTIONS | ||
| 132 | |||
| 133 | =over | ||
| 134 | |||
| 135 | =item -c | ||
| 136 | |||
| 137 | Limpa o cache | ||
| 138 | |||
| 139 | =back | ||
| 140 | |||
| 141 | =head1 TODO | ||
| 142 | |||
| 143 | Exibir legendas das proximas paginas quando houver paginação | ||
| 130 | 144 | ||
| 131 | 145 | =head1 AUTHOR | |
| 132 | 146 |

