mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
We got the first working webpage!
This commit is contained in:
parent
0dd6cd9dd5
commit
f88852ee6a
@ -72,9 +72,12 @@ meta.create_all(engine)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### Conversions between DB and dicts
|
||||||
|
## These should only take the row info from their respective table and fill in
|
||||||
|
## other information by calling the respective id lookup functions
|
||||||
|
|
||||||
def scrobble_db_to_dict(row):
|
def scrobble_db_to_dict(row):
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"time":row.timestamp,
|
"time":row.timestamp,
|
||||||
"track":get_track(row.track_id),
|
"track":get_track(row.track_id),
|
||||||
@ -84,6 +87,7 @@ def scrobble_db_to_dict(row):
|
|||||||
|
|
||||||
def track_db_to_dict(row):
|
def track_db_to_dict(row):
|
||||||
return {
|
return {
|
||||||
|
"artists":get_artists_of_track(row.id),
|
||||||
"title":row.title,
|
"title":row.title,
|
||||||
"length":row.length
|
"length":row.length
|
||||||
}
|
}
|
||||||
@ -229,7 +233,6 @@ def get_scrobbles_of_artist(artist,since,to):
|
|||||||
)
|
)
|
||||||
result = conn.execute(op).all()
|
result = conn.execute(op).all()
|
||||||
|
|
||||||
print(result)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@ -244,19 +247,16 @@ def get_scrobbles_of_track(track,since,to):
|
|||||||
)
|
)
|
||||||
result = conn.execute(op).all()
|
result = conn.execute(op).all()
|
||||||
|
|
||||||
print(result)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_scrobbles(since,to):
|
def get_scrobbles(since,to):
|
||||||
print(since,to)
|
|
||||||
|
|
||||||
with engine.begin() as conn:
|
with engine.begin() as conn:
|
||||||
op = DB['scrobbles'].select().where(
|
op = DB['scrobbles'].select().where(
|
||||||
DB['scrobbles'].c.timestamp<=to,
|
DB['scrobbles'].c.timestamp<=to,
|
||||||
DB['scrobbles'].c.timestamp>=since,
|
DB['scrobbles'].c.timestamp>=since,
|
||||||
)
|
)
|
||||||
print(str(op))
|
|
||||||
result = conn.execute(op).all()
|
result = conn.execute(op).all()
|
||||||
|
|
||||||
result = [scrobble_db_to_dict(row) for row in result]
|
result = [scrobble_db_to_dict(row) for row in result]
|
||||||
@ -272,16 +272,7 @@ def get_track(id):
|
|||||||
trackinfo = result[0]
|
trackinfo = result[0]
|
||||||
|
|
||||||
|
|
||||||
with engine.begin() as conn:
|
|
||||||
op = DB['trackartists'].select().where(
|
|
||||||
DB['trackartists'].c.track_id==id
|
|
||||||
)
|
|
||||||
result = conn.execute(op).all()
|
|
||||||
|
|
||||||
artists = [get_artist(row.artist_id) for row in result]
|
|
||||||
|
|
||||||
result = track_db_to_dict(trackinfo)
|
result = track_db_to_dict(trackinfo)
|
||||||
result['artists'] = artists
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@ -295,6 +286,15 @@ def get_artist(id):
|
|||||||
artistinfo = result[0]
|
artistinfo = result[0]
|
||||||
return artist_db_to_dict(artistinfo)
|
return artist_db_to_dict(artistinfo)
|
||||||
|
|
||||||
|
def get_artists_of_track(track_id):
|
||||||
|
with engine.begin() as conn:
|
||||||
|
op = DB['trackartists'].select().where(
|
||||||
|
DB['trackartists'].c.track_id==track_id
|
||||||
|
)
|
||||||
|
result = conn.execute(op).all()
|
||||||
|
|
||||||
|
artists = [get_artist(row.artist_id) for row in result]
|
||||||
|
return artists
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
{%- if loop.index0 >= firstindex and loop.index0 < lastindex -%}
|
{%- if loop.index0 >= firstindex and loop.index0 < lastindex -%}
|
||||||
<tr>
|
<tr>
|
||||||
<td class='time'>{{ malojatime.timestamp_desc(s["time"],short=shortTimeDesc) }}</td>
|
<td class='time'>{{ malojatime.timestamp_desc(s["time"],short=shortTimeDesc) }}</td>
|
||||||
{{ entityrow.row(s) }}
|
{{ entityrow.row(s.track) }}
|
||||||
</tr>
|
</tr>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
{% elif filterkeys.get('artist') is not none %}
|
{% elif filterkeys.get('artist') is not none %}
|
||||||
{% set img = utilities.getArtistImage(filterkeys.artist,fast=True) %}
|
{% set img = utilities.getArtistImage(filterkeys.artist,fast=True) %}
|
||||||
{% elif scrobbles.__len__() > 0 %}
|
{% elif scrobbles.__len__() > 0 %}
|
||||||
{% set img = utilities.getTrackImage(artists=scrobbles[0].artists,title=scrobbles[0].title,fast=True) %}
|
{% set img = utilities.getTrackImage(artists=scrobbles[0].track.artists,title=scrobbles[0].track.title,fast=True) %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set img = "/favicon.png" %}
|
{% set img = "/favicon.png" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user