started album squared thing
This commit is contained in:
1 parent
3fefdcc7d8
commit
75260fac0e
9 files changed
+169
-1
No files matched your search
+55
-1
@@ -2,6 +2,7 @@ import glob
|
||||
import configparser
|
||||
import random
|
||||
|
||||
import requests
|
||||
import flask
|
||||
import waitress
|
||||
import markdown
|
||||
@@ -19,6 +20,9 @@ STATUS_FILE = config['STATUS']['STATUS_FILE']
|
||||
PORT = int(config['NETWORK']['PORT'])
|
||||
DEV = int(config['NETWORK']['DEV'])
|
||||
|
||||
MUSIC_API_TOKEN = config['AUTH']['MUSIC_API_TOKEN']
|
||||
MUSIC_API_URL = config['NETWORK']['MUSIC_API_URL']
|
||||
|
||||
def get_posts(category_filter : str | None = None) -> list[Post]:
|
||||
post_files = glob.glob(f'{POSTS_FOLDER}/*')
|
||||
try:
|
||||
@@ -105,7 +109,25 @@ def music():
|
||||
# Get status
|
||||
status = get_status()
|
||||
|
||||
return flask.render_template('music.html', posts=post_bodies, status=status)
|
||||
# Get top albums
|
||||
r = requests.get(
|
||||
MUSIC_API_URL +'/top/albums',
|
||||
headers={
|
||||
'token' : MUSIC_API_TOKEN,
|
||||
'user' : '1',
|
||||
'limit' : '9'
|
||||
})
|
||||
|
||||
top_albums = r.json()['top']
|
||||
for album_index in range(0, len(top_albums)):
|
||||
album = top_albums[album_index]
|
||||
|
||||
time = int(album['listen_time'])
|
||||
hours = round(time/1000/60/60, 1)
|
||||
|
||||
top_albums[album_index]['listen_time'] = hours
|
||||
|
||||
return flask.render_template('music.html', posts=post_bodies, status=status, top_albums=top_albums)
|
||||
|
||||
# Motion Pictures Page
|
||||
@app.route('/motion-pictures/')
|
||||
@@ -148,6 +170,38 @@ def about():
|
||||
|
||||
return flask.render_template('about.html', status=status)
|
||||
|
||||
# MISC
|
||||
|
||||
@app.route('/albumsquare/<user_id>/<int:rows>')
|
||||
def album_square(user_id, rows : int):
|
||||
|
||||
limit = rows ** 2
|
||||
|
||||
res = 100/(rows+2)
|
||||
|
||||
# Get top albums
|
||||
r = requests.get(
|
||||
MUSIC_API_URL +'/top/albums',
|
||||
headers={
|
||||
'token' : MUSIC_API_TOKEN,
|
||||
'user' : user_id,
|
||||
'limit' : str(limit)
|
||||
})
|
||||
|
||||
top_albums = r.json()['top']
|
||||
for album_index in range(0, len(top_albums)):
|
||||
album = top_albums[album_index]
|
||||
|
||||
time = int(album['listen_time'])
|
||||
hours = round(time/1000/60/60, 1)
|
||||
|
||||
top_albums[album_index]['listen_time'] = hours
|
||||
|
||||
|
||||
return flask.render_template('album_square.html', top_albums=top_albums, limit=rows, res=res)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if DEV:
|
||||
app.run(port=PORT)
|
||||
|
||||
Reference in new issue
Block a user