mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
fix merge conflict
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
"""
|
"""
|
||||||
Contains all the playlist routes.
|
Contains all the playlist routes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask import Blueprint, request
|
from app import api
|
||||||
from app import instances, api
|
|
||||||
from app.lib import playlistlib
|
|
||||||
from app import models
|
|
||||||
from app import exceptions
|
from app import exceptions
|
||||||
|
from app import instances
|
||||||
|
from app import models
|
||||||
from app import serializer
|
from app import serializer
|
||||||
|
from app.lib import playlistlib
|
||||||
|
from flask import Blueprint
|
||||||
|
from flask import request
|
||||||
|
|
||||||
playlist_bp = Blueprint("playlist", __name__, url_prefix="/")
|
playlist_bp = Blueprint("playlist", __name__, url_prefix="/")
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"""
|
"""
|
||||||
This file contains the Playlists class for interacting with the playlist documents in MongoDB.
|
This file contains the Playlists class for interacting with the playlist documents in MongoDB.
|
||||||
"""
|
"""
|
||||||
|
from app import db
|
||||||
from app import db, models
|
from app import models
|
||||||
from bson import ObjectId
|
from bson import ObjectId
|
||||||
|
|
||||||
convert_many = db.convert_many
|
convert_many = db.convert_many
|
||||||
@@ -23,8 +23,12 @@ class Playlists(db.Mongo):
|
|||||||
Inserts a new playlist object into the database.
|
Inserts a new playlist object into the database.
|
||||||
"""
|
"""
|
||||||
return self.collection.update_one(
|
return self.collection.update_one(
|
||||||
{"name": playlist["name"]},
|
{
|
||||||
{"$set": playlist},
|
"name": playlist["name"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$set": playlist
|
||||||
|
},
|
||||||
upsert=True,
|
upsert=True,
|
||||||
).upserted_id
|
).upserted_id
|
||||||
|
|
||||||
@@ -49,7 +53,9 @@ class Playlists(db.Mongo):
|
|||||||
|
|
||||||
return self.collection.update_one(
|
return self.collection.update_one(
|
||||||
{"_id": ObjectId(playlistid)},
|
{"_id": ObjectId(playlistid)},
|
||||||
{"$push": {"pre_tracks": track}},
|
{"$push": {
|
||||||
|
"pre_tracks": track
|
||||||
|
}},
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_playlist_by_name(self, name: str) -> dict:
|
def get_playlist_by_name(self, name: str) -> dict:
|
||||||
@@ -66,4 +72,4 @@ class Playlists(db.Mongo):
|
|||||||
return self.collection.update_one(
|
return self.collection.update_one(
|
||||||
{"_id": ObjectId(playlistid)},
|
{"_id": ObjectId(playlistid)},
|
||||||
{"$set": playlist},
|
{"$set": playlist},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,12 +5,17 @@ This library contains all the functions related to playlists.
|
|||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from PIL import Image, ImageSequence
|
|
||||||
|
from app import api
|
||||||
|
from app import exceptions
|
||||||
|
from app import instances
|
||||||
|
from app import models
|
||||||
|
from app import settings
|
||||||
|
from app.lib import trackslib
|
||||||
|
from PIL import Image
|
||||||
|
from PIL import ImageSequence
|
||||||
from progress.bar import Bar
|
from progress.bar import Bar
|
||||||
from werkzeug import datastructures
|
from werkzeug import datastructures
|
||||||
from app import api, instances, models, exceptions, settings
|
|
||||||
|
|
||||||
from app.lib import trackslib
|
|
||||||
|
|
||||||
TrackExistsInPlaylist = exceptions.TrackExistsInPlaylist
|
TrackExistsInPlaylist = exceptions.TrackExistsInPlaylist
|
||||||
|
|
||||||
@@ -31,7 +36,8 @@ def add_track(playlistid: str, trackid: str):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
playlist.add_track(track)
|
playlist.add_track(track)
|
||||||
instances.playlist_instance.add_track_to_playlist(playlistid, track)
|
instances.playlist_instance.add_track_to_playlist(
|
||||||
|
playlistid, track)
|
||||||
return
|
return
|
||||||
except TrackExistsInPlaylist as e:
|
except TrackExistsInPlaylist as e:
|
||||||
return {"error": str(e)}, 409
|
return {"error": str(e)}, 409
|
||||||
@@ -63,7 +69,8 @@ def save_p_image(file: datastructures.FileStorage, pid: str):
|
|||||||
"""
|
"""
|
||||||
img = Image.open(file)
|
img = Image.open(file)
|
||||||
|
|
||||||
random_str = "".join(random.choices(string.ascii_letters + string.digits, k=5))
|
random_str = "".join(
|
||||||
|
random.choices(string.ascii_letters + string.digits, k=5))
|
||||||
|
|
||||||
img_path = pid + str(random_str) + ".webp"
|
img_path = pid + str(random_str) + ".webp"
|
||||||
full_path = os.path.join(settings.APP_DIR, "images", "playlists", img_path)
|
full_path = os.path.join(settings.APP_DIR, "images", "playlists", img_path)
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
Contains all the models for objects generation and typing.
|
Contains all the models for objects generation and typing.
|
||||||
"""
|
"""
|
||||||
|
from dataclasses import dataclass
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import field
|
||||||
|
from datetime import date
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from app import api
|
from app import api
|
||||||
from app import settings
|
from app import settings
|
||||||
from app.exceptions import TrackExistsInPlaylist
|
from app.exceptions import TrackExistsInPlaylist
|
||||||
@@ -71,11 +73,9 @@ class Album:
|
|||||||
|
|
||||||
def get_p_track(ptrack):
|
def get_p_track(ptrack):
|
||||||
for track in api.TRACKS:
|
for track in api.TRACKS:
|
||||||
if (
|
if (track.title == ptrack["title"]
|
||||||
track.title == ptrack["title"]
|
and track.artists == ptrack["artists"]
|
||||||
and track.artists == ptrack["artists"]
|
and ptrack["album"] == track.album):
|
||||||
and ptrack["album"] == track.album
|
|
||||||
):
|
|
||||||
return track
|
return track
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ HOME_DIR = os.path.expanduser("~")
|
|||||||
APP_DIR = os.path.join(HOME_DIR, CONFIG_FOLDER)
|
APP_DIR = os.path.join(HOME_DIR, CONFIG_FOLDER)
|
||||||
THUMBS_PATH = os.path.join(APP_DIR, "images", "thumbnails")
|
THUMBS_PATH = os.path.join(APP_DIR, "images", "thumbnails")
|
||||||
|
|
||||||
|
|
||||||
# URL
|
# URL
|
||||||
IMG_BASE_URI = "http://127.0.0.1:8900/images/"
|
IMG_BASE_URI = "http://127.0.0.1:8900/images/"
|
||||||
IMG_ARTIST_URI = IMG_BASE_URI + "artists/"
|
IMG_ARTIST_URI = IMG_BASE_URI + "artists/"
|
||||||
IMG_THUMB_URI = IMG_BASE_URI + "thumbnails/"
|
IMG_THUMB_URI = IMG_BASE_URI + "thumbnails/"
|
||||||
IMG_PLAYLIST_URI = IMG_BASE_URI + "playlists/"
|
IMG_PLAYLIST_URI = IMG_BASE_URI + "playlists/"
|
||||||
|
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
DEFAULT_ARTIST_IMG = IMG_ARTIST_URI + "0.webp"
|
DEFAULT_ARTIST_IMG = IMG_ARTIST_URI + "0.webp"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user