fix transcript in search
This commit is contained in:
parent
ddb1ef4d3d
commit
45c50d68a7
19
search.py
19
search.py
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from flask import Flask, render_template, request, request, jsonify, session
|
from flask import Flask, render_template, request, request, jsonify, session
|
||||||
import random
|
import random
|
||||||
@ -123,8 +124,22 @@ def searchcommand():
|
|||||||
transcript.lower().count(w.lower()) for w in words
|
transcript.lower().count(w.lower()) for w in words
|
||||||
)
|
)
|
||||||
record.pop('transcript', None)
|
record.pop('transcript', None)
|
||||||
record['fulltext_url'] = f"/media/{quote(record.get('relative_path', ''), safe='/')}"
|
|
||||||
record['fulltext_type'] = 'sng' if (record.get('filetype') or '').lower() == '.sng' else 'transcript'
|
filetype = (record.get('filetype') or '').lower()
|
||||||
|
if filetype == '.sng':
|
||||||
|
record['fulltext_type'] = 'sng'
|
||||||
|
record['fulltext_url'] = f"/media/{quote(record.get('relative_path', ''), safe='/')}"
|
||||||
|
else:
|
||||||
|
record['fulltext_type'] = 'transcript'
|
||||||
|
relative_path = record.get('relative_path', '')
|
||||||
|
filename = record.get('filename', '')
|
||||||
|
name_root = os.path.splitext(filename)[0] if filename else os.path.splitext(os.path.basename(relative_path))[0]
|
||||||
|
parent = os.path.dirname(relative_path)
|
||||||
|
if parent:
|
||||||
|
transcript_rel_path = f"{parent}/Transkription/{name_root}.md"
|
||||||
|
else:
|
||||||
|
transcript_rel_path = f"Transkription/{name_root}.md"
|
||||||
|
record['fulltext_url'] = f"/transcript/{quote(transcript_rel_path, safe='/')}"
|
||||||
# convert date to TT.MM.YYYY format
|
# convert date to TT.MM.YYYY format
|
||||||
if record.get('performance_date'):
|
if record.get('performance_date'):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user