summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-05-01 16:55:09 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-05-01 16:55:09 +0200
commit86c30dcd6b010f143f05bae367b8acb84e0f6cee (patch)
tree27b9d328c190cfe2ad2efda99c5a7ce9652cc70f
parentc69a189b4c3e6ba5db4de67e07a10eabe1a6017d (diff)
Fix VOR and LinzAG encoding
-rwxr-xr-xbin/efa-m5
-rw-r--r--lib/Travel/Status/DE/EFA.pm39
2 files changed, 26 insertions, 18 deletions
diff --git a/bin/efa-m b/bin/efa-m
index 7e84863..93c6b6b 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -16,6 +16,7 @@ use List::Util qw(first max);
use Travel::Status::DE::EFA;
my $efa_url = 'http://efa.vrr.de/vrr/XSLT_DM_REQUEST';
+my $efa_encoding;
my ( $date, $time, $input_type, $list_lines, $offset, $relative_times );
my ($full_routes);
my ( $filter_via, $track_via );
@@ -95,7 +96,8 @@ if ($service) {
);
exit 1;
}
- $efa_url = $service_ref->{url};
+ $efa_url = $service_ref->{url};
+ $efa_encoding = $service_ref->{encoding};
}
sub new_efa_by_url {
@@ -104,6 +106,7 @@ sub new_efa_by_url {
date => $date,
developer_mode => $developer_mode,
efa_url => $url,
+ efa_encoding => $efa_encoding,
full_routes => $full_routes,
place => $place,
name => $input,
diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm
index a77baac..71775a4 100644
--- a/lib/Travel/Status/DE/EFA.pm
+++ b/lib/Travel/Status/DE/EFA.pm
@@ -126,7 +126,12 @@ sub new {
return $self;
}
- $self->{xml} = $response->decoded_content;
+ if ( $opt{efa_encoding} ) {
+ $self->{xml} = encode( $opt{efa_encoding}, $response->content );
+ }
+ else {
+ $self->{xml} = $response->decoded_content;
+ }
if ( not $self->{xml} ) {
@@ -534,6 +539,7 @@ sub get_efa_urls {
url => 'https://efa.vor.at/wvb/XSLT_DM_REQUEST',
name => 'Verkehrsverbund Ost-Region',
shortname => 'VOR',
+ encoding => 'iso-8859-15',
},
# HTTPS not supported
@@ -546,6 +552,7 @@ sub get_efa_urls {
url => 'https://www.linzag.at/static/XSLT_DM_REQUEST',
name => 'Linz AG',
shortname => 'LinzAG',
+ encoding => 'iso-8859-15',
},
{
url => 'https://efa.vgn.de/vgnExt_oeffi/XML_DM_REQUEST',
@@ -643,7 +650,7 @@ Travel::Status::DE::EFA - unofficial EFA departure monitor
use Travel::Status::DE::EFA;
my $status = Travel::Status::DE::EFA->new(
- efa_url => 'http://efa.vrr.de/vrr/XSLT_DM_REQUEST',
+ efa_url => 'https://efa.vrr.de/vrr/XSLT_DM_REQUEST',
place => 'Essen', name => 'Helenenstr'
);
@@ -672,7 +679,8 @@ It reports all upcoming tram/bus/train departures at a given place.
=item my $status = Travel::Status::DE::EFA->new(I<%opt>)
Requests the departures as specified by I<opts> and returns a new
-Travel::Status::DE::EFA object. Dies if the wrong I<opts> were passed.
+Travel::Status::DE::EFA object. B<efa_url>, B<place> and B<name> are
+mandatory. Dies if the wrong I<opts> were passed.
Arguments:
@@ -680,20 +688,9 @@ Arguments:
=item B<efa_url> => I<url>
-URL to the EFA service. Known URLs are:
-
-=over
-
-=item * L<http://212.114.197.7/vgnExt_oeffi/XML_DM_REQUEST> (Verkehrsverbund GroE<szlig>raum NE<uuml>rnberg)
-
-=item * L<http://efa.vrr.de/vrr/XSLT_DM_REQUEST> (Verkehrsverbund Rhein-Ruhr)
-
-=item * L<http://www2.vvs.de/vvs/XSLT_DM_REQUEST> (Verkehrsverbund Stuttgart)
-
-=back
-
-If you found a URL not listed here, please send it to
-E<lt>derf@finalrewind.orgE<gt>.
+URL to the EFA service. See C<< efa-m --list >> for known URLs.
+If you found a URL not listed there, please notify
+E<lt>derf+efa@finalrewind.orgE<gt>.
=item B<place> => I<place>
@@ -708,6 +705,12 @@ B<stop> (stop/station name).
address / poi / stop name to list departures for.
+=item B<efa_encoding> => I<encoding>
+
+Some EFA servers do not correctly specify their response encoding. If you
+observe encoding issues, you can manually specify it here. Example:
+iso-8859-15.
+
=item B<full_routes> => B<0>|B<1>
If true: Request full routes for all departures from the backend. This
@@ -765,6 +768,8 @@ the following elements.
=item B<shortname>: Short name of the entity
+=item B<encoding>: Server-side encoding override for B<efa_encoding> (optional)
+
=back
=back