summaryrefslogtreecommitdiff
path: root/retronews/retronews.py
diff options
context:
space:
mode:
Diffstat (limited to 'retronews/retronews.py')
-rw-r--r--retronews/retronews.py50
1 files changed, 0 insertions, 50 deletions
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'