PDA

View Full Version : [ViX_Misc] Yahoo Weather - YWeather converter



chaser
08-05-16, 23:09
Hi,

I noticed recently that the Yahoo Weather was not displaying correctly on the Confluence Skin 2nd Info Bar (having previously uncommented the line in the skin that enables the weather to show on this skin).

I took the opportunity to do a bit of digging today, and noticed that the skin refers to a piece of code called YWeather, which was originally written by someone called 2boom. This code links to a Yahoo site, but Yahoo have changed things at their end a bit, and the link no longer works correctly, which then breaks the YWeather code. I'm guessing that anything else that relies on YWeather will also not be working.

I've had a look through the code, made some adjustments, and now have it working again on my Ultimo & Duo2 boxes - albeit, it seems to be a lot slower at zapping than it did before. I'm not sure if it's related to the changes I've made. My Python coding skills are not the best, and I'm sure there's a more elegant way of achieving what I've done. If anyone is interested in looking at or amending the code, the two main parts I adjusted are:

1. Creating a link to download the yahoo xml file.
This was a bit more complicated that I thought is should be! I tried doing this in a single line, but the combination of '%20' (for spaces), and '%s' (for the variable location id) in the URL didn't seem to work very well. This is why I've split the URL generation into 3 lines of code - plus a couple of other lines to actually download the yahoo xml file (which is actually called YWeather_tmp.xml).

2. Inserting new lines into the downloaded Yahoo xml file
Currently the downloaded Yahoo xml file, which is downloaded to the tmp folder on the flash, has one very long line that contains most of the weather data. This data is in the following format:

<Something1><Something2>....<something10>

Whereas, it appears that the YWeather code expects each <Something> to be on a separate line:

<Something1>
<Something2>
...
<Something10>

I'm sure it's possible to amend the code to capture relevant info from the single line, but that was beyond me! Instead, I just changed the format of the file so that a new line was inserted between the '>' and '<' symbols.


Anyway, if you're interested in trying it out, I've attached an updated copy of the YWeather.py file, which should be copied to /usr/lib/enigma2/python/Components/Converter. Restart E2 after you've copied the file across to generate the new compiled YWeather.pyo file. Make a backup copy of the existing YWeather.pyo file, before starting this in case you need to revert back (delete the YWeather.py file before you revert back, or you'll keep regenerating the new YWeather.pyo file).

Let me know if it's not working correctly, and I'll see if I can fix it.

Attached file: 48086

twol
09-05-16, 07:08
Hi,

I noticed recently that the Yahoo Weather was not displaying correctly on the Confluence Skin 2nd Info Bar (having previously uncommented the line in the skin that enables the weather to show on this skin).

I took the opportunity to do a bit of digging today, and noticed that the skin refers to a piece of code called YWeather, which was originally written by someone called 2boom. This code links to a Yahoo site, but Yahoo have changed things at their end a bit, and the link no longer works correctly, which then breaks the YWeather code. I'm guessing that anything else that relies on YWeather will also not be working.

I've had a look through the code, made some adjustments, and now have it working again on my Ultimo & Duo2 boxes - albeit, it seems to be a lot slower at zapping than it did before. I'm not sure if it's related to the changes I've made. My Python coding skills are not the best, and I'm sure there's a more elegant way of achieving what I've done. If anyone is interested in looking at or amending the code, the two main parts I adjusted are:

1. Creating a link to download the yahoo xml file.
This was a bit more complicated that I thought is should be! I tried doing this in a single line, but the combination of '%20' (for spaces), and '%s' (for the variable location id) in the URL didn't seem to work very well. This is why I've split the URL generation into 3 lines of code - plus a couple of other lines to actually download the yahoo xml file (which is actually called YWeather_tmp.xml).

2. Inserting new lines into the downloaded Yahoo xml file
Currently the downloaded Yahoo xml file, which is downloaded to the tmp folder on the flash, has one very long line that contains most of the weather data. This data is in the following format:

<Something1><Something2>....<something10>

Whereas, it appears that the YWeather code expects each <Something> to be on a separate line:

<Something1>
<Something2>
...
<Something10>

I'm sure it's possible to amend the code to capture relevant info from the single line, but that was beyond me! Instead, I just changed the format of the file so that a new line was inserted between the '>' and '<' symbols.


Anyway, if you're interested in trying it out, I've attached an updated copy of the YWeather.py file, which should be copied to /usr/lib/enigma2/python/Components/Converter. Restart E2 after you've copied the file across to generate the new compiled YWeather.pyo file. Make a backup copy of the existing YWeather.pyo file, before starting this in case you need to revert back (delete the YWeather.py file before you revert back, or you'll keep regenerating the new YWeather.pyo file).

Let me know if it's not working correctly, and I'll see if I can fix it.

Attached file: 48086

Will try this later today ... spent hours trying to fix it but couldn,t get the whole search argument sent to the web site .... so mighty impressed!
Its used in th ET8500 lcd display skin so will be pleased to get the weather back:)
Yahoo are real idiots the way they changed the access.

twol
09-05-16, 08:21
had a quick look and clever!
I think (?) if you add &format=xml (otherwise it assumes json format - whatever that is :) it creates the xml file and you don't have to do the line translation and the existing code will work.
However, haven't played yet so I could be totally wrong!

twol
09-05-16, 13:37
OK works for me apart from a crash when it couldn,t find a file ... will send you a PM :)
adding &format=xml didn't seem to make any difference :confused:

bbbuk
09-05-16, 18:54
What has yahoo changed then? I'm guessing more than URL? Was yahoo always using XML or is that what has changed?

twol
09-05-16, 19:07
Its now using a yql (yahoo query language) system that eventially goes to the now non public search urls.s
But this new api url is a pain to define inside for instance python because of the numerous ' " and other symbols that have to be part of the wget you issue :)
The complaints are numerous, especially as all the guidelines describe the previous system :)

chaser
09-05-16, 22:10
OK works for me apart from a crash when it couldn,t find a file ... will send you a PM :)
Thanks for the feedback. I had hoped that the code was written in such a way that the file was always going to be generated, and so would always be available for deleting, but obviously not! I'll update the code later in the week with your suggested file checking and reattach to this thread.

birdman
09-05-16, 23:30
You might be better off using a relevant Python module to parse xml or JSON properly, rather than relying on where Yahoo decides to put newlines (neither of which have any effect outside of data elements in those formats).
(I've only ever done that in Perl - but python-xml, python-lxml, python-simplejson, python-ujson and python-json are all available in the image).

bbbuk
14-05-16, 21:07
I've just checked yahoo weather from feeds and it's working now as weather for my local region is showing. This wasn't the case a month or so ago.

I assume this plugin was updated?

twol
14-05-16, 21:21
I've just checked yahoo weather from feeds and it's working now as weather for my local region is showing. This wasn't the case a month or so ago.

I assume this plugin was updated?

The yweather plugin was updated but not the yweather renderer used by the skins ..... 2 different things, although the renderer uses the geo location from the yweather plugin :)