Skip to content

Commit afdcb22

Browse files
committed
small fix to weather getter
it did not always get the most updated data
1 parent 35fba82 commit afdcb22

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

eClockDataGetter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
def fnGetWeather():
1818
data_timediff = int(config.get('Weather','Refresh'))*60
1919
try:
20-
data_timediff = int(time.time()) - int(os.path.getmtime('data_weather.txt'))
20+
with open('data_weather.txt') as fp:
21+
json_obj = json.load(fp)
22+
data_timediff = int(time.time()) - int(json_obj['dt'])
23+
2124
except:
2225
data_timediff = int(config.get('Weather','Refresh'))*61
2326

@@ -101,11 +104,12 @@ def fnGetDlna():
101104
value_audio = response_data[count_audio:count_audioe]
102105
value_audio = value_audio.replace('Audio files</td><td>','')
103106
value_audio = value_audio.replace('</td>','')
107+
value_updated = int(time.time())
104108

105109
if int(value_audio) <= 0:
106110
raise Exception("No Audio??")
107111

108-
data = {'audio':value_audio, 'video':value_video}
112+
data = {'audio':value_audio, 'video':value_video, 'updated':value_updated}
109113
with open('data_dlna.txt','w') as fp:
110114
json.dump(data, fp)
111115

0 commit comments

Comments
 (0)