Commit dbe379a3 authored by marudor's avatar marudor Committed by derf
Browse files

use bahn.expert as new domain for marudor.de

parent 0e14df21
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
#!/usr/bin/python3

# This script queries the Travelynx API if you are checked into a train. If
# yes, marudor.de is additionally queried for the next stop, and a JSON object
# yes, bahn.expert is additionally queried for the next stop, and a JSON object
# like this is written to stdout:
# {"full_text": "RE26824, next: D\u00fcren at <span fgcolor=\"#ff0000\">15:38+5</span>, dest: Aachen Hbf at <span fgcolor=\"#ff0000\">16:07+5</span>", "markup": "pango"},
# The script then exits.
@@ -80,7 +80,7 @@ predicted_arrival_timestamp = j["toStation"]["realTime"]
delay = (predicted_arrival_timestamp - scheduled_arrival_timestamp) / 60

try:
    details_res = requests.get(f"https://marudor.de/api/hafas/v2/details/{train}")
    details_res = requests.get(f"https://bahn.expert/api/hafas/v2/details/{train}")
    details = details_res.json()
    # print(json.dumps(details, sort_keys=True, indent=4), file=sys.stderr)
    next_stop_name = details["currentStop"]["station"]["title"]
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ sub startup {
	# security and usability for websites that want to maintain user's logged-in
	# session after the user arrives from an external link". In practice,
	# Safari (both iOS and macOS) does not send a SameSite=lax cookie when
	# following a link from an external site. So, marudor.de providing a
	# following a link from an external site. So, bahn.expert providing a
	# checkin link to travelynx.de/s/whatever does not work because the user
	# is not logged in due to Safari not sending the cookie.
	#
+1 −1
Original line number Diff line number Diff line
@@ -1072,7 +1072,7 @@ my @migrations = (

	# v24 -> v25
	# travelynx 1.23 adds optional links to external services, e.g.
	# DBF or marudor.de departure boards
	# DBF or bahn.expert departure boards
	sub {
		my ($db) = @_;
		$db->query(
+2 −2
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@ use DateTime;
my @sb_templates = (
	undef,
	[ 'DBF', 'https://dbf.finalrewind.org/{name}?rt=1#{tt}{tn}' ],
	[ 'marudor.de', 'https://marudor.de/{name}#{id}' ],
	[ 'marudor.de', 'https://bahn.expert/{name}#{id}' ],
	[ 'NVM',        'https://nvm.finalrewind.org/board/{eva}#{tt}{tn}' ],
	[ 'marudor.de/regional', 'https://marudor.de/regional/{name}#{id}' ],
	[ 'marudor.de/regional', 'https://bahn.expert/regional/{name}#{id}' ],
);

sub new {
+2 −2
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@
								% @wagons = reverse @wagons;
							% }
						% }
						<a href="https://marudor.de/details/<%= $journey->{train_type} %>%20<%= $journey->{train_no} %>/<%= DateTime->now(time_zone => 'Europe/Berlin')->iso8601 %>?station=<%= $journey->{dep_eva} %>">
						<a href="https://bahn.expert/details/<%= $journey->{train_type} %>%20<%= $journey->{train_no} %>/<%= DateTime->now(time_zone => 'Europe/Berlin')->iso8601 %>?station=<%= $journey->{dep_eva} %>">
						%= $direction
						% for my $wagon (@wagons) {
							% if (not ($wagon->is_locomotive or $wagon->is_powercar)) {
@@ -297,7 +297,7 @@
				% }
			</div>
			<div class="card-action">
				% my $url = 'https://marudor.de/details/' . $journey->{train_type} . ' ' . $journey->{train_no} . '/' . DateTime->now(time_zone => 'Europe/Berlin')->epoch . '000';
				% my $url = 'https://bahn.expert/details/' . $journey->{train_type} . ' ' . $journey->{train_no} . '/' . DateTime->now(time_zone => 'Europe/Berlin')->epoch . '000';
				<a style="margin-right: 0;" href="<%= $url %>" aria-label="Zuglauf"><i class="material-icons left">timeline</i> Zuglauf</a>
				% if ($journey->{extra_data}{trip_id}) {
					<a class="right" style="margin-right: 0;" href="https://dbf.finalrewind.org/map/<%= $journey->{extra_data}{trip_id} %>/<%= $journey->{train_line} || 0 %>?from=<%= $journey->{dep_name} %>&amp;to=<%= $journey->{arr_name} %>&amp;dark=<%= (session('theme') and session('theme') eq 'dark') ? 1 : 0 %>"><i class="material-icons left" aria-hidden="true">map</i> Karte</a>
Loading