mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-10 15:38:50 +00:00
parse 'invalid station'
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@165 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
7826d06a22
commit
615e25ba3f
1 changed files with 13 additions and 3 deletions
|
@ -440,11 +440,15 @@ public final class BahnProvider implements NetworkProvider
|
|||
return uri.toString();
|
||||
}
|
||||
|
||||
private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern.compile(
|
||||
".*?<title>Deutsche Bahn - Abfahrt</title>.*?<body >(.*?Abfahrt.*?)</body>.*?", Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern.compile(".*?" //
|
||||
+ "(?:" //
|
||||
+ "<title>Deutsche Bahn - Abfahrt</title>.*?<body >(.*?Abfahrt.*?)</body>" //
|
||||
+ "|(Eingabe kann nicht interpretiert))" //
|
||||
+ ".*?" //
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_HEAD_FINE = Pattern.compile(".*?" //
|
||||
+ "<div class=\"haupt rline\">\n<span class=\"bold\">\n(.+?)\\s*(?:- Aktuell)?\\n</span>.*?" // location
|
||||
+ "Abfahrt (\\d+:\\d+)\\n?Uhr, (\\d+\\.\\d+\\.\\d+).*?" // currentTime
|
||||
+ "Abfahrt (\\d{1,2}:\\d{2})\\n?Uhr, (\\d{2}\\.\\d{2}\\.\\d{2}).*?" // currentTime
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<div class=\"sqdetailsDep trow\">\n(.+?)</div>", Pattern.DOTALL);
|
||||
static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?" //
|
||||
|
@ -476,6 +480,10 @@ public final class BahnProvider implements NetworkProvider
|
|||
final Matcher mHeadCoarse = P_DEPARTURES_HEAD_COARSE.matcher(page);
|
||||
if (mHeadCoarse.matches())
|
||||
{
|
||||
// messages
|
||||
if (mHeadCoarse.group(2) != null)
|
||||
return new QueryDeparturesResult(uri, Status.INVALID_STATION);
|
||||
|
||||
final Matcher mHeadFine = P_DEPARTURES_HEAD_FINE.matcher(mHeadCoarse.group(1));
|
||||
if (mHeadFine.matches())
|
||||
{
|
||||
|
@ -554,6 +562,8 @@ public final class BahnProvider implements NetworkProvider
|
|||
private static String normalizeLine(final String line)
|
||||
{
|
||||
// TODO ARZ Simplon Tunnel: Brig - Iselle di Trasquera
|
||||
// ARZ29177
|
||||
// ARZ29178
|
||||
|
||||
if (line == null || line.length() == 0)
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue