summaryrefslogtreecommitdiff
path: root/retronews
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-12-30 15:37:08 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-12-30 15:37:08 +0300
commitabd1975def213891afdf0d87adbf79c2c7dbc0cb (patch)
tree4c0feb5ecc7f8dcf5c17e74a81a2bae9ba6c649f /retronews
parent38474234431fcf1dae50c00cdf649b4102c0faf9 (diff)
Diffstat (limited to 'retronews')
-rw-r--r--retronews/__init__.py8
-rw-r--r--retronews/retronews.py50
2 files changed, 0 insertions, 58 deletions
diff --git a/retronews/__init__.py b/retronews/__init__.py
deleted file mode 100644
index ae3b518..0000000
--- a/retronews/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from .retronews import (
- convert_date,
- parse_url,
- doc_info,
- page_info,
- thumbnail_url,
- tile_url
-) \ No newline at end of file
diff --git a/retronews/retronews.py b/retronews/retronews.py
deleted file mode 100644
index 9e80c58..0000000
--- a/retronews/retronews.py
+++ /dev/null
@@ -1,50 +0,0 @@
-import re
-import requests
-
-MONTHS = dict(
- jan=1,
- feb=2,
- mar=3,
- apr=4,
- may=5,
- jun=6,
- jul=7,
- juillet=7,
- aout=8,
- aug=8,
- sep=9,
- oct=10,
- nov=11,
- novembre=11, # https://www.retronews.fr/journal/mercure-de-france/15-novembre-1905/118/2617647/1
- dec=12
-)
-
-
-def convert_date(s: str) -> tuple[str, str, str]:
- m = re.match(r'^(\d{2})-(.*?)-(\d{4})$', s).groups()
- year = m[2]
- month = '%02d' % MONTHS[m[1]]
- day = m[0]
- return year, month, day
-
-
-def parse_url(url: str) -> tuple:
- return re.search(r'/(?:[\-\d\w]+)/([^/]+)/(\d+)/(\d+)/', url).groups()
-
-
-def doc_info(collection_id, doc_id):
- r = requests.get(f'https://pv5web.retronews.fr/api/document/{collection_id}/{doc_id}')
- return r.json()
-
-
-def page_info(collection_id, doc_id, page):
- r = requests.get(f'https://pv5web.retronews.fr/api/document/{collection_id}/{doc_id}/page/{page}/')
- return r.json()
-
-
-def thumbnail_url(collection_id, doc_id, page) -> str:
- return f'https://pv5web.retronews.fr/api/document/{collection_id}/{doc_id}/page/{page}/thumbnail'
-
-
-def tile_url(collection_id, doc_id, page, v_tile, h_tile) -> str:
- return f'https://pv5web.retronews.fr/api/document/{collection_id}/{doc_id}/page/{page}/tile/{h_tile}/{v_tile}/0'