Resolves #13
This commit is contained in:
parent
3b7e47fbfa
commit
12a6f72767
@ -18,8 +18,8 @@ class ValidShowEpisodeLineRequest(BaseModel):
|
||||
- **e**: episode id
|
||||
"""
|
||||
|
||||
s: str
|
||||
e: str
|
||||
s: int
|
||||
e: int
|
||||
|
||||
class Transcriptions(FastAPI):
|
||||
"""Transcription Endpoints"""
|
||||
@ -77,7 +77,7 @@ class Transcriptions(FastAPI):
|
||||
case _:
|
||||
return {
|
||||
'err': True,
|
||||
'errorText': 'Unknown endpoint.'
|
||||
'errorText': 'Unknown error.'
|
||||
}
|
||||
async with sqlite3.connect(database=db_path, timeout=1) as _db:
|
||||
async with _db.execute(db_query) as _cursor:
|
||||
@ -95,6 +95,37 @@ class Transcriptions(FastAPI):
|
||||
"""/transcriptions/get_episode_lines/
|
||||
Get lines for a particular episode
|
||||
"""
|
||||
return {
|
||||
'hi': True
|
||||
}
|
||||
show_id = data.s
|
||||
episode_id = data.e
|
||||
|
||||
match show_id:
|
||||
case 0:
|
||||
db_path = os.path.join("/", "var", "lib", "singerdbs", "sp.db")
|
||||
db_query = """SELECT ("S" || Season || "E" || Episode || " " || Title), Character, Line FROM SP_DAT WHERE ID = ?"""
|
||||
case 1:
|
||||
db_path = os.path.join("/", "var", "lib", "singerdbs", "futur.db")
|
||||
db_query = """SELECT ("S" || EP_S || "E" || EP_EP || " " || EP_TITLE || "<br><em>Opener: " || EP_OPENER || "</em>"), EP_LINE_SPEAKER, EP_LINE FROM clean_dialog WHERE EP_ID = ? ORDER BY LINE_ID ASC"""
|
||||
case 2:
|
||||
db_path = os.path.join("/", "var", "lib", "singerdbs", "parks.db")
|
||||
db_query = """SELECT ("S" || EP_S || "E" || EP_EP || " " || EP_TITLE), EP_LINE_SPEAKER, EP_LINE FROM clean_dialog WHERE EP_ID = ? ORDER BY id ASC"""
|
||||
|
||||
case _:
|
||||
return {
|
||||
'err': True,
|
||||
'errorText': 'Unknown error'
|
||||
}
|
||||
|
||||
async with sqlite3.connect(database=db_path, timeout=1) as _db:
|
||||
params = (episode_id,)
|
||||
async with _db.execute(db_query, params) as _cursor:
|
||||
result = await _cursor.fetchall()
|
||||
return {
|
||||
"episode_id": episode_id,
|
||||
"lines": [
|
||||
{
|
||||
'ep_friendly': item[0].strip(),
|
||||
'speaker': item[1].strip(),
|
||||
'line': item[2].strip()
|
||||
} for item in result]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user