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

We don't import anymore the fonction for each site.

Importing the fonction in the table name of the sites::parser module has
the site effect that reload only a site's module (like sites/youtube.pm)
don't actually update the code.
parent 4b286731
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -14,7 +14,7 @@ my $inAuthor = 0; ...@@ -14,7 +14,7 @@ my $inAuthor = 0;
my %infos; my %infos;
sub mixcloud { sub get {
my ($url) = @_; my ($url) = @_;
my $ua = LWP::UserAgent->new( my $ua = LWP::UserAgent->new(
......
...@@ -5,10 +5,10 @@ our @ISA = qw(Exporter); ...@@ -5,10 +5,10 @@ our @ISA = qw(Exporter);
our @EXPORT_OK = qw(parse); our @EXPORT_OK = qw(parse);
use lib "$FindBin::Bin/lib/sites/"; use lib "$FindBin::Bin/lib/sites/";
use youtube qw(youtube); use youtube;
use soundcloud qw(soundcloud); use soundcloud;
use mixcloud qw(mixcloud); use mixcloud;
use zippy qw(zippy); use zippy;
sub parse { sub parse {
...@@ -16,24 +16,24 @@ sub parse { ...@@ -16,24 +16,24 @@ sub parse {
my %content; my %content;
if ($msg =~ m#(?:^|[^!])https?://(?:www.youtube.com/watch\?[a-zA-Z0-9_=&-]*v=|youtu.be/)([a-zA-Z0-9_-]+)#) { if ($msg =~ m#(?:^|[^!])https?://(?:www.youtube.com/watch\?[a-zA-Z0-9_=&-]*v=|youtu.be/)([a-zA-Z0-9_-]+)#) {
eval { %content = youtube($1) }; eval { %content = youtube::get($1) };
$content{'site'} = 'youtube'; $content{'site'} = 'youtube';
$content{'url'} = 'https://www.youtube.com/watch?v='.$1; $content{'url'} = 'https://www.youtube.com/watch?v='.$1;
} }
elsif ($msg =~ m#(^|[^!])https?://soundcloud.com/([a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+)#) { elsif ($msg =~ m#(^|[^!])https?://soundcloud.com/([a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+)#) {
my $url = 'https://www.soundcloud.com/'.$2; my $url = 'https://www.soundcloud.com/'.$2;
eval { %content = soundcloud($url) }; eval { %content = soundcloud::get($url) };
$content{'site'} = 'soundcloud'; $content{'site'} = 'soundcloud';
} }
elsif ($msg =~ m#(^|[^!])https?://www.mixcloud.com/([a-zA-Z0-9-_]+/[a-zA-Z0-9-_]+)#) { elsif ($msg =~ m#(^|[^!])https?://www.mixcloud.com/([a-zA-Z0-9-_]+/[a-zA-Z0-9-_]+)#) {
my $url = 'https://www.mixcloud.com/'.$2; my $url = 'https://www.mixcloud.com/'.$2;
eval { %content = mixcloud($url) }; eval { %content = mixcloud::get($url) };
$content{'site'} = 'mixcloud'; $content{'site'} = 'mixcloud';
} }
elsif ($msg =~ m#((^|[^!])http://www[0-9]+.zippyshare.com/v/[0-9]+/file.html)#) { elsif ($msg =~ m#((^|[^!])http://www[0-9]+.zippyshare.com/v/[0-9]+/file.html)#) {
my $url = $1; my $url = $1;
eval { %content = zippy($url) }; eval { %content = zippy::get($url) };
$content{'site'} = 'zippyshare'; $content{'site'} = 'zippyshare';
} }
......
...@@ -12,7 +12,7 @@ my $root = 'http://api.soundcloud.com'; ...@@ -12,7 +12,7 @@ my $root = 'http://api.soundcloud.com';
my $clientId = 'f4956716fe1a9dc9c3725af822963365'; my $clientId = 'f4956716fe1a9dc9c3725af822963365';
sub soundcloud { sub get {
my ($url) = @_; my ($url) = @_;
my $ua = LWP::UserAgent->new(timeout => 30); my $ua = LWP::UserAgent->new(timeout => 30);
......
...@@ -6,7 +6,7 @@ require Exporter; ...@@ -6,7 +6,7 @@ require Exporter;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT_OK = qw(youtube); our @EXPORT_OK = qw(youtube);
sub youtube { sub get {
my $id = shift; my $id = shift;
my $yt = new WebService::GData::YouTube(); my $yt = new WebService::GData::YouTube();
......
...@@ -14,7 +14,7 @@ my $inAuthor = 0; ...@@ -14,7 +14,7 @@ my $inAuthor = 0;
my %infos; my %infos;
sub zippy { sub get {
my ($url) = @_; my ($url) = @_;
my $ua = LWP::UserAgent->new( my $ua = LWP::UserAgent->new(
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter