Skip to content

Commit

Permalink
Merge pull request #2553 from vlmaksime/weather.gismeteo@krypton
Browse files Browse the repository at this point in the history
[weather.gismeteo@krypton] 0.6.4
  • Loading branch information
basrieter authored Dec 2, 2023
2 parents 800c72a + c6e7849 commit 27c45d5
Show file tree
Hide file tree
Showing 7 changed files with 414 additions and 115 deletions.
7 changes: 5 additions & 2 deletions weather.gismeteo/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="weather.gismeteo" version="0.6.3" name="Gismeteo" provider-name="vl.maksime">
<addon id="weather.gismeteo" version="0.6.4" name="Gismeteo" provider-name="vl.maksime">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.simpleplugin3" version="3.0.5"/>
Expand All @@ -13,25 +13,28 @@
<summary lang="fr_FR">Gismeteo prévisions météorologiques. Prévisions météorologiques en temps réel à travers le monde.</summary>
<summary lang="sv_SE">Gismeteo Weather Forecast. Realtidsväder och detaljerade prognoser över hela världen</summary>
<summary lang="is_IS">Gismeteo veðurspá. Rauntíma veðurlýsing og nákvæmar veðurspár um víða veröld</summary>
<summary lang="de_DE">Gismeteo Wettervorhersage. Echtzeitwetter und detailierte Vorhersagen auf der ganzen Welt</summary>
<description lang="en_GB">The weather is provided solely for personal non-commercial use</description>
<description lang="ru_RU">Погода предоставлена исключительно для личного некоммерческого использования</description>
<description lang="es_ES">El clima se proporciona únicamente para su uso personal y no comercial</description>
<description lang="fr_FR">La météo est fournie pour un usage personnel non-commercial.</description>
<description lang="sv_SE">Vädret tillhandahålls enbart för personligt, icke-kommersiellt bruk</description>
<description lang="is_IS">Veðurupplýsingarnar eru einungis til einkanota og ekki í hagnaðarskyni</description>
<description lang="de_DE">Das Wetter wird nur für persönlichen, nicht-kommerziellen Gebrauch zur Verfügung gestellt</description>
<disclaimer lang="en_GB">The weather forecast has been prepared by MapMakers Group Ltd</disclaimer>
<disclaimer lang="ru_RU">Прогноз погоды подготовлен НПЦ "Мэп Мейкер"</disclaimer>
<disclaimer lang="es_ES">El pronóstico del tiempo ha sido preparado por MapMakers Group Ltd</disclaimer>
<disclaimer lang="fr_FR">Les prévisions météorologiques sont mises à disposition par MapMakers Group Ltd</disclaimer>
<disclaimer lang="sv_SE">Väderprognosen har utarbetats av MapMakers Group Ltd.</disclaimer>
<disclaimer lang="is_IS">Veðurspáin var útbúin af MapMakers Group Ltd</disclaimer>
<disclaimer lang="de_DE">Die Wettervorhersage wurde von MapMakers Group Ltd vorbereitet</disclaimer>
<platform>all</platform>
<license>GPL-3.0-only</license>
<forum>https://forum.kodi.tv/showthread.php?tid=323624</forum>
<website>https://www.gismeteo.com/</website>
<email>[email protected]</email>
<source>https://github.com/vlmaksime/weather.gismeteo</source>
<news>v0.6.3 (2021-09-27)[CR]- Fixed identified bugs[CR][CR]v0.6.2 (2021-05-31)[CR]- Updated compatibility with Kodi 19[CR]- Added Icelandic translation (sveinki) [CR][CR]v0.6.1 (2021-04-03)[CR]- SimplePlugin 3 module moved into external addon[CR]- Small changes in the add-on structure [CR]- Added French translation (DavidHenryThoreau)[CR]- Added Swedish translation (Sopor)</news>
<news>v0.6.4 (2023-10-30)[CR]- Adapted to changes in the service API[CR]- Added German translation (kyoforkshomebrews)[CR][CR]v0.6.3 (2021-09-27)[CR]- Fixed identified bugs[CR][CR]v0.6.2 (2021-05-31)[CR]- Updated compatibility with Kodi 19[CR]- Added Icelandic translation (sveinki)[CR][CR]v0.6.1 (2021-04-03)[CR]- SimplePlugin 3 module moved into external addon[CR]- Small changes in the add-on structure [CR]- Added French translation (DavidHenryThoreau)[CR]- Added Swedish translation (Sopor)</news>
<assets>
<icon>icon.png</icon>
</assets>
Expand Down
4 changes: 4 additions & 0 deletions weather.gismeteo/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.6.4 (2023-11-30)
- Adapted to changes in the service API
- Added German translation (kyoforkshomebrews)

v0.6.3 (2021-09-27)
- Fixed identified bugs

Expand Down
48 changes: 24 additions & 24 deletions weather.gismeteo/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from __future__ import unicode_literals

from builtins import range
import os
import time
from builtins import range

import xbmc
from simpleplugin import translate_path

from resources.libs import Gismeteo, GismeteoError, Location, Weather, WebClientError
from simpleplugin import translate_path

weather = Weather()
_ = weather.initialize_gettext()
Expand Down Expand Up @@ -68,8 +68,8 @@ def set_item_info(props, item, item_type, icon='%s.png', day_temp=None):
if 'FanartCode' in keys:
props['FanartCode'] = weather_code

if 'ProviderIcon' in keys\
and weather.use_provider_icon:
if 'ProviderIcon' in keys \
and weather.use_provider_icon:
props['ProviderIcon'] = 'resource://resource.images.weatherprovidericons.gismeteo/{0}.png'.format(item['icon'])

# Wind
Expand Down Expand Up @@ -126,13 +126,17 @@ def set_item_info(props, item, item_type, icon='%s.png', day_temp=None):
props['FeelsLike'] = weather.TEMP(item['temperature']['comfort']) + weather.TEMPUNIT

if day_temp is not None:
if 'TempMorn' in keys:
if 'TempMorn' in keys \
and day_temp.get('morn') is not None:
props['TempMorn'] = weather.TEMP(day_temp['morn']) + weather.TEMPUNIT
if 'TempDay' in keys:
if 'TempDay' in keys \
and day_temp.get('day') is not None:
props['TempDay'] = weather.TEMP(day_temp['day']) + weather.TEMPUNIT
if 'TempEve' in keys:
if 'TempEve' in keys \
and day_temp.get('eve') is not None:
props['TempEve'] = weather.TEMP(day_temp['eve']) + weather.TEMPUNIT
if 'TempNight' in keys:
if 'TempNight' in keys \
and day_temp.get('night') is not None:
props['TempNight'] = weather.TEMP(day_temp['night']) + weather.TEMPUNIT

# Humidity
Expand All @@ -154,17 +158,18 @@ def set_item_info(props, item, item_type, icon='%s.png', day_temp=None):

if 'Pressure' in keys:
pressure = item['pressure']['avg'] if item_type == 'day' else item['pressure']
props['Pressure'] = '{0} {1}'.format(weather.PRESSURE(pressure), _(weather.PRESUNIT)) if pressure is not None else _('n/a')
props['Pressure'] = '{0} {1}'.format(weather.PRESSURE(pressure),
_(weather.PRESUNIT)) if pressure is not None else _('n/a')

# Precipitation

if 'Precipitation' in keys:
precip = item['precipitation']['amount']
props['Precipitation'] = '{0} {1}'.format(weather.PRECIPITATION(precip), _(weather.PRECIPUNIT)) if precip is not None else _('n/a')
props['Precipitation'] = '{0} {1}'.format(weather.PRECIPITATION(precip),
_(weather.PRECIPUNIT)) if precip is not None else _('n/a')


def clear():

# Current
weather.set_properties(weather.prop_current(), 'Current')

Expand Down Expand Up @@ -279,7 +284,7 @@ def set_location_props(forecast_info):

# Hourly
if count_hourly < MAX_HOURLY \
and hour['date']['unix'] >= CURRENT_TIME['unix']:
and hour['date']['unix'] >= CURRENT_TIME['unix']:
hourly_props = weather.prop_hourly()
set_item_info(hourly_props, hour, 'hour', WEATHER_ICON)
weather.set_properties(hourly_props, 'Hourly', count_hourly + 1)
Expand All @@ -288,10 +293,10 @@ def set_location_props(forecast_info):

# 36Hour
if count_36hour < MAX_36HOUR \
and hour['tod'] in [2, 3]:
and hour['tod'] in [2, 3]:
if hour['tod'] == 2 \
and hour['date']['unix'] >= CURRENT_TIME['unix'] \
or hour['tod'] == 3:
and hour['date']['unix'] >= CURRENT_TIME['unix'] \
or hour['tod'] == 3:
_36hour_props = weather.prop_36hour()
set_item_info(_36hour_props, hour, 'hour', WEATHER_ICON)

Expand Down Expand Up @@ -320,7 +325,7 @@ def set_location_props(forecast_info):

# Weekend
if weather.is_weekend(day) \
and count_weekends <= MAX_WEEKENDS:
and count_weekends <= MAX_WEEKENDS:
weekend_props = weather.prop_daily()
set_item_info(weekend_props, day, 'day', WEATHER_ICON, day_temp)
weather.set_properties(weekend_props, 'Weekend', count_weekends + 1)
Expand Down Expand Up @@ -356,7 +361,6 @@ def set_location_props(forecast_info):

@weather.action('root')
def forecast(params):

location = get_location(params.id)
if location.id:
try:
Expand Down Expand Up @@ -406,7 +410,6 @@ def location(params):

@weather.mem_cached(30)
def _location_forecast(lang, _id):

gismeteo = Gismeteo(lang)

params = {'city_id': _id,
Expand All @@ -415,20 +418,18 @@ def _location_forecast(lang, _id):
return _call_method(gismeteo.forecast, params)



@weather.mem_cached(10)
def _ip_locations(lang):

gismeteo = Gismeteo(lang)

return _call_method(gismeteo.cities_ip)

def get_location(loc_id):

def get_location(loc_id):
use_current_location = weather.get_setting('CurrentLocation')

if loc_id == '1' \
and use_current_location:
and use_current_location:
try:
lang = weather.gismeteo_lang()
ip_locations = _ip_locations(lang)
Expand All @@ -446,7 +447,7 @@ def get_location(loc_id):
location_id = weather.get_setting('Location{0}ID'.format(int_loc_id))

if not location_id \
and int_loc_id != 1:
and int_loc_id != 1:
int_loc_id = 1

location_id = weather.get_setting('Location{0}ID'.format(int_loc_id))
Expand Down Expand Up @@ -479,7 +480,6 @@ def _call_method(func, params=None):


if __name__ == '__main__':

description = weather.prop_description()

description['Forecast.IsFetched'] = 'true'
Expand Down
Loading

0 comments on commit 27c45d5

Please sign in to comment.