add xml version of sh/qrz
authorDirk Koopman <djk@tobit.co.uk>
Wed, 25 Nov 2009 17:15:57 +0000 (17:15 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Wed, 25 Nov 2009 17:15:57 +0000 (17:15 +0000)
you will need a subscription to the xml service. See:
http://www.qrz.com/XML/index.html for more info.

Disable the incomplete Encoding of textual data. Work out what to do after
more agreement with people.

Changes
cmd/show/qrz.pl
perl/AnnTalk.pm
perl/Spot.pm
perl/Version.pm

diff --git a/Changes b/Changes
index b0d72948760a0dde7073ca976a658658d800de5e..fb1c1915d772968b2e51a8fe07addaec854528d5 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,8 @@
+25Nov09=======================================================================
+1. Change sh/qrz to use the xml interface. You will have to subscribe to
+the xml interface - see http://www.qrz.com/XML/index.html for more info.
+2. Remove (bodged) forced encoding to iso-8859 on incoming text. More
+subtle handling will be required.
 14Nov09=======================================================================
 1. Add CTY-1921 prefixes
 2. allow -SSID values on set/badnode
index e0ee31a6c7bf27a150b36c0061877e556b602b37..9a3f9c3fc93ed9dd334b64ac259c7e271ac7ae14 100644 (file)
@@ -2,10 +2,9 @@
 # Query the QRZ Database server for a callsign
 #
 # from an idea by Steve Franke K9AN and information from Angel EA7WA
+# and finally (!) modified to use the XML interface
 #
-# Copyright (c) 2001 Dirk Koopman G1TLH
-#
-#
+# Copyright (c) 2001-2009 Dirk Koopman G1TLH
 #
 my ($self, $line) = @_;
 my @list = split /\s+/, $line;               # generate a list of callsigns
@@ -15,14 +14,10 @@ my @out;
 
 return (1, $self->msg('e24')) unless $Internet::allow;
 return (1, "SHOW/QRZ <callsign>, e.g. SH/QRZ g1tlh") unless @list;
-#my $target = $Internet::http_proxy || 'www.qrz.com';
-#my $port = $Internet::http_proxy_port || 80;
-#my $url = '';
-#$url = 'http://www.qrz.com' if $Internet::http_proxy; 
-my $target = $Internet::http_proxy || $Internet::qrz_url || 'www.qrz.com';
+my $target = $Internet::http_proxy || $Internet::qrz_url || 'xml.qrz.com';
 my $port = $Internet::http_proxy_port || 80;
 my $url = '';
-$url = 'http://' . ($Internet::qrz_url | 'www.qrz.com') if $Internet::http_proxy;
+$url = 'http://' . ($Internet::qrz_url | 'xml.qrz.com') if $Internet::http_proxy;
 
 
 use Net::Telnet;
@@ -39,7 +34,7 @@ foreach $l (@list) {
        if (!$t || $@) {
                push @out, $self->msg('e18', 'QRZ.com');
        } else {
-               my $s = "GET $url/p/dxcluster.pl?callsign=$l\&username=$Internet::qrz_uid\&password=$Internet::qrz_pw HTTP/1.0\n\n";
+               my $s = "GET /xml?callsign=$l;username=$Internet::qrz_uid;password=$Internet::qrz_pw;agent=dxspider HTTP/1.0\n\n";
                dbg($s) if isdbg('qrz');
                $t->print($s);
                Log('call', "$call: show/qrz \U$l");
@@ -50,12 +45,17 @@ foreach $l (@list) {
                                push @out, $self->msg('e18', 'QRZ.com');
                                last;
                        }
-                       if ($state eq 'blank' && $result =~ /^\s*Callsign\s*:/i) {
+                       if ($state eq 'blank' && $result =~ /^<Callsign>/i) {
                                $state = 'go';
                        } elsif ($state eq 'go') {
-                               next if $result =~ /^\s*Usage\s*:/i;
-                               chomp $result;
-                               push @out, $result;
+                               next if $result =~ m|<user>|;
+                               next if $result =~ m|<u_views>|;
+                               next if $result =~ m|<locref>|;
+                               next if $result =~ m|<ccode>|;
+                               next if $result =~ m|<dxcc>|;
+                               last if $result =~ m|</Callsign>|;
+                               my ($tag, $data) = $result =~ m|^\s*<(\w+)>(.*)</|;
+                               push @out, sprintf "%10s: $data", $tag;
                        }
                }
                $t->close;
index c075765f6eaf1523fc4a1b022370d527f7a23c5c..f6b4653d28d497b9a854de43a206dc470eb86a58 100644 (file)
@@ -47,7 +47,7 @@ sub dup
        chomp $text;
        unpad($text);
        $text =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
-       $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
+#      $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
        $text =~ s/[^\#a-zA-Z0-9]//g;
        $text = substr($text, 0, $duplth) if length $text > $duplth; 
        my $dupkey = "A$call|$to|\L$text";
index a2b9eee04efe5d9856f4e9d104721350818e495a..e7227ab1b2cdff4e313b95266b935756e2d0d5c5 100644 (file)
@@ -404,7 +404,7 @@ sub dup
                }
        }
        my $otext = $text;
-       $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
+#      $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
        $text =~ s/^\+\w+\s*//;                 # remove leading LoTW callsign
        $text =~ s/\s{2,}[\dA-Z]?[A-Z]\d?$// if length $text > 24;
        $text =~ s/[\W\x00-\x2F\x7B-\xFF]//g; # tautology, just to make quite sure!
index 214f167de5ec8e303c33b244ab46aa93daadd250..c9b52ecb0717d3244567d6106f1c08f12ea55f73 100644 (file)
@@ -11,6 +11,6 @@ use vars qw($version $subversion $build);
 
 $version = '1.55';
 $subversion = '0';
-$build = '52';
+$build = '53';
 
 1;