Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link broken? #2

Open
treeswoodhead opened this issue Jan 19, 2021 · 16 comments
Open

Link broken? #2

treeswoodhead opened this issue Jan 19, 2021 · 16 comments

Comments

@treeswoodhead
Copy link

Hi is anyone having issues with the data suddenly stopping loading?

@XBCreepinJesus
Copy link

Yep, I have the same issue.

The error log in the browser console shows the module is getting a 301 status on the response, so I thought it may be something to do with that? Indeed, in node_helper.js, line 45, there's an if statement checking for a 200.

That's all I've had time to look at so far.

@treeswoodhead
Copy link
Author

I think the feed has changed from the met office but I have no knowledge of what to look for to change.

@XBCreepinJesus
Copy link

The feed path looks the same, but it's being redirected (in a browser, at least) from http to https, giving the 301 (permanent redirection). The module won't use a https URL at the moment, by the looks of things.

@silvannn
Copy link

Module is not working. I think that is because of https. If you copy content from web to local file and use test url to that file module is showing data so met Office did not change any structure, so in my opinion https is a problem.

@meaple
Copy link

meaple commented Jul 31, 2021

Did anyone managed to get it working?

@jbradsha
Copy link

Met office have changed to HTTPS. I got it working:

  1. Changing the apiBase: 'https://www.metoffice.gov.uk/public/data/PWSCache/WarningsRSS/Region/'
  2. Change the http.get() call in line 44 to https.get()
  3. Add a new line near the top (I copied the http one and put this edited version after it): const https = require("https")

node.js won't honour 301 redirect from http to https - need to stick with HTTPS throughout.

@jonathananderson13
Copy link

Thanks those changes partially resolved my issue but unfortunately it looks like the feed schema has changed

@jbradsha
Copy link

Yes, they've moved from JSON to XML-based RSS. I'll have a look and see if there's a RSS reader module that could donate some code... not a JS coder though.

@jonathananderson13
Copy link

Ok so looks like that isn't the issue. The parser (FeedMe) does support XML based RSS.
Unfortunately the module relies on the presence of three meta data fields that look to have been removed from the RSS feed. I am going to look at writing a hack to get it to work for my own mirror then might have to write a new module from scratch.

@jbradsha
Copy link

jbradsha commented Jan 2, 2025

Thanks.

The testing/createDummyWarnings.js script shows how those are created... they should be parsable (regex?) from the XML item/description contents.

Yellow warning of ice affecting Grampian: Aberdeenshire, Moray valid from 1600 Wed 01 Jan to 1000 Thu 02 Jan

"metadata:warningkind": "WARNING",
"metadata:warninglevel": level.toUpperCase(), <----- YELLOW
"metadata:warningtype": type.toUpperCase() <---- ICE

@jonathananderson13
Copy link

Unfortunately the meta data is not listed in the feed from the met office any more (see example of link below). I created a "hacky" version last night which I did get work but encountered other issues with the plugin so wondering about getting the warnings from a "proper api" somewhere and writing a new version.

 <item>
            <title>Yellow warning of snow, ice affecting North East England</title>
            <link>https://www.metoffice.gov.uk/weather/warnings-and-advice/uk-warnings#?date=2025-01-04&amp;id=cb7ef0b6-e44c-4abd-b868-e27d1fd5dd64&amp;referrer=rss</link>
            <description>Yellow warning of snow, ice affecting North East England: Darlington, Durham, Gateshead, Hartlepool, Middlesbrough, Newcastle upon Tyne, North Tyneside, Northumberland, Redcar and Cleveland, South Tyneside, Stockton-on-Tees, Sunderland valid from 1200 Sat 04 Jan to 2359 Sun 05 Jan</description>
            <guid isPermaLink="false">https://www.metoffice.gov.uk/weather/warnings-and-advice/uk-warnings#?date=2025-01-04&amp;id=cb7ef0b6-e44c-4abd-b868-e27d1fd5dd64&amp;referrer=rss&amp;region=North East England</guid>
            <enclosure length="17454" type="image/png" url="https://data.consumer-digital.api.metoffice.gov.uk/v1/warnings/rss/image/yellow-snow-ice.png"/>
        </item> 

@jbradsha
Copy link

jbradsha commented Jan 2, 2025

API due to retire in September 2025 and needs a key too... https://www.metoffice.gov.uk/services/data/datapoint

I hardcoded the values as below in warningitemobject.js and it's picking up a live XML feed.

Mirror GUI updated from Ice to Icy (mixed case) when I Changed ICE to ICY below. If it can be extracted from the item.description there may not need to do much else. Will see if I get a regex working in JS.
this.level = "YELLOW"
this.kind = "WARNING"
this.type = "ICE"
// this.level = item["metadata:warninglevel"]
// this.kind = item["metadata:warningkind"]
// this.type = item["metadata:warningtype"]

What other issues did you see in the module?

@jonathananderson13
Copy link

Yes I saw that, unfortunate that they are stopping their API. The hacky version I had last night was extracting from the Title and was working well. The issues I was encountering were strange and I wasn't able to reliably get them to repeat. Things worked until I restarted the mirror then would get intermittent socket errors. Need to spend some more time on it when I get a chance.

@jonathananderson13
Copy link

Manged to write a new version last night, it's very very rough round the edges and haven't done much testing but you are welcome to give it a go. It's in my repo. Will try tidy it up but can't promise I will be able to or resolve any bugs.
image

@jbradsha
Copy link

jbradsha commented Jan 5, 2025

Thanks! Works great for me (had to install node-fetch 2.6.7 but that's a local thing) and mirror correctly showing the two warnings for my region per https://weather.metoffice.gov.uk/warnings-and-advice/uk-warnings

Only thing I'm not getting is the title banner, expect I need to change the config.js - will add a note over over your repro, no value continuing here.

@jonathananderson13
Copy link

Pleased it's working for you! For anyone else that comes across it, feel free to give it a go. I will look at giving it a bit of a tidy and add a screenshot etc over in my Repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants