mirror of
https://github.com/iiab/iiab.git
synced 2025-02-14 20:22:08 +00:00
Merge pull request #3835 from tim-moody/zimit
only support versioned zims if have YYYY-MM ending
This commit is contained in:
commit
1d9c0199cb
1 changed files with 12 additions and 5 deletions
|
@ -6,6 +6,7 @@ import os
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
|
import re
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
import iiab.iiab_const as CONST
|
import iiab.iiab_const as CONST
|
||||||
|
|
||||||
|
@ -46,11 +47,17 @@ def get_zim_list(path):
|
||||||
if filename in CONST.old_zim_map: # handle old names that don't parse
|
if filename in CONST.old_zim_map: # handle old names that don't parse
|
||||||
perma_ref = CONST.old_zim_map[filename]
|
perma_ref = CONST.old_zim_map[filename]
|
||||||
else:
|
else:
|
||||||
ulpos = filename.rfind("_")
|
# handle various zim name patterns:
|
||||||
# but old gutenberg and some other names are not canonical
|
# 1. canonical zim ending in _YYYY-MM
|
||||||
if filename.rfind("-") < 0: # non-canonical name
|
# as of 10/16/2024 it looks like all Kiwix zims fit this pattern
|
||||||
ulpos = filename[:ulpos].rfind("_")
|
# 2. otherwise assume no versioning and perma_ref = filename
|
||||||
perma_ref = filename[:ulpos]
|
|
||||||
|
match = re.search("_[0-5][0-9][0-5][0-9]-[0-5][0-9]$", filename)
|
||||||
|
if match:
|
||||||
|
perma_ref = filename[: match.span()[0]]
|
||||||
|
else:
|
||||||
|
perma_ref = filename
|
||||||
|
|
||||||
zim_info['file_name'] = filename
|
zim_info['file_name'] = filename
|
||||||
zim_versions[perma_ref] = zim_info # if there are multiples, last should win
|
zim_versions[perma_ref] = zim_info # if there are multiples, last should win
|
||||||
return files_processed, zim_versions
|
return files_processed, zim_versions
|
||||||
|
|
Loading…
Reference in a new issue