Opened 16 years ago

Closed 15 years ago

#3337 closed enhancement (wontfix)

mythweather-revamp new script for weather.com and a few problems

Reported by: anonymous Owned by: ldunning
Priority: minor Milestone: unknown
Component: mythweather Version: unknown
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Attached is a new script to retrieve weather from weather.com. This script is based on my patches on tickets 3303 and 3327. This should work for locations outside the US. The script is in PHP and is based on my patch to mythweb weather. In fact it re-uses the code with a few modifications. If ticket 3303 is accepted into SVN then mythweather and mythweb weather can share exactly the same code. Big advantage if changes are needed, only change one set of code.

I've tested this on the command line comparing it to the other scripts. Seems to work ok. I have not been able to test it in mythtv with mythweather-revamp. I have 13132 main svn installed, and have compiled and install mythweather-revamp (only mythweather modules). I can not add pages. I add them but they aren't there after I exit and go back. Thus I can add sources. I guess there may be an issue with mythweather-revamp working with the main svn. I can't easily install the entire mythweather-revamp branch to test it that way. sorry.

Dependencies: php-common and php-cli. WeatherSide?.php and Forecast.php MUST BE NON-EXECUTABLE weather_com.php MUST BE EXECUTABLE. Files in icon zips need to go into /usr/share/mythtv/themes/default/

Attachments (10)

weather_com.php (3.9 KB) - added by maverik044 16 years ago.
main script to get weather (current and forecast) from weather.com xml source
WeatherSite.php (6.3 KB) - added by maverik044 16 years ago.
Support script. Same as patched version to Ticket#3303, with a few changes for more data
Forecast.php (856 bytes) - added by maverik044 16 years ago.
Support script. Same as patched version to Ticket#3303
icons1.zip (254.8 KB) - added by maverik044 16 years ago.
icons files part 1
icons2.zip (253.7 KB) - added by maverik044 16 years ago.
icons files part 2
icons3.zip (255.6 KB) - added by maverik044 16 years ago.
icons files part 3
icons4.zip (147.1 KB) - added by maverik044 16 years ago.
icons files part 4
weathercomXML.pl (4.3 KB) - added by simonflood 16 years ago.
Perl script to pull XML data from weather.com
weathercomXML.2.pl (4.5 KB) - added by simonflood 16 years ago.
Perl script to pull XML data from weather.com (v0.2)
weathercomXML.3.pl (11.5 KB) - added by simonflood 16 years ago.
Perl script to pull XML data from weather.com (v0.3)

Download all attachments as: .zip

Change History (28)

Changed 16 years ago by maverik044

Attachment: weather_com.php added

main script to get weather (current and forecast) from weather.com xml source

Changed 16 years ago by maverik044

Attachment: WeatherSite.php added

Support script. Same as patched version to Ticket#3303, with a few changes for more data

Changed 16 years ago by maverik044

Attachment: Forecast.php added

Support script. Same as patched version to Ticket#3303

Changed 16 years ago by maverik044

Attachment: icons1.zip added

icons files part 1

Changed 16 years ago by maverik044

Attachment: icons2.zip added

icons files part 2

Changed 16 years ago by maverik044

Attachment: icons3.zip added

icons files part 3

Changed 16 years ago by maverik044

Attachment: icons4.zip added

icons files part 4

comment:1 Changed 16 years ago by maverik044

By the way, I can tell that the setup for mythweather-revamp is calling my script, it is does results for searches on locations. Just can't add pages in the setup, to then be able to add sources.

comment:2 Changed 16 years ago by maverik044

Sorry should be Dependencies: php5-common and php5-cli (debian pkg names)

By the way great work on the revamp, I like what I see so far, I just wish I could get it to run. I'm willing to do more testing, if we can get is working with the current SVN (or may be its just my config).

Changed 16 years ago by simonflood

Attachment: weathercomXML.pl added

Perl script to pull XML data from weather.com

comment:3 Changed 16 years ago by simonflood

I've just added a Perl script that I've developed to pull XML data from weather.com.

Looking at mythweather-revamp's weather-ui.xml I've provided data for all screens apart from severe weather alerts and 18 hour forecast which weather.com doesn't provide.

Also the 3 day and 6 day forecasts only use the day part of the XML data, nothing is currently done with night info.

No additional dependencies are required that mythweather-revamp doesn't already use.

Changed 16 years ago by simonflood

Attachment: weathercomXML.2.pl added

Perl script to pull XML data from weather.com (v0.2)

comment:4 Changed 16 years ago by simonflood

Having now got mythweather-revamp running on my KnoppMyth? R5E50 VMware guest I was able to see how the data was actually used and discovered some duplication of measurement flags which I've now fixed in version 0.2.

comment:5 Changed 16 years ago by maverik044

great job simonflood, as much as I hate to admit it, your script is cleaner and smaller. mythweather-revamp should go with your script. I'll test it tonight to compare the output against mine as a double check.

I would have like to have the code common with mythweb, but can't argue with your cleaner solution.

Note that for this new script, the icon files that I posted must still be installed.

comment:6 in reply to:  4 Changed 16 years ago by simonflood

discovered some duplication of measurement flags which I've now fixed in version 0.2.

I notice in weatherScreen.cpp that there's a function(?) prepareDataItem that appends the measurement flag (ie. F or C for temps) for some of the values. I think it would be better to leave it to the scripts to add these since they could vary depending on the weather source and it's also easier to do it in the script when adding extra data types.

comment:7 in reply to:  5 ; Changed 16 years ago by simonflood

