Compare commits
4
Commits
0.5.4
...
a92b63b855
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a92b63b855 | ||
|
|
712c7615a6 | ||
|
|
1b5d009cdf | ||
|
|
ca08bc282d |
@@ -6,4 +6,5 @@ PYTHON_VERSION=$(grep -m 1 'python' ./pyproject.toml | grep -oP 'python\s*=\s*"\
|
|||||||
DOCKER_PROJECTS=("gallery")
|
DOCKER_PROJECTS=("gallery")
|
||||||
DOCKER_TAG=latest
|
DOCKER_TAG=latest
|
||||||
|
|
||||||
OPENWEATHER_KEY="<EMPTY>"
|
OPENWEATHER_KEY=""
|
||||||
|
GISMETEO_AUTH=""
|
||||||
@@ -4,23 +4,12 @@ ignore=.venv
|
|||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable=
|
disable=
|
||||||
missing-docstring,
|
missing-docstring,
|
||||||
too-few-public-methods,
|
|
||||||
too-many-instance-attributes,
|
|
||||||
too-many-arguments,
|
|
||||||
too-many-locals,
|
|
||||||
too-many-boolean-expressions,
|
|
||||||
too-many-public-methods,
|
|
||||||
no-else-return,
|
|
||||||
singleton-comparison,
|
|
||||||
unused-argument,
|
|
||||||
unspecified-encoding,
|
|
||||||
fixme,
|
fixme,
|
||||||
|
invalid-name,
|
||||||
duplicate-code,
|
duplicate-code,
|
||||||
|
too-few-public-methods,
|
||||||
extension-pkg-allow-list=
|
too-many-locals,
|
||||||
lxml,
|
no-else-return
|
||||||
GeoIP,
|
|
||||||
pydantic
|
|
||||||
|
|
||||||
[MISCELLANEOUS]
|
[MISCELLANEOUS]
|
||||||
notes=FIXME,TODO
|
notes=FIXME,TODO
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
- OPENWEATHER_KEY=$OPENWEATHER_KEY
|
- OPENWEATHER_KEY=$OPENWEATHER_KEY
|
||||||
|
- GISMETEO_AUTH=$GISMETEO_AUTH
|
||||||
- DEBUG=1
|
- DEBUG=1
|
||||||
ports:
|
ports:
|
||||||
- 8000:80
|
- 8000:80
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
- OPENWEATHER_KEY=$OPENWEATHER_KEY
|
- OPENWEATHER_KEY=$OPENWEATHER_KEY
|
||||||
|
- GISMETEO_AUTH=$GISMETEO_AUTH
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from os import environ
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@@ -9,6 +10,7 @@ from fastapi import HTTPException, status
|
|||||||
from gallery.sketch.source import ApiSource
|
from gallery.sketch.source import ApiSource
|
||||||
from gallery.sketch.weather.api import WeatherApi
|
from gallery.sketch.weather.api import WeatherApi
|
||||||
from gallery.sketch.weather.model import Location, WeatherResponse, WeatherValue
|
from gallery.sketch.weather.model import Location, WeatherResponse, WeatherValue
|
||||||
|
from gallery.sketch.weather.util import merge_weather_values
|
||||||
|
|
||||||
from . import datehelp
|
from . import datehelp
|
||||||
from .parser import DAYS_PARSER, LOCATION_PARSER, ONE_DAY_PARSER, ROW_PARSERS
|
from .parser import DAYS_PARSER, LOCATION_PARSER, ONE_DAY_PARSER, ROW_PARSERS
|
||||||
@@ -20,18 +22,7 @@ class GismeteoApi(WeatherApi):
|
|||||||
PROVIDER = "gismeteo"
|
PROVIDER = "gismeteo"
|
||||||
SOURCE = ApiSource(
|
SOURCE = ApiSource(
|
||||||
"https://www.gismeteo.ru",
|
"https://www.gismeteo.ru",
|
||||||
cookies={
|
cookies={"xauth": auth} if (auth := environ.get("GISMETEO_AUTH")) else None,
|
||||||
"cf_clearance": (
|
|
||||||
"zPj8qeaYZWp5BUZsWIRD7kd32s59IDWWaVvD7GGf6b4-1724254262-1.2.1.1-"
|
|
||||||
"R1PaHoqlm4OEgHfrOg6oAJmVmFJ7053JI_QDjIFlCAmbNY0oyw1J4QtgmEkAkTWF4C99X5hpXmZB2en."
|
|
||||||
"9Ey3NL0kzaE10UGBHPli5OLxHNKC3wQ34xmxTxg6GcKouXOPRgqo92lVRpQP7ghvDmvvT_"
|
|
||||||
"S6YXDbRonkamptWhZiAsIhsnIQg2Mt7Lk1fxSEVbaey_RXVQBvaR2ofiFgIavcbQPRFSvJ."
|
|
||||||
"Ct_FujmymTAZWh1XHTptK32kur81NXyPuARThetOKQm8AklaMa855Oom6Bms1a4F9b0yEHSd2inA4j3FR7uauu8hhwO0Z2goa3."
|
|
||||||
"ktpXXAQLz6dm.fBEWIHD7wooda15X57tCcDOely4hxhO4LK2lIH6TbOr."
|
|
||||||
"rZQAiRRhltHiCizP1Ou2SiF_81lb1umoDh739tQD1cnw_USnL."
|
|
||||||
"JwTHvkB00ZnaHRMi4FCBrsKIE0NxJO6kiv1QANqumzf5.8_pSIGRo2cKeO8xCydduDNFbStdOmLR6FU7ZKqVu"
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _parse_oneday(self, date: datetime.date, data: str) -> WeatherResponse:
|
def _parse_oneday(self, date: datetime.date, data: str) -> WeatherResponse:
|
||||||
@@ -45,6 +36,10 @@ class GismeteoApi(WeatherApi):
|
|||||||
result.append({})
|
result.append({})
|
||||||
result[index][parser.KEY] = value
|
result[index][parser.KEY] = value
|
||||||
values = [WeatherValue(**item) for item in result]
|
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(
|
return WeatherResponse(
|
||||||
location=location or "n/a",
|
location=location or "n/a",
|
||||||
date=date,
|
date=date,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class ForecastItemParser:
|
|||||||
# TODO parse temperature interval flag
|
# TODO parse temperature interval flag
|
||||||
value.temperature = [round(item.main.temp)]
|
value.temperature = [round(item.main.temp)]
|
||||||
# value.temperature = [round(item.main.temp_max), round(item.main.temp_min)]
|
# 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.humidity = item.main.humidity
|
||||||
value.wind_speed = round(item.wind.speed)
|
value.wind_speed = round(item.wind.speed)
|
||||||
value.wind_gust = round(item.wind.gust)
|
value.wind_gust = round(item.wind.gust)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# pylint: skip-file
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
@@ -17,8 +18,8 @@ def icon_optimizator(file: Path):
|
|||||||
for node in tree.findall(".//{*}path"):
|
for node in tree.findall(".//{*}path"):
|
||||||
d = node.attrib["d"]
|
d = node.attrib["d"]
|
||||||
node.attrib["d"] = " ".join(map(normalize_value, d.split(" ")))
|
node.attrib["d"] = " ".join(map(normalize_value, d.split(" ")))
|
||||||
#file = file.parent.parent / "icons.tmp" / file.name
|
# file = file.parent.parent / "icons.tmp" / file.name
|
||||||
#file.parent.mkdir(parents=True, exist_ok=True)
|
# file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
tree.write(file)
|
tree.write(file)
|
||||||
target_size = file.stat().st_size
|
target_size = file.stat().st_size
|
||||||
print(file.name, source_size, target_size)
|
print(file.name, source_size, target_size)
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from os import environ
|
||||||
|
|
||||||
|
environ.setdefault("OPENWEATHER_KEY", "test")
|
||||||
Reference in New Issue
Block a user