Skip to content
Extraits de code Groupes Projets
Valider 9e418af0 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

add and fix warnings

parent e9249abf
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de avec 72 ajouts et 24 suppressions
package PlayBot::commands::fav;
use strict;
use warnings;
our $dbh;
our $log;
our $irc;
......
package PlayBot::commands::get::query;
use strict;
use warnings;
use Moose;
use overload '~~' => \&_equals;
use Scalar::Util qw(looks_like_number);
......
package PlayBot::commands::later;
use strict;
use warnings;
our $dbh;
our $log;
......
package PlayBot::commands::parser;
use strict;
use warnings;
use Try::Tiny;
use PlayBot::commands::fav;
......@@ -89,8 +90,8 @@ sub exec {
$irc->yield(privmsg => $chan => $insultes[rand @insultes]);
};
}
elsif ($msg =~ /^( *!get)(?: +.*)?$/) {
my $query = substr $msg, (length $1) + 1;
elsif ($msg =~ /^( *!get)( +.*)?$/) {
my $query = $2;
my @args = ($chan, $query);
my $id = PlayBot::commands::get::exec(@args);
......
package PlayBot::commands::tag;
use strict;
use warnings;
our $dbh;
our $log;
......
......@@ -49,7 +49,7 @@ my $debug = 0;
# mode debug
if ($#ARGV + 1) {
@channels = qw(#hormone);
@channels = ('#hormone');
$nick = 'kikoo';
$debug = 1;
}
......
package PlayBot::sessions::irc::later;
use strict;
use warnings;
use PlayBot::commands::get;
sub consume
......@@ -7,7 +10,7 @@ sub consume
my ($nick, $id, $chan_src) = @_;
my @args = ($nick, $id, $chan_src);
commands::get::exec(@args);
PlayBot::commands::get::exec(@args);
}
1;
package PlayBot::sites::dailymotion;
use strict;
use warnings;
use Inline Python => 'DATA';
sub get {
......
package PlayBot::sites::mixcloud;
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Encode;
......@@ -7,7 +10,6 @@ use Encode;
sub get {
my ($url) = @_;
$url =~ s/www/api/;
my %infos;
my $ua = LWP::UserAgent->new(
timeout => 30,
......@@ -16,13 +18,15 @@ sub get {
my $response = $ua->get($url);
die($response->status_line) unless ($response->is_success);
$content = decode_json(encode('UTF-8', $response->decoded_content));
$infos{'title'} = $content->{'name'};
$infos{'author'} = $content->{'user'}->{'name'};
$infos{'url'} = $content->{'url'};
$infos{'duration'} = $content->{'audio_length'};
my $content = decode_json(encode('UTF-8', $response->decoded_content));
my $infos = {
title => $content->{'name'},
author => $content->{'user'}->{'name'},
url => $content->{'url'},
duration => $content->{'audio_length'},
};
return %infos;
return %{ $infos };
}
1;
......@@ -76,8 +76,13 @@ sub parse {
');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth);
$sth->execute($content{'site'}, $content{'url'},
$content{'author'}, $content{'title'}, $content{'duration'});
$sth->execute(
$content{'site'},
$content{'url'},
$content{'author'},
$content{'title'},
$content{'duration'}
);
};
if ($@) {
# seems to be already present in database
......@@ -110,7 +115,7 @@ sub parse {
$id = $sth->fetch->[0];
# insertion du chan
my $sth = $dbh->prepare('
$sth = $dbh->prepare('
INSERT INTO playbot_chan (content, chan, sender_irc)
VALUES (?,?,?)');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth);
......
package PlayBot::sites::soundcloud;
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use URI::Find;
......@@ -19,17 +22,19 @@ sub get {
my $response = $ua->get($root.'/resolve.json?url='.$url.'&client_id='.$clientId);
die($response->status_line) unless ($response->is_success);
$content = decode_json($response->decoded_content);
$infos{'title'} = $content->{'title'};
$infos{'author'} = $content->{'user'}->{'username'};
$infos{'duration'} = $content->{'duration'} / 1000;
$infos{'url'} = $url;
my $content = decode_json($response->decoded_content);
my $infos = {
title => $content->{'title'},
author => $content->{'user'}->{'username'},
duration => $content->{'duration'} / 1000,
url => $url,
};
if ($content->{'downloadable'}) {
$infos{'ddl'} = $content->{'download_url'};
$infos->{'ddl'} = $content->{'download_url'};
}
return %infos;
return %{ $infos };
}
1;
package PlayBot::sites::youtube;
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use FindBin;
......@@ -37,9 +40,9 @@ sub get {
$video->{'contentDetails'}->{'duration'} =~ /PT((?<h>\d+)H)?((?<m>\d+)M)?((?<s>\d+)S)?/;
# default values
my ($h) = ($+{'h'}, 0);
my ($m) = ($+{'m'}, 0);
my ($s) = ($+{'s'}, 0);
my ($h) = $+{'h'} || 0;
my ($m) = $+{'m'} || 0;
my ($s) = $+{'s'} || 0;
# there is one more second, don't know why
$infos{'duration'} = $h*3600 + $m*60 + $s - 1;
......
package PlayBot::sites::zippy;
use strict;
use warnings;
use LWP::UserAgent;
use HTML::Parser;
use HTML::Entities;
......
package PlayBot::utils::db::get;
use strict;
use warnings;
use feature 'state';
use Moose;
......
package PlayBot::utils::db::stats;
use strict;
use warnings;
use Moose;
use FindBin;
use List::Util qw( reduce );
......
package PlayBot::utils::id;
use strict;
use warnings;
use Scalar::Util qw(looks_like_number);
# Used to get a proper id from an index.
......
package PlayBot::utils::print;
use strict;
use warnings;
use IRC::Utils qw(YELLOW ORANGE GREEN NORMAL LIGHT_BLUE GREY);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter