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

Jonah Brüchert <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit e312d298d18302fa0f1232a6a1591b926685de7f by Jonah Brüchert.
Committed on 19/07/2026 at 23:02.
Pushed by jbbgameich into branch 'master'.

Add support for motis booking urls

Test example: Juvignac -> Lattes Centre

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

https://invent.kde.org/libraries/kpublictransport/-/commit/e312d298d18302fa0f1232a6a1591b926685de7f

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.