File perl-Finance-Quote-debian-04_deka.patch of Package perl-Finance-Quote

Bart Martens <bartm@debian.org>
Closes: #431293.

Index: lib/Finance/Quote/Deka.pm
===================================================================
--- lib/Finance/Quote/Deka.pm.orig
+++ lib/Finance/Quote/Deka.pm
@@ -62,8 +62,7 @@ sub deka
     if (!$response -> is_success()) {
       $info{$stock,"errormsg"} = "HTTP failure";
     } else {
-      my @headers = [qw(Name ISIN Whg Datum)];
-      my $te = new HTML::TableExtract(headers => @headers, slice_columns => 0);
+      my $te = new HTML::TableExtract();
       $te->parse($response->content);
       foreach my $ts ($te->table_states) {
 #        foreach my $row ($ts->rows) {
@@ -73,16 +72,34 @@ sub deka
 
         foreach my $row ($ts->rows) {
 	  next if !defined $$row[0] || !defined $$row[1];
-	  $info{$stock,"name"} = $$row[0];
-	  $info{$stock,"currency"} = $$row[2];
-	  $quoter->store_date(\%info, $stock, {eurodate => $$row[6]});
-	  $info{$stock,"price"} = convert_price(trim($$row[4]));
-	  $info{$stock,"last"} = $info{$stock,"price"};
-	  $info{$stock,"success"} = 1;
-	  $info{$stock,"method"} = "deka";
-	  $info{$stock,"symbol"} = $stock;
+	  next if !defined $$row[2] || !defined $$row[3];
+	  $info{$stock,"currency"} = $$row[1] if( $$row[0] =~ /^W.hrung:$/ );
+	  $info{$stock,"price"} = convert_price(trim($$row[3])) if( $$row[2] eq "Anteilpreis Aktuell:" );
         }
       }
+
+      $info{$stock,"name"} = $1
+        if( $response->content =~ /<div class="sfg_txt">[^<>]*<h1>([^<>]+)<\/h1>/s );
+      $info{$stock,"eurodate"} = $1
+        if( $response->content =~ /<div class="box">[^<>]*<h2 class="headline">Aktuelle Fondsdaten vom ([^<>]+)<\/h2>/s );
+      $info{$stock,"last"} = $info{$stock,"price"}
+        if( defined $info{$stock,"price"} );
+
+      $info{$stock,"success"} = 1
+      	if( defined $info{$stock,"name"}
+      	&&  defined $info{$stock,"eurodate"}
+      	&&  defined $info{$stock,"price"}
+	&&  defined $info{$stock,"last"}
+	&&  defined $info{$stock,"currency"} );
+
+      if( $info{$stock,"success"} == 1 )
+      {
+        $info{$stock,"method"} = "deka";
+        $info{$stock,"symbol"} = $stock;
+        $quoter->store_date(\%info, $stock, {eurodate => $info{$stock,"eurodate"}});
+        delete $info{$stock,"eurodate"};
+      }
+
       $info{$stock,"errormsg"} = "Couldn't parse deka website"
 	  if ($info{$stock,"success"} == 0);
     }
openSUSE Build Service is sponsored by