[libraries/kpublictransport/release/26.08] src/lib/backends: Add support for motis booking urls

Volker Krause <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 89a7d7a6a354cbbdc901161d220e556a37ab6763 by Volker Krause, on behalf of Jonah Brüchert.
Committed on 20/07/2026 at 16:04.
Pushed by vkrause into branch 'release/26.08'.

Add support for motis booking urls

Test example: Juvignac -> Lattes Centre

(cherry picked from commit e312d298d18302fa0f1232a6a1591b926685de7f)

M  +14   -0    src/lib/backends/motis2parser.cpp

https://invent.kde.org/libraries/kpublictransport/-/commit/89a7d7a6a354cbbdc901161d220e556a37ab6763

diff --git a/src/lib/backends/motis2parser.cpp b/src/lib/backends/motis2parser.cpp
index 154efb00..e50d1cc4 100644
--- a/src/lib/backends/motis2parser.cpp
+++ b/src/lib/backends/motis2parser.cpp
@@ -243,11 +243,25 @@ Motis2Parser::MotisRoute Motis2Parser::parseRoute(const QJsonObject &obj) const
     res.route.setDestination(parsePlace(obj.value("tripTo"_L1).toObject(), false).stopPoint());
     res.route.setLine(line);
 
+    res.bookingUrl = QUrl(obj.value("agencyFareUrl"_L1).toString());
+
     // Amarillo rideshare booking URLs
     if (res.route.line().mode() == Line::RideShare) {
         res.bookingUrl = QUrl(obj.value("routeUrl"_L1).toString());
     }
 
+    if (obj.contains("ticketUrls"_L1)) {
+        const auto urls = obj.value("ticketUrls"_L1).toObject();
+        // prefer web url even on android
+        // in the hope that it requires installing less third-party apps
+        res.bookingUrl = QUrl(urls.value("web"_L1).toString());
+#ifdef Q_OS_ANDROID
+        if (res.bookingUrl.isEmpty()) {
+            res.bookingUrl = QUrl(urls.value("android"_L1).toString());
+        }
+#endif
+    }
+
     return res;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.