fix date in index
This commit is contained in:
parent
da98a8b6e6
commit
688625f451
@ -101,6 +101,10 @@ def updatefileindex():
|
||||
relative_path = os.path.join(foldername, rel_part).replace(os.sep, '/')
|
||||
filetype = os.path.splitext(entry.name)[1].lower()
|
||||
|
||||
if filetype not in ['.mp3', '.wav', '.ogg', '.m4a', '.flac']:
|
||||
# Skip non-audio files.
|
||||
continue
|
||||
|
||||
# Retrieve the hit count for this file.
|
||||
hit_count = get_hit_count(relative_path)
|
||||
|
||||
@ -112,8 +116,6 @@ def updatefileindex():
|
||||
elif foldername == 'Gottesdienste Schwegenheim':
|
||||
site = 'Schwegenheim'
|
||||
|
||||
if filetype == '.mp3':
|
||||
|
||||
# Check for a corresponding transcript file in a sibling "Transkription" folder.
|
||||
parent_dir = os.path.dirname(entry_path)
|
||||
transcript_dir = os.path.join(parent_dir, "Transkription")
|
||||
@ -167,12 +169,12 @@ def updatefileindex():
|
||||
titel = None
|
||||
name = None
|
||||
|
||||
# extract the date from path using regex (dd.mm.yyyy or dd.mm.yy)
|
||||
date_match = re.search(r'(\d{1,2}\.\d{1,2}\.\d{2,4})', relative_path)
|
||||
# extract the date from path using regex (supports YYYY.MM.DD, DD.MM.YYYY or DD.MM.YY)
|
||||
date_match = re.search(r'(\d{1,2}\.\d{1,2}\.\d{2,4}|\d{4}\.\d{2}\.\d{2})', relative_path)
|
||||
if date_match:
|
||||
date_str = date_match.group(1)
|
||||
performance_date = None
|
||||
for fmt in ('%d.%m.%Y', '%d.%m.%y', '%Y-%m-%d'):
|
||||
for fmt in ('%Y.%m.%d', '%d.%m.%Y', '%d.%m.%y', '%Y-%m-%d'):
|
||||
try:
|
||||
date_obj = datetime.strptime(date_str, fmt)
|
||||
# Convert to ISO format YYYY-MM-DD
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user