Add support for öv.ztn.sh
This commit is contained in:
parent
cce5198e86
commit
01c9148c54
|
@ -87,10 +87,10 @@
|
|||
</div>
|
||||
<div class="d-flex p-2" style="width: 40%">
|
||||
<form style="width: 100%" method="GET" action="/OEAPI">
|
||||
<h3>Add trip from <a href="https://oeffisear.ch" target="_blank">oeffisear.ch</a></h3>
|
||||
<h3>Add trip from <a href="https://oeffisear.ch" target="_blank">oeffisear.ch</a> or <a href="https://öv.ztn.sh" target="_blank">öv.ztn.sh</a></h3>
|
||||
<br/>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="link" placeholder="oeffisear.ch link / shortcode">
|
||||
<input type="text" class="form-control" name="link" placeholder="paste link / shortcode here">
|
||||
</div>
|
||||
<br/>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
|
|
|
@ -21,13 +21,18 @@ namespace bahnplan.web.Pages {
|
|||
|
||||
var link = Request.Query["link"].ToString();
|
||||
var shortcode = link;
|
||||
var oepage = "oeffisear.ch";
|
||||
if (link.Contains("oeffisear.ch"))
|
||||
shortcode = link.Split("/#/").Last();
|
||||
else if (link.Contains("öv.ztn.sh") || link.Contains("xn--v-0ga.ztn.sh")) {
|
||||
shortcode = link.Split("/#/").Last();
|
||||
oepage = "xn--v-0ga.ztn.sh";
|
||||
}
|
||||
var jid = shortcode.Split("/").Last();
|
||||
shortcode = shortcode.Split("/").First();
|
||||
|
||||
using var db = new Database.DbConn();
|
||||
var response = new WebClient().DownloadString($"https://oeffisear.ch/journeys?{{\"reqId\":\"{shortcode}\"}}");
|
||||
var response = new WebClient().DownloadString($"https://{oepage}/journeys?{{\"reqId\":\"{shortcode}\"}}");
|
||||
|
||||
var parsed = OeapiResponse.FromJson(response);
|
||||
|
||||
|
|
Reference in a new issue