Package: libfinance-quote-perl
Version: 1.13-3
Severity: important
Tags: patch

Since my last successful retrieve of the GBP/EUR exchange rate in 
gnucash on Tuesday, trying to update the price has failed.

Advice from the gnucash-user mailing list yielded a patch - not quite 
right for this version but fixable.

I applied the patch manually and produced a copy of the patch for this 
report, which I attach.

For lenny and sid, the last three added lines may well already be there.

-- System Information:
Debian Release: 5.0.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-amd64 (SMP w/3 CPU cores)
Locale: LANG=en_GB, LC_CTYPE=en_GB (charmap=locale: Cannot set LC_CTYPE to 
default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages libfinance-quote-perl depends on:
ii  libcrypt-ssleay-perl          0.57-1+b1  Support for https protocol in LWP
ii  libhtml-tableextract-perl     2.10-3     module for extracting the content 
ii  libwww-perl                   5.813-1    WWW client/server library for Perl
ii  perl                          5.10.0-19  Larry Wall's Practical Extraction 

libfinance-quote-perl recommends no packages.

libfinance-quote-perl suggests no packages.

-- debconf information:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_GB"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
--- Quote.pm.old        2008-06-29 18:04:09.000000000 +0100
+++ Quote.pm    2009-05-16 07:13:12.000000000 +0100
@@ -36,14 +36,16 @@
 use Finance::Quote::UserAgent;
 use HTTP::Request::Common;
 use HTML::TableExtract;
+use Finance::Quote::Yahoo::Base qw/yahoo_request/;
 
 use vars qw/@ISA @EXPORT @EXPORT_OK @EXPORT_TAGS
             $VERSION $TIMEOUT %MODULES %METHODS $AUTOLOAD
            $YAHOO_CURRENCY_URL $USE_EXPERIMENTAL_UA/;
 
-$YAHOO_CURRENCY_URL = 
"http://uk.finance.yahoo.com/currency/convert?amt=1&submit=Convert&";;
+#$YAHOO_CURRENCY_URL = 
"http://uk.finance.yahoo.com/currency/convert?amt=1&submit=Convert&";;
 # If the above URL ever fails, try rewriting this module to use the URL below.
 # $YAHOO_CURRENCY_URL = "http://uk.finance.yahoo.com/q?s=USDCAD%3DX";;
+$YAHOO_CURRENCY_URL = "http://finance.yahoo.com/d";;
 
 @ISA    = qw/Exporter/;
 @EXPORT = ();
@@ -236,17 +238,16 @@
 
        return $amount if ($from eq $to);       # Trivial case.
 
-       my $ua = $this->user_agent;
-
-       my $data = $ua->request(GET 
"${YAHOO_CURRENCY_URL}from=$from&to=$to")->content;
-       my $te = HTML::TableExtract->new( headers => ['Symbol', 'Bid', 'Ask'] );
-       $te->parse($data);
-
-       # Make sure there's a table to parse.
-       return undef unless ($te->tables);
-
-       my $row = ($te->rows())[0];
-       my ($exchange_rate) = $$row[1];
+       my $symbol = "$from$to=X";
+       my @symbols = ($symbol);
+       my %info = yahoo_request($this,$YAHOO_CURRENCY_URL,\...@symbols);
+       return undef unless $info{$symbol,"success"};
+
+       my $exchange_rate = $info{$symbol,"last"};
+
+        $exchange_rate =~ s/,// ; # solve a bug when conversion rate
+                                  # involves thousands. yahoo inserts
+                                  # a comma when thousands occur
 
        {
                local $^W = 0;  # Avoid undef warnings.

Reply via email to