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, '/')
|
relative_path = os.path.join(foldername, rel_part).replace(os.sep, '/')
|
||||||
filetype = os.path.splitext(entry.name)[1].lower()
|
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.
|
# Retrieve the hit count for this file.
|
||||||
hit_count = get_hit_count(relative_path)
|
hit_count = get_hit_count(relative_path)
|
||||||
|
|
||||||
@ -112,8 +116,6 @@ def updatefileindex():
|
|||||||
elif foldername == 'Gottesdienste Schwegenheim':
|
elif foldername == 'Gottesdienste Schwegenheim':
|
||||||
site = 'Schwegenheim'
|
site = 'Schwegenheim'
|
||||||
|
|
||||||
if filetype == '.mp3':
|
|
||||||
|
|
||||||
# Check for a corresponding transcript file in a sibling "Transkription" folder.
|
# Check for a corresponding transcript file in a sibling "Transkription" folder.
|
||||||
parent_dir = os.path.dirname(entry_path)
|
parent_dir = os.path.dirname(entry_path)
|
||||||
transcript_dir = os.path.join(parent_dir, "Transkription")
|
transcript_dir = os.path.join(parent_dir, "Transkription")
|
||||||
@ -167,12 +169,12 @@ def updatefileindex():
|
|||||||
titel = None
|
titel = None
|
||||||
name = None
|
name = None
|
||||||
|
|
||||||
# extract the date from path using regex (dd.mm.yyyy or dd.mm.yy)
|
# 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})', relative_path)
|
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:
|
if date_match:
|
||||||
date_str = date_match.group(1)
|
date_str = date_match.group(1)
|
||||||
performance_date = None
|
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:
|
try:
|
||||||
date_obj = datetime.strptime(date_str, fmt)
|
date_obj = datetime.strptime(date_str, fmt)
|
||||||
# Convert to ISO format YYYY-MM-DD
|
# Convert to ISO format YYYY-MM-DD
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user