Skip to content

Commit

Permalink
Merge pull request #2616 from ronie/weather.multi-0.0.26
Browse files Browse the repository at this point in the history
[weather.multi] 0.0.26
  • Loading branch information
basrieter authored May 4, 2024
2 parents d222179 + 145652a commit 2b4f4ff
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 86 deletions.
2 changes: 1 addition & 1 deletion weather.multi/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="weather.multi" name="Multi Weather" version="0.0.22" provider-name="ronie">
<addon id="weather.multi" name="Multi Weather" version="0.0.26" provider-name="ronie">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.openweathermap.maps" version="1.0.4"/>
Expand Down
12 changes: 12 additions & 0 deletions weather.multi/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
v0.0.26
- language update

v0.0.25
- reinit session with each new url

v0.0.24
- try multiple yahoo urls in order to get cookie

v0.0.23
- fix yahoo weather again

v0.0.22
- fix weatherbit ozone value could be none

Expand Down
48 changes: 28 additions & 20 deletions weather.multi/lib/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .providers import weatherbit
from .providers import openweathermap

CURL = 'https://www.yahoo.com/?guccounter=2'
CURL = ['https://www.yahoo.com/', 'https://www.yahoo.com/?guccounter=1', 'https://www.yahoo.com/?guccounter=2', 'https://www.yahoo.com/?guccounter=', 'https://ca.yahoo.com/']
YURL = 'https://www.yahoo.com/news/weather/'
LCURL = 'https://www.yahoo.com/news/_tdnews/api/resource/WeatherSearch;text=%s'
FCURL = 'https://www.yahoo.com/news/_tdnews/api/resource/WeatherService;crumb={crumb};woeids=%5B{woeid}%5D'
Expand Down Expand Up @@ -86,7 +86,6 @@ def get_location(self, mode):
return location, locationid, locationlat, locationlon

def get_ycreds(self):
ysess = requests.Session()
ycookie = ADDON.getSettingString('ycookie')
ycrumb = ADDON.getSettingString('ycrumb')
ystamp = ADDON.getSettingString('ystamp')
Expand All @@ -95,25 +94,34 @@ def get_ycreds(self):
log('stamp from settings: %s' % ystamp)
if ystamp == '' or (int(time.time()) - int(ystamp) > 31536000): # cookie expires after 1 year
try:
retry = 0
while (retry < 6) and (not self.MONITOR.abortRequested()):
response = ysess.get(CURL, headers=HEADERS, timeout=10)
if response.status_code == 200:
for URL in CURL:
ysess = requests.Session()
retry = 0
while (retry < 6) and (not self.MONITOR.abortRequested()):
response = ysess.get(URL, headers=HEADERS, timeout=10)
if response.status_code == 200:
break
else:
self.MONITOR.waitForAbort(10)
retry += 1
log('getting yahoo website failed')
if 'consent' in response.url: # EU users are asked for cookie consent
log('EU user')
token = re.search('csrfToken" value="(.*?)"', response.text, flags=re.DOTALL).group(1)
sessionid = re.search('sessionId" value="(.*?)"', response.text, flags=re.DOTALL).group(1)
redirect = re.search('originalDoneUrl" value="(.*?)"', response.text, flags=re.DOTALL).group(1)
log('EU token: %s' % token)
log('EU sessionid: %s' % sessionid)
log('EU redirect %s' % redirect)
DATA = {'csrfToken': token, 'sessionId': sessionid, 'originalDoneUrl': redirect, 'namespace': 'yahoo', 'reject': 'reject'}
response = ysess.post(response.url, headers=HEADERS, data=DATA)
log('cookies: %s' % str(response.cookies))
if 'A3' in response.cookies:
ycookie = response.cookies['A3']
break
elif 'A1' in response.cookies:
ycookie = response.cookies['A1']
break
else:
self.MONITOR.waitForAbort(10)
retry += 1
log('getting yahoo website failed')
if 'consent' in response.url: # EU users are asked for cookie consent
token = re.search('csrfToken" value="(.*?)"', response.text, flags=re.DOTALL).group(1)
sessionid = re.search('sessionId" value="(.*?)"', response.text, flags=re.DOTALL).group(1)
redirect = re.search('originalDoneUrl" value="(.*?)"', response.text, flags=re.DOTALL).group(1)
DATA = {'csrfToken': token, 'sessionId': sessionid, 'originalDoneUrl': redirect, 'namespace': 'yahoo', 'reject': 'reject'}
response = ysess.post(response.url, headers=HEADERS, data=DATA)
try:
ycookie = response.cookies['A3']
except:
ycookie = response.cookies['A1']
response = ysess.get(YURL, headers=HEADERS, cookies=dict(A3=ycookie), timeout=10)
match = re.search('WeatherStore":{"crumb":"(.*?)","weathers', response.text, re.IGNORECASE)
if not match:
Expand Down
104 changes: 52 additions & 52 deletions weather.multi/resources/language/resource.language.et_ee/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ msgstr ""
"Project-Id-Version: Kodi add-ons\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2023-08-05 23:11+0000\n"
"Last-Translator: Toomas Tänava <toomas.tanava@mail.ee>\n"
"PO-Revision-Date: 2024-03-28 06:13+0000\n"
"Last-Translator: rimasx <riks_12@hot.ee>\n"
"Language-Team: Estonian <https://kodi.weblate.cloud/projects/kodi-add-ons-weather/weather-multi/et_ee/>\n"
"Language: et_ee\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.18.2\n"
"X-Generator: Weblate 5.4\n"

msgctxt "Addon Summary"
msgid "Weather forecast from several providers"
Expand Down Expand Up @@ -147,7 +147,7 @@ msgstr "Paduvihm"

msgctxt "#32214"
msgid "Freezing rain"
msgstr "Jäävihm"
msgstr "Jäine vihm"

msgctxt "#32215"
msgid "Light shower rain"
Expand Down Expand Up @@ -199,15 +199,15 @@ msgstr "Sajuhood"

msgctxt "#32227"
msgid "Mist"
msgstr "Udu"
msgstr "Sumu"

msgctxt "#32228"
msgid "Smoke"
msgstr "Suitsuvine"
msgstr "Suits"

msgctxt "#32229"
msgid "Haze"
msgstr "Udu"
msgstr "Hägune"

msgctxt "#32230"
msgid "Sand/dust"
Expand Down Expand Up @@ -247,183 +247,183 @@ msgstr "Teadmata sademed"

msgctxt "#32251"
msgid "Tornado"
msgstr ""
msgstr "Tornaado"

msgctxt "#32252"
msgid "Tropical Storm"
msgstr ""
msgstr "Troopiline torm"

msgctxt "#32253"
msgid "Hurricane"
msgstr ""
msgstr "Orkaan"

msgctxt "#32254"
msgid "Severe Thunderstorms"
msgstr ""
msgstr "Tugevad äikesetormid"

msgctxt "#32255"
msgid "Thunderstorms"
msgstr ""
msgstr "Äikesetormid"

msgctxt "#32256"
msgid "Mixed Rain and Snow"
msgstr ""
msgstr "Lumelörts ja vihm"

msgctxt "#32257"
msgid "Mixed Rain and Sleet"
msgstr ""
msgstr "Vihm ja lörts"

msgctxt "#32258"
msgid "Mixed Snow and Sleet"
msgstr ""
msgstr "Lumi ja lörts"

msgctxt "#32259"
msgid "Freezing Drizzle"
msgstr ""
msgstr "Külmavihm"

msgctxt "#32260"
msgid "Drizzle"
msgstr ""
msgstr "Uduvihm"

msgctxt "#32261"
msgid "Freezing Rain"
msgstr ""
msgstr "Jäävihm"

msgctxt "#32262"
msgid "Showers"
msgstr ""
msgstr "Hoovihm"

msgctxt "#32263"
msgid "Rain"
msgstr ""
msgstr "Vihm"

msgctxt "#32264"
msgid "Snow Flurries"
msgstr ""
msgstr "Lomehood"

msgctxt "#32265"
msgid "Light Snow Showers"
msgstr ""
msgstr "Kerged lumehood"

msgctxt "#32266"
msgid "Blowing Snow"
msgstr ""
msgstr "Hootine lumesadu"

