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)
|
||||
|
||||
# query song name
|
||||
|
||||
name, = db.execute('''
|
||||
select
|
||||
name
|
||||
@ -23,7 +25,7 @@ def songpage(id):
|
||||
|
||||
album_info = db.execute('''
|
||||
select
|
||||
album_id, track, album.name, album.code
|
||||
track, album.name, album.code
|
||||
from
|
||||
song_album
|
||||
join
|
||||
@ -36,8 +38,48 @@ def songpage(id):
|
||||
(id,)
|
||||
).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',
|
||||
name=name,
|
||||
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:]
|
||||
)
|
||||
|
||||
print(clipdata['Motif'][1:])
|
||||
|
||||
# import motif
|
||||
cur.executemany(
|
||||
'insert into motif(id,name) values(?, ?)',
|
||||
|
||||
Binary file not shown.
@ -2,19 +2,36 @@
|
||||
{% block title %}{{ name }}{% endblock %}
|
||||
|
||||
{% 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>
|
||||
|
||||
<!-- Artist info -->
|
||||
|
||||
<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>
|
||||
<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>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<p>blah</p>
|
||||
|
||||
<p>Clips: </p>
|
||||
<ul>
|
||||
{% for song_id, motif_id, motif in clip_info %}
|
||||
<li>
|
||||
<audio
|
||||
controls
|
||||
src = "/static/clip/0001-001.flac">
|
||||
</audio>
|
||||
src = "/static/clip/{{ '%04d' % song_id }}-{{ '%03d' % motif_id }}.flac">
|
||||
</audio> {{ motif }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user