Browse Source

Revert "more robust"

This reverts commit 89544ddfc50a41fb9022eb4411d0871823039969.
David Sniperovitch 8 years ago
parent
commit
43e22bf58a
1 changed files with 7 additions and 14 deletions
  1. 7 14
      mirror_pad.pl

+ 7 - 14
mirror_pad.pl

@@ -8,23 +8,16 @@ use Encode ();
 use FindBin;
 use URI::Encode ();
 
-my $pad_url = URI::Encode::uri_decode(shift);
-warn "PAD_URL=$pad_url";
-
-my $config_file = "$FindBin::Bin/mirror_pad.yml";
-die "'$config_file' introuvable\n" unless -r $config_file;
-
-my $c = Config::YAML->new(config => $config_file);
+my $url = URI::Encode::uri_decode(shift);
+my $c = Config::YAML->new(config => "$FindBin::Bin/mirror_pad.yml");
 my $ep = Etherpad->new(
-  apiurl => $c->get_apiurl,
-  apikey => $c->get_apikey,
+  url      => $c->get_url,
+  apikey   => $c->get_apikey,
 );
 
-my $pad_base = quotemeta $c->get_apiurl;
-warn "PAD_BASE=$pad_base";
-# Extraction de l'id du pad à partir de l'url du pad
-my $pad_id;
-($pad_id) = $pad_url =~ m{^$pad_base/.+?/(g\.[^/]+)}o;
+my $pad_base = quotemeta $c->get_url;
+my $pad_id = $url;
+$pad_id =~ s{$pad_base/.+?/(g\.[^/]+).*$}{$1};
 warn "PADID=$pad_id\n";
 if(my($pad_text) = $ep->get_text($pad_id)) {
     $pad_text = Encode::encode('UTF-8', $pad_text);