msgctxt "#32267"
msgid "Snow"
msgstr ""
msgstr "Lumi"

msgctxt "#32268"
msgid "Hail"
msgstr ""
msgstr "Rahe"

msgctxt "#32269"
msgid "Sleet"
msgstr ""
msgstr "Lörts"

msgctxt "#32270"
msgid "Dust"
msgstr ""
msgstr "Tolm"

msgctxt "#32271"
msgid "Foggy"
msgstr ""
msgstr "Udune"

msgctxt "#32272"
msgid "Haze"
msgstr ""
msgstr "Hägu"

msgctxt "#32273"
msgid "Smoky"
msgstr ""
msgstr "Suitsuvine"

msgctxt "#32274"
msgid "Blustery"
msgstr ""
msgstr "Tormine"

msgctxt "#32275"
msgid "Windy"
msgstr ""
msgstr "Tuuline"

msgctxt "#32276"
msgid "Cold"
msgstr ""
msgstr "Külm"

msgctxt "#32277"
msgid "Cloudy"
msgstr ""
msgstr "Pilves"

msgctxt "#32278"
msgid "Mostly Cloudy"
msgstr ""
msgstr "Enamasti pilves"

msgctxt "#32279"
msgid "Partly Cloudy"
msgstr ""
msgstr "Osaliselt pilves"

msgctxt "#32280"
msgid "Clear"
msgstr ""
msgstr "Selge"

msgctxt "#32281"
msgid "Sunny"
msgstr ""
msgstr "Päikeseline"

msgctxt "#32282"
msgid "Fair"
msgstr ""
msgstr "Ilus"

msgctxt "#32283"
msgid "Mixed Rain and Hail"
msgstr ""
msgstr "Vihm ja rahe"

msgctxt "#32284"
msgid "Hot"
msgstr ""
msgstr "Palav"

msgctxt "#32285"
msgid "Isolated Thunderstorms"
msgstr ""
msgstr "Üksikud äikesetormid"

msgctxt "#32286"
msgid "Scattered Thunderstorms"
msgstr ""
msgstr "Hajutatud äikesetormid"

msgctxt "#32287"
msgid "Scattered Showers"
msgstr ""
msgstr "Hajutatud dušid"

msgctxt "#32288"
msgid "Heavy Rain"
msgstr ""
msgstr "Tugev vihm"

msgctxt "#32289"
msgid "Scattered Snow Showers"
msgstr ""
msgstr "Hajutatud lumehood"

msgctxt "#32290"
msgid "Heavy Snow"
msgstr ""
msgstr "Tugev lumesadu"

msgctxt "#32291"
msgid "Blizzard"
msgstr ""
msgstr "Tuisk"

msgctxt "#32292"
msgid "Not Available"
msgstr ""
msgstr "Pole saadaval"

msgctxt "#32293"
msgid "Scattered Showers"
msgstr ""
msgstr "Hajutatud vihmahood"

msgctxt "#32294"
msgid "Scattered Snow Showers"
msgstr ""
msgstr "Hajutatud lumehood"

msgctxt "#32295"
msgid "Scattered Thundershowers"
msgstr ""
msgstr "Hajutatud äikesevihmad"

msgctxt "#32300"
msgid "New Moon"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ msgstr ""
"Project-Id-Version: Kodi add-ons\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2023-01-01 16:16+0000\n"
"Last-Translator: skypichat <[email protected]>\n"
"PO-Revision-Date: 2024-02-21 15:13+0000\n"
"Last-Translator: ludovik <[email protected]>\n"
"Language-Team: French (France) <https://kodi.weblate.cloud/projects/kodi-add-ons-weather/weather-multi/fr_fr/>\n"
"Language: fr_fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.15\n"
"X-Generator: Weblate 5.4\n"

msgctxt "Addon Summary"
msgid "Weather forecast from several providers"
Expand Down Expand Up @@ -171,7 +171,7 @@ msgstr "Neige"

msgctxt "#32220"
msgid "Heavy snow"
msgstr "Beaucoup de neige"
msgstr "Neige abondante"

msgctxt "#32221"
msgid "Mix snow/rain"
Expand Down
Loading

0 comments on commit 2b4f4ff

Please sign in to comment.