adds artist info and motif name to song pages
This commit is contained in:
parent
1f6d448c74
commit
6c8a9b1da0
46
app.py
46
app.py
@ -8,6 +8,8 @@ def songpage(id):
|
|||||||
|
|
||||||
db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
||||||
|
|
||||||
|
# query song name
|
||||||
|
|
||||||
name, = db.execute('''
|
name, = db.execute('''
|
||||||
select
|
select
|
||||||
name
|
name
|
||||||
@ -23,7 +25,7 @@ def songpage(id):
|
|||||||
|
|
||||||
album_info = db.execute('''
|
album_info = db.execute('''
|
||||||
select
|
select
|
||||||
album_id, track, album.name, album.code
|
track, album.name, album.code
|
||||||
from
|
from
|
||||||
song_album
|
song_album
|
||||||
join
|
join
|
||||||
@ -36,8 +38,48 @@ def songpage(id):
|
|||||||
(id,)
|
(id,)
|
||||||
).fetchall()
|
).fetchall()
|
||||||
|
|
||||||
|
# query artist info
|
||||||
|
|
||||||
|
artist_info = db.execute('''
|
||||||
|
select
|
||||||
|
artist.name, artist.name_rm, credit.name
|
||||||
|
from
|
||||||
|
song_artist
|
||||||
|
join
|
||||||
|
artist
|
||||||
|
on
|
||||||
|
song_artist.artist_id=artist.id
|
||||||
|
join
|
||||||
|
credit
|
||||||
|
on
|
||||||
|
song_artist.credit_id=credit.id
|
||||||
|
where
|
||||||
|
song_id = ?
|
||||||
|
''',
|
||||||
|
(id,)
|
||||||
|
).fetchall()
|
||||||
|
|
||||||
|
# query clip info
|
||||||
|
|
||||||
|
clip_info = db.execute('''
|
||||||
|
select
|
||||||
|
song_id, motif_id, motif.name
|
||||||
|
from
|
||||||
|
clip
|
||||||
|
join
|
||||||
|
motif
|
||||||
|
on
|
||||||
|
clip.motif_id=motif.id
|
||||||
|
where
|
||||||
|
song_id = ?
|
||||||
|
''',
|
||||||
|
(id,)
|
||||||
|
).fetchall()
|
||||||
|
|
||||||
return flask.render_template('song.jinja',
|
return flask.render_template('song.jinja',
|
||||||
name=name,
|
name=name,
|
||||||
id=id,
|
id=id,
|
||||||
album_info=album_info
|
album_info=album_info,
|
||||||
|
clip_info=clip_info,
|
||||||
|
artist_info=artist_info
|
||||||
)
|
)
|
||||||
@ -37,6 +37,8 @@ cur.executemany(
|
|||||||
data['Credit'][1:]
|
data['Credit'][1:]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(clipdata['Motif'][1:])
|
||||||
|
|
||||||
# import motif
|
# import motif
|
||||||
cur.executemany(
|
cur.executemany(
|
||||||
'insert into motif(id,name) values(?, ?)',
|
'insert into motif(id,name) values(?, ?)',
|
||||||
|
|||||||
Binary file not shown.
@ -2,19 +2,36 @@
|
|||||||
{% block title %}{{ name }}{% endblock %}
|
{% block title %}{{ name }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Now Playing: {{ id }}. {{ name }} ({% for _, _, _, album_code in album_info %}{{ album_code }}{% if not loop.last %}, {% endif %}{% endfor %})
|
<h1>Now Playing: {{ id }}. {{ name }} ({% for _, _, album_code in album_info %}{{ album_code }}{% if not loop.last %}, {% endif %}{% endfor %})
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
|
<!-- Artist info -->
|
||||||
|
|
||||||
<p>Artist: </p>
|
<p>Artist: </p>
|
||||||
|
<ul>
|
||||||
|
{% for name, name_rm, credit in artist_info %}
|
||||||
|
<li>{{ name_rm }} ({{ name }}): {{ credit }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- Album info -->
|
||||||
|
|
||||||
<p>Album: </p>
|
<p>Album: </p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for album_id, track, album_name, album_code in album_info %}
|
{% for track, album_name, album_code in album_info %}
|
||||||
<li>{{ album_name }} #{{ track }}</li>
|
<li>{{ album_name }} #{{ track }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<p>blah</p>
|
|
||||||
<p>Clips: </p>
|
<p>Clips: </p>
|
||||||
|
<ul>
|
||||||
|
{% for song_id, motif_id, motif in clip_info %}
|
||||||
|
<li>
|
||||||
<audio
|
<audio
|
||||||
controls
|
controls
|
||||||
src = "/static/clip/0001-001.flac">
|
src = "/static/clip/{{ '%04d' % song_id }}-{{ '%03d' % motif_id }}.flac">
|
||||||
</audio>
|
</audio> {{ motif }}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user