diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-02-09 10:58:16 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-02-09 10:58:16 +0100 |
commit | 520e11a25e0c970cc0382af4bfb3565a9ced96fa (patch) | |
tree | f582530b9454b74da847a366ca78141b783408ae /lib | |
parent | dc87974aabe306e7cddad0657b378a6fe13723c8 (diff) |
Add PKP support
Requires "probably Polish" IP address that is allowed at the PKP endpoint
When using new_p or providing a ua object, the user agent string must be set to
'Dalvik/2.1.0'.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS.pm | 5 | ||||
-rw-r--r-- | lib/Travel/Status/DE/HAFAS/Services.pm.PL | 13 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm index 379bd82..638b4af 100644 --- a/lib/Travel/Status/DE/HAFAS.pm +++ b/lib/Travel/Status/DE/HAFAS.pm @@ -42,6 +42,9 @@ sub new { if ( not $ua ) { my %lwp_options = %{ $conf{lwp_options} // { timeout => 10 } }; + if ( $service and $hafas_instance->{$service}{ua_string} ) { + $lwp_options{agent} = $hafas_instance->{$service}{ua_string}; + } $ua = LWP::UserAgent->new(%lwp_options); $ua->env_proxy; } @@ -137,7 +140,7 @@ sub new { y => int( $conf{geoSearch}{lat} * 1e6 ), }, maxDist => -1, - minDist => 0, + minDist => 0, }, locFltrL => [ { diff --git a/lib/Travel/Status/DE/HAFAS/Services.pm.PL b/lib/Travel/Status/DE/HAFAS/Services.pm.PL index 4f491bb..f0e1d18 100644 --- a/lib/Travel/Status/DE/HAFAS/Services.pm.PL +++ b/lib/Travel/Status/DE/HAFAS/Services.pm.PL @@ -75,6 +75,9 @@ sub load_instance { if ( $opt{lang} ) { $ret{request}{lang} = $opt{lang}; } + if ( $opt{ua_string} ) { + $ret{ua_string} = $opt{ua_string}; + } if ( $opt{ver} ) { $ret{request}{ver} = $opt{ver}; } @@ -179,10 +182,12 @@ my %hafas_instance = ( ), stopfinder => 'https://fahrplan.oebb.at/bin/ajax-getstop.exe', }, - Resrobot => { load_instance( 'se/resrobot', lang => 'sve' ), }, - RMV => { load_instance( 'de/rmv', lang => 'deu' ), }, - RSAG => { load_instance( 'de/rsag', lang => 'deu' ), }, - SaarVV => { load_instance( 'de/saarvv', lang => 'deu' ), }, + PKP => + { load_instance( 'pl/pkp', lang => 'pol' ), ua_string => 'Dalvik/2.1.0' }, + Resrobot => { load_instance( 'se/resrobot', lang => 'sve' ), }, + RMV => { load_instance( 'de/rmv', lang => 'deu' ), }, + RSAG => { load_instance( 'de/rsag', lang => 'deu' ), }, + SaarVV => { load_instance( 'de/saarvv', lang => 'deu' ), }, STV => { load_instance( 'at/stv', lang => 'deu', ver => '1.32' ), }, TPG => { load_instance( 'ch/tpg', lang => 'deu', ver => '1.40' ), }, VBB => { |