Compare commits

...
4 Commits
10 changed files with 20 additions and 22 deletions
+2 -1
View File
@@ -6,4 +6,5 @@ PYTHON_VERSION=$(grep -m 1 'python' ./pyproject.toml | grep -oP 'python\s*=\s*"\
DOCKER_PROJECTS=("gallery")
DOCKER_TAG=latest
OPENWEATHER_KEY="<EMPTY>"
OPENWEATHER_KEY=""
GISMETEO_AUTH=""
+1
View File
@@ -13,6 +13,7 @@ services:
environment:
- REDIS_HOST=redis
- OPENWEATHER_KEY=$OPENWEATHER_KEY
- GISMETEO_AUTH=$GISMETEO_AUTH
- DEBUG=1
ports:
- 8000:80
+1
View File
@@ -13,6 +13,7 @@ services:
environment:
- REDIS_HOST=redis
- OPENWEATHER_KEY=$OPENWEATHER_KEY
- GISMETEO_AUTH=$GISMETEO_AUTH
depends_on:
- redis
ports:
@@ -173,7 +173,7 @@
{% for value in response.values %}
<td class="humidity"
style="background-color: rgba(128, 128, 255, {{value.humidity * 0.005}});">
<span class="value">{{value.humidity}}</span>
{% if value.humidity > -1%}<span class="value">{{value.humidity}}</span>{% endif %}
</td>
{% endfor %}
</tr>
+7 -12
View File
@@ -1,6 +1,7 @@
import datetime
import json
import logging
from os import environ
from typing import Any
from bs4 import BeautifulSoup
@@ -9,6 +10,7 @@ from fastapi import HTTPException, status
from gallery.sketch.source import ApiSource
from gallery.sketch.weather.api import WeatherApi
from gallery.sketch.weather.model import Location, WeatherResponse, WeatherValue
from gallery.sketch.weather.util import merge_weather_values
from . import datehelp
from .parser import DAYS_PARSER, LOCATION_PARSER, ONE_DAY_PARSER, ROW_PARSERS
@@ -20,18 +22,7 @@ class GismeteoApi(WeatherApi):
PROVIDER = "gismeteo"
SOURCE = ApiSource(
"https://www.gismeteo.ru",
cookies={
"cf_clearance": (
"zPj8qeaYZWp5BUZsWIRD7kd32s59IDWWaVvD7GGf6b4-1724254262-1.2.1.1-"
"R1PaHoqlm4OEgHfrOg6oAJmVmFJ7053JI_QDjIFlCAmbNY0oyw1J4QtgmEkAkTWF4C99X5hpXmZB2en."
"9Ey3NL0kzaE10UGBHPli5OLxHNKC3wQ34xmxTxg6GcKouXOPRgqo92lVRpQP7ghvDmvvT_"
"S6YXDbRonkamptWhZiAsIhsnIQg2Mt7Lk1fxSEVbaey_RXVQBvaR2ofiFgIavcbQPRFSvJ."
"Ct_FujmymTAZWh1XHTptK32kur81NXyPuARThetOKQm8AklaMa855Oom6Bms1a4F9b0yEHSd2inA4j3FR7uauu8hhwO0Z2goa3."
"ktpXXAQLz6dm.fBEWIHD7wooda15X57tCcDOely4hxhO4LK2lIH6TbOr."
"rZQAiRRhltHiCizP1Ou2SiF_81lb1umoDh739tQD1cnw_USnL."
"JwTHvkB00ZnaHRMi4FCBrsKIE0NxJO6kiv1QANqumzf5.8_pSIGRo2cKeO8xCydduDNFbStdOmLR6FU7ZKqVu"
)
},
cookies={"xauth": auth} if (auth := environ.get("GISMETEO_AUTH")) else None,
)
def _parse_oneday(self, date: datetime.date, data: str) -> WeatherResponse:
@@ -45,6 +36,10 @@ class GismeteoApi(WeatherApi):
result.append({})
result[index][parser.KEY] = value
values = [WeatherValue(**item) for item in result]
# group values by 3 hours
if len(values) > 8:
n = 3
values = [merge_weather_values(values[i].date, values[i : i + n]) for i in range(0, len(values), n)]
return WeatherResponse(
location=location or "n/a",
date=date,
+1 -1
View File
@@ -29,7 +29,7 @@ class ForecastItemParser:
# TODO parse temperature interval flag
value.temperature = [round(item.main.temp)]
# value.temperature = [round(item.main.temp_max), round(item.main.temp_min)]
value.pressure = [round(item.main.pressure / 133.3 * 100)]
value.pressure = [round(item.main.pressure * 0.75006)]
value.humidity = item.main.humidity
value.wind_speed = round(item.wind.speed)
value.wind_gust = round(item.wind.gust)
+3 -3
View File
@@ -2,7 +2,7 @@ import datetime
from enum import StrEnum, auto
from typing import Self
from pydantic import BaseModel
from pydantic import BaseModel, Field
class Model(BaseModel):
@@ -116,8 +116,8 @@ class WeatherValue(Model):
wind_gust: int
wind_direction: float
precipitation: float
pressure: list[int]
humidity: int
pressure: list[int] = Field(default=[])
humidity: int = Field(default=-1)
class WeatherResponse(Model):
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "gallery"
description = ""
version = "0.5.3"
version = "0.5.4"
readme = "README.md"
authors = [{ name = "shmyga", email = "shmyga.z@gmail.com" }]
requires-python = '>=3.14,<4.0'
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "gallery",
"version": "0.5.3",
"version": "0.5.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gallery",
"version": "0.5.3",
"version": "0.5.4",
"license": "ISC",
"dependencies": {
"@popperjs/core": "^2.11.8",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gallery",
"version": "0.5.3",
"version": "0.5.4",
"type": "module",
"scripts": {
"build": "webpack --mode production",