Thanks for kind comments. Note that my script doesn't currently obey weather.com's "rules" regarding caching of data, something that I do intend to fix if I can figure out how. Having found that you can pull XML feed for current conditions and forecast as 2 separate requests I think store the XML for each as separate files and then update (or not) based on their timestamps. Some of you may have noticed that I also don't pass the partner & licensing stuff in the request (I think we ought to try and get a "mythTV" one). Oh and there's lot's more info that I plan to export such as UV, precipitation, sunrise & sunset, as well as handle days/evenings!

comment:8 in reply to:  7 ; Changed 16 years ago by ldunning

Replying to simonflood:

Note that my script doesn't currently obey weather.com's "rules" regarding caching of data, something that I do intend to fix if I can figure out how.

Look at how ndfd18.pl does it. You can store things in the data directory passed to the script by the plugin. ndfd18.pl actually does the parse and uses Data::Dumper to cache it in a format that can be read by the eval command, then it just looks at a timestamp in the file.

comment:9 Changed 16 years ago by maverik044

To meet the terms of the weather.com SDK for the XML feed, the weather.com logo needs to be displayed. Technically link to the web site also. We need to at least get the logo there. I don't think the code currently supports this, some changes may be needed to display a logo depending on the data source. Perhaps an option to the script could be added to provide the file name of the logo to display. I believe that I have packaged the logo in icon4.zip.

comment:10 in reply to:  8 Changed 16 years ago by simonflood

Replying to ldunning:

Look at how ndfd18.pl does it. You can store things in the data directory passed to the script by the plugin. ndfd18.pl actually does the parse and uses Data::Dumper to cache it in a format that can be read by the eval command, then it just looks at a timestamp in the file.

Thanks I must've missed that one (I did look at your scripts to see what's possible, etc.).

comment:11 in reply to:  9 Changed 16 years ago by simonflood

Replying to maverik044:

To meet the terms of the weather.com SDK for the XML feed, the weather.com logo needs to be displayed. Technically link to the web site also. We need to at least get the logo there. I don't think the code currently supports this, some changes may be needed to display a logo depending on the data source. Perhaps an option to the script could be added to provide the file name of the logo to display. I believe that I have packaged the logo in icon4.zip.

Yes that's on my to-do list - actually I was thinking of passing out the name of the logo image as both cclogo & fclogo (current conditions vs. forecast) plus ccprovider & fcprovider with value "weather.com" or possibly "Weather data provided by weather.com" (to keep it generic and allow other scripts for other providers to use different wording to comply with their licensing terms). Also seeing as no-one is saying that weather.com has been contacted re an account for [all] mythTV [users] I'll now drop them a line and see what they say. As has already been pointed out MediaPortal? use weather.com as their weather provider so I can't see why mythTV can't too. BTW check out http://www.team-mediaportal.com/content/view/241/5/ for a video (no sound) of MP's weather system ... interesting (though it's not clear from http://wiki.team-mediaportal.com/MediaPortalSetup_Weather whether they're pulling icons via HTTP each time weather is checked ...)

comment:12 in reply to:  9 ; Changed 16 years ago by paulh

Replying to maverik044:

To meet the terms of the weather.com SDK for the XML feed, the weather.com logo needs to be displayed. Technically link to the web site also. We need to at least get the logo there. I don't think the code currently supports this, some changes may be needed to display a logo depending on the data source. Perhaps an option to the script could be added to provide the file name of the logo to display. I believe that I have packaged the logo in icon4.zip.

I think there is more to it than just putting a logo in. Item no. 3 in the license agreement says there should be 3 links plus a logo that links to the weather.com home page. The three links are links provided by them that could link to their site or to some third party advertising.

I did start to register for the xml feed but when I read the license agreement I decided I didn't agree with it so never complete the registration.

Personally I don't think there should be any advertising in Myth at all. I believe that to fully comply with their licence there will have to be active links that are supposed to open a web browser to show these links. How are the other programs using there feed getting around this?

I should say I'm no lawer and only glanced though the licence.

comment:13 in reply to:  12 Changed 16 years ago by simonflood

Replying to paulh:

I think there is more to it than just putting a logo in. Item no. 3 in the license agreement says there should be 3 links plus a logo that links to the weather.com home page. The three links are links provided by them that could link to their site or to some third party advertising.

I believe that the 3 links are the 3 links that are returned if you retrieve the Links as part of your weather request (by adding &link=xoap to the request URL). This is an optional request and links are not returned if the Partner ID is not supplied. 3 links are then supplied. Section 9.1 of the Weather XML Data Feed Implementation Guide talks about these links and what you must do with them. I sent an e-mail to the address given in the Implementation Guide but it bounced back as an unknown user(!) so I've now tried using the contact us/feedback form to start a dialogue with weather.com.

comment:14 Changed 16 years ago by maverik044

I don't think that media portal does anything with the links. Also keep in mind that mythweather is already using maps from weather.com, I would wonder if terms and conditions are respect there.

Changed 16 years ago by simonflood

Attachment: weathercomXML.3.pl added

Perl script to pull XML data from weather.com (v0.3)

comment:15 Changed 16 years ago by simonflood

Have now attached v0.3 of my Perl script to this ticket. It now observes weather.com's caching criteria - 15 minutes for current conditions and 2 hours for forecast. I've still to add in code to handle weathertypes.dat for using mythTV weather icons instead of weather.com provided ones (this will be optional - if weathertypes.dat exists then use mythTV ones, if not use weather.com). I'm also working on a script that scrapes the HTML for weather.com's hour-by-hour forecast (which will need an updated weather-ui.xml). Oh and I'm still waiting to hear anything back from weather.com re partner/license key for mythTV!

comment:16 Changed 16 years ago by anonymous

Sorry, but how do you install this?

comment:17 Changed 16 years ago by wongat

Was there a fix for adding pages(screens)? I try to add pages, but it will not save. Therefore it doesn't allow me to go to add sources.

comment:18 Changed 15 years ago by stuartm

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.