Commit b65e6070 authored by Kerenoc's avatar Kerenoc
Browse files

Plugin Coins Numista : new version for exonumia (contrib from Michel_P)

parent e844da25
......@@ -37,6 +37,11 @@ use GCPlugins::GCcoins::GCcoinsCommon;
use base qw(GCPlugins::GCcoins::GCcoinsPluginsBase);
use URI::Escape;
sub getSearchType
{
return "coin";
}
# getSearchUrl
sub getSearchUrl
{
......@@ -55,29 +60,24 @@ use GCPlugins::GCcoins::GCcoinsCommon;
$word =~ s/\s*$//;
# on remplace les espaces internes par des plus
$word =~ s/ /\+/gi;
$url = "https://fr.numista.com/catalogue/index.php?mode=simplifie&p=1&e=&d=&ca=3&no=&i=&v=&m=&a=&t=&dg=&w=&g=&f=&c=&tb=y&tc=y&tn=y&tp=y&tp=y&tt=y&te=y&cat=y&ct=coin&q=100&r=$word";
$url = "https://fr.numista.com/catalogue/index.php?mode=simplifie&p=1&e=&d=&ca=3&no=&i=&v=&m=&a=&t=&dg=&w=&g=&f=&c=&tb=y&tc=y&tn=y&tp=y&tp=y&tt=y&te=y&cat=y";
$url .= "&ct=" . $self->getSearchType() . "&q=100&r=$word";
}
elsif ($self->{searchField} eq 'country')
{
# recherche sur le pays (&r=pays:nom traduit en &r=pays%3Anom)
$url = "https://fr.numista.com/catalogue/index.php?ca=3&no=&c=&tb=y&tc=y&tn=y&tp=y&tp=y&tt=y&te=y&cat=y&mode=simplifie&p=1&e=&d=&i=&v=&m=&a=&t=&dg=&w=&g=&f=&ct=coin&q=100&r=pays:".$word;
}
elsif ($self->{searchField} eq 'number1')
{
# recherche par KM (&km=numero)
# todo : ne marche pas si séparateur espace
# KM# 757 ne fonctionne pas, il faut envoyer KM#757
$word =~ s/ //;
$url = "https://fr.numista.com/catalogue/index.php?mode=simplifie&p=1&e=&d=&ca=3&no=&i=&v=&m=&a=&t=&dg=&w=&g=&f=&c=&tb=y&tc=y&tn=y&tp=y&tp=y&tt=y&te=y&cat=y&ct=coin&q=100&r=".$word;
}
else
{
# recherche dans les jetons
# TODO CT=exonumia ne fonctionne pas
# faut-il rajouter un champ de critère de recherche dans le modèle ou faire un modèle spécifique pour les jetons ?
$word =~ s/ //;
$url = "https://fr.numista.com/catalogue/index.php?mode=simplifie&p=1&e=&d=&ca=3&no=&i=&v=&m=&a=&t=&dg=&w=&g=&f=&c=&tb=y&tc=y&tn=y&tp=y&tp=y&tt=y&te=y&cat=y&ct=exonumia&q=100&r=".$word;
}
{
# recherche sur le pays (&r=pays:nom traduit en &r=pays%3Anom)
$url = "https://fr.numista.com/catalogue/index.php?ca=3&no=&c=&tb=y&tc=y&tn=y&tp=y&tp=y&tt=y&te=y&cat=y&mode=simplifie&p=1&e=&d=&i=&v=&m=&a=&t=&dg=&w=&g=&f=";
$url .= "&ct=" . $self->getSearchType() . "&q=100&r=pays:".$word;
}
elsif ($self->{searchField} eq 'number1')
{
# recherche par KM (&km=numero)
# todo : ne marche pas si séparateur espace
# KM# 757 ne fonctionne pas, il faut envoyer KM#757
$word =~ s/ //;
$url = "https://fr.numista.com/catalogue/index.php?mode=simplifie&p=1&e=&d=&ca=3&no=&i=&v=&m=&a=&t=&dg=&w=&g=&f=&c=&tb=y&tc=y&tn=y&tp=y&tp=y&tt=y&te=y&cat=y";
$url .= "&ct=" . $self->getSearchType() . "&q=100&r=".$word;
}
return $url;
}
......@@ -117,7 +117,7 @@ use GCPlugins::GCcoins::GCcoinsCommon;
sub getSearchFieldsArray
{
return ['name', 'country', 'number1', 'exonumia'];
return ['name', 'country', 'number1'];
}
# getSearchCharset
......@@ -183,7 +183,7 @@ use GCPlugins::GCcoins::GCcoinsCommon;
$self->{isCoin} = 5;
$self->{itemsList}[ $self->{itemIdx} ]->{country} = $attr->{title};
}
elsif (($tagname eq "a") && ($attr->{href} =~ /pieces(\d+)\.html/) && ($self->{isCoin} eq 5))
elsif (($tagname eq "a") && ($attr->{href} =~ /(pieces|exonumia)(\d+)\.html/) && ($self->{isCoin} eq 5))
{
my $url = $attr->{href};
$self->{itemsList}[ $self->{itemIdx} ]->{url} = $url;
......
#
# More information here: http://wiki.gcstar.org/en/websites_plugins
#
package GCPlugins::GCcoins::GCNumistaExonumia;
###################################################
#
# Copyright 2005-2010 Tian
# Copyright 2014-2021 MesBedes
#
# This file is part of GCstar.
#
# GCstar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GCstar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCstar; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
###################################################
use strict;
use utf8; # pour dire que le source est en utf8
use GCPlugins::GCcoins::GCcoinsCommon;
#use open qw(:std :utf8); # pour dire que les entrées et sorties sont par défaut en utf8
{
package GCPlugins::GCcoins::GCPluginNumistaExonumia;
use base qw(GCPlugins::GCcoins::GCPluginNumista);
use URI::Escape;
sub getSearchType
{
return "exonumia";
}
# getName
sub getName
{
return "fr.numista.exonumia";
}
}
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment