diff --git a/package.json b/package.json index 5f276402..14d6259b 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,9 @@ "lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src" }, "dependencies": { - "axios": "^0.26.0", + "axios": "^0.26.1", "mitt": "^3.0.0", + "node-vibrant": "^3.2.1-alpha.1", "pinia": "^2.0.11", "register-service-worker": "^1.7.1", "sass": "^1.49.0", diff --git a/server/app/__init__.py b/server/app/__init__.py index a1331bc6..b74f967d 100644 --- a/server/app/__init__.py +++ b/server/app/__init__.py @@ -1,7 +1,6 @@ from flask import Flask -from flask_cors import CORS - from flask_caching import Cache +from flask_cors import CORS config = {"CACHE_TYPE": "SimpleCache", "CACHE_DEFAULT_TIMEOUT": 300} @@ -19,7 +18,7 @@ def create_app(): cache.init_app(app) with app.app_context(): - from app.api import artist, track, search, folder, album, playlist + from app.api import album, artist, folder, playlist, search, track app.register_blueprint(album.album_bp, url_prefix="/") app.register_blueprint(artist.artist_bp, url_prefix="/") @@ -28,5 +27,4 @@ def create_app(): app.register_blueprint(folder.folder_bp, url_prefix="/") app.register_blueprint(playlist.playlist_bp, url_prefix="/") - return app diff --git a/server/app/api/album.py b/server/app/api/album.py index abc4d063..67f60c4b 100644 --- a/server/app/api/album.py +++ b/server/app/api/album.py @@ -1,12 +1,13 @@ """ Contains all the album routes. """ - -from flask import Blueprint, request from app import api -from app import helpers, cache from app import functions -from app.lib import albumslib, trackslib +from app import helpers +from app.lib import albumslib +from app.lib import trackslib +from flask import Blueprint +from flask import request album_bp = Blueprint("album", __name__, url_prefix="") diff --git a/server/app/lib/playlistlib.py b/server/app/lib/playlistlib.py index bbc8b7b1..90fa81bf 100644 --- a/server/app/lib/playlistlib.py +++ b/server/app/lib/playlistlib.py @@ -4,6 +4,7 @@ This library contains all the functions related to playlists. import os import random import string +from datetime import datetime from app import api from app import exceptions @@ -55,6 +56,7 @@ def create_all_playlists(): playlists = instances.playlist_instance.get_all_playlists() _bar = Bar("Creating playlists", max=len(playlists)) + for playlist in playlists: api.PLAYLISTS.append(models.Playlist(playlist)) @@ -132,3 +134,7 @@ def validate_images(): for image in os.listdir(p_path): if image not in images: os.remove(os.path.join(p_path, image)) + + +def create_new_date(): + return datetime.now() diff --git a/server/app/serializer.py b/server/app/serializer.py index 2e3bf78e..b0e5d102 100644 --- a/server/app/serializer.py +++ b/server/app/serializer.py @@ -4,16 +4,17 @@ from datetime import datetime from app import models -def date_string_to_time_passed(dstring: str) -> str: +def date_string_to_time_passed(prev_date: str) -> str: """ Converts a date string to time passed. eg. 2 minutes ago, 1 hour ago, yesterday, 2 days ago, 2 weeks ago, etc. """ now = datetime.now() - then = datetime.strptime(dstring, "%Y-%m-%d %H:%M:%S") + then = datetime.strptime(prev_date, "%Y-%m-%d %H:%M:%S") diff = now - then days = diff.days + print(days) if days < 0: return "in the future" @@ -32,22 +33,19 @@ def date_string_to_time_passed(dstring: str) -> str: elif days == 1: return "yesterday" elif days < 7: - if days == 1: - return "1 day ago" - return str(days) + " days ago" elif days < 30: - if days == 7: + if days < 14: return "1 week ago" return str(days // 7) + " weeks ago" elif days < 365: - if days == 30: + if days < 60: return "1 month ago" return str(days // 30) + " months ago" elif days > 365: - if days == 365: + if days < 730: return "1 year ago" return str(days // 365) + " years ago" diff --git a/server/start.sh b/server/start.sh index a509bcc8..5cceeae4 100755 --- a/server/start.sh +++ b/server/start.sh @@ -1,9 +1,8 @@ +# ppath=$(poetry run which python) -ppath=$(poetry run which python) - -$ppath manage.py - +# $ppath manage.py #python manage.py +gpath=$(poetry run which gunicorn) -# gunicorn -b 0.0.0.0:9876 --workers=4 "wsgi:create_app()" --log-level=debug +"$gpath" -b 0.0.0.0:9876 -w 1 --threads=4 "manage:create_app()" #--log-level=debug diff --git a/src/App.vue b/src/App.vue index aa01e0f6..2ab5990a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,9 +9,9 @@ >
-