diff options
Diffstat (limited to 'retronews')
-rw-r--r-- | retronews/__init__.py | 8 | ||||
-rw-r--r-- | retronews/retronews.py | 50 |
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' |