Looking at the error I posted it is clear that the int() function is expecting a "2" string and not the long string shown in the error. Therefore something is not right in the logic that partitions the strings from the feed. I'm not familiar with python at all but have tried to trace back the code.
As of now, the feed I use is:
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="http://meteoalarm.eu/documents/rss/es/ES001.rss" rel="self" type="application/rss+xml"/>
<title>Meteoalarm Spain, Barcelona</title>
<link>https://www.meteoalarm.eu/es_ES/0/0/ES001.html</link>
<description>Metoalarm actual warnings from Spain, Barcelona</description>
<ttl>10</ttl>
<language>eng</language>
<item>
<title>Barcelona</title>
<link>https://www.meteoalarm.eu/es_ES/0/0/ES001.html</link>
<description><![CDATA[<table border="0" cellspacing="0" cellpadding="3"><tr><th colspan="3" align="left">Today</th></tr><tr><td width="28"><img border="1" src="https://www.meteoalarm.eu/documents/rss/wflag-l2-t10.jpg" alt="awt:10 level:2"></td><td><b>From: </b><i>18.11.2018 09:00 CET</i><b> Until: </b><i>18.11.2018 20:59 CET</i></td></tr><tr><td width="28"></td><td></td></tr><tr><th colspan="3" align="left"><br />Tomorrow</th></tr><tr><td width="28"><img border="1" src="https://www.meteoalarm.eu/documents/rss/wflag-l1-t4.jpg" alt="awt:4 level:1"></td></tr><tr><td width="28"></td><td>No special awareness required</td></tr></table>]]></description>
<pubDate>Sun, 18 Nov 2018 08:59:12 +0100</pubDate>
<guid isPermaLink="false">d31bb52bb3b94d8322370ae3b3f15c2c</guid>
</item>
</channel>
</rss>
Looking through the code I found that that string is LEVELValue, which is partitioned in lines 156-160.
In line 158, the string AWTPossitions[1] is:
Code: Select all
10 level:2">-/td>-td>-b>From: -/b>-i>18.11.2018 09:00 CET-/i>-b> Until: -/b>-i>18.11.2018 20:59 CET-/i>-/td>-/tr>-tr>-td width="28">-/td>-td>-/td>-/tr>-tr>-th colspan="3" align="left">-br />
This line correctly extracts value 10 for AWTvalue.
However line 160:
Code: Select all
LEVELvalue = AWTPossitions[AWTPos].split('level:')[1].split('border')[0].replace('"','').strip()
tries to split the string using "border", which is not present, therefore it delivers a wrong result for LEVELvalue.
In turn, the list AWTPossitions comes from FeedValueFTd, which is:
Code: Select all
<tr>TODAY </th></tr><tr><td width="28"><img border="1" src="https://www.meteoalarm.eu/documents/rss/wflag-l2-t10.jpg" alt="awt:10 level:2"></td><td><b>From: </b><i>18.11.2018 11:00 CET</i><b> Until: </b><i>18.11.2018 20:59 CET</i></td></tr><tr><td width="28"></td><td></td></tr><tr><th colspan="3" align="left"><br />
In line 152 this is split using string "awt:" and "<" are replaced by "-", so:
Code: Select all
AWTpossitions[0] = -tr>TODAY -/th>-/tr>-tr>-td width="28">-img border="1" src="https://www.meteoalarm.eu/documents/rss/wflag-l2-t10.jpg" alt="
AWTPossitions[1] = 10 level:2">-/td>-td>-b>From: -/b>-i>18.11.2018 11:00 CET-/i>-b> Until: -/b>-i>18.11.2018 20:59 CET-/i>-/td>-/tr>-tr>-td width="28">-/td>-td>-/td>-/tr>-tr>-th colspan="3" align="left">-br />
Unless I have missed something, at this points it seems pretty obvious that the code is expecting a different format to that the feed is using. I checked other feeds containing alerts and they seem to use that "border" tag as the code expects, but apparently some do not; it looks like it depends on there actually being an alert or not, or maybe on there being one or more. You may want to give it a quick review. I hope this helps.