mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
add the albumhash prop to the fallback track object
- plus other tiny changes
This commit is contained in:
committed by
Mungai Geoffrey
parent
6fbf179f34
commit
40fcbfd576
@@ -17,14 +17,18 @@ def send_track_file(trackid):
|
|||||||
Returns an audio file that matches the passed id to the client.
|
Returns an audio file that matches the passed id to the client.
|
||||||
"""
|
"""
|
||||||
track = instances.tracks_instance.get_track_by_id(trackid)
|
track = instances.tracks_instance.get_track_by_id(trackid)
|
||||||
|
msg = {"msg": "File Not Found"}
|
||||||
|
|
||||||
if track is None:
|
if track is None:
|
||||||
return "File not found", 404
|
return msg, 404
|
||||||
|
|
||||||
track = models.Track(track)
|
track = models.Track(track)
|
||||||
type = track.filepath.split(".")[-1]
|
type = track.filepath.split(".")[-1]
|
||||||
|
|
||||||
return send_file(track.filepath, mimetype=f"audio/{type}")
|
try:
|
||||||
|
return send_file(track.filepath, mimetype=f"audio/{type}")
|
||||||
|
except FileNotFoundError:
|
||||||
|
return msg, 404
|
||||||
|
|
||||||
|
|
||||||
@track_bp.route("/sample")
|
@track_bp.route("/sample")
|
||||||
|
|||||||
+10
-8
@@ -79,7 +79,6 @@ class getArtistImage:
|
|||||||
|
|
||||||
|
|
||||||
class useImageDownloader:
|
class useImageDownloader:
|
||||||
|
|
||||||
def __init__(self, url: str, dest: str) -> None:
|
def __init__(self, url: str, dest: str) -> None:
|
||||||
self.url = url
|
self.url = url
|
||||||
self.dest = dest
|
self.dest = dest
|
||||||
@@ -96,7 +95,6 @@ class useImageDownloader:
|
|||||||
|
|
||||||
|
|
||||||
class CheckArtistImages:
|
class CheckArtistImages:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.artists: list[str] = []
|
self.artists: list[str] = []
|
||||||
print("Checking for artist images")
|
print("Checking for artist images")
|
||||||
@@ -121,8 +119,12 @@ class CheckArtistImages:
|
|||||||
:param artistname: The artist name
|
:param artistname: The artist name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
img_path = (settings.APP_DIR + "/images/artists/" +
|
img_path = (
|
||||||
helpers.create_safe_name(artistname) + ".webp")
|
settings.APP_DIR
|
||||||
|
+ "/images/artists/"
|
||||||
|
+ helpers.create_safe_name(artistname)
|
||||||
|
+ ".webp"
|
||||||
|
)
|
||||||
|
|
||||||
if cls.check_if_exists(img_path):
|
if cls.check_if_exists(img_path):
|
||||||
return "exists"
|
return "exists"
|
||||||
@@ -139,7 +141,7 @@ class CheckArtistImages:
|
|||||||
|
|
||||||
with ThreadPoolExecutor() as pool:
|
with ThreadPoolExecutor() as pool:
|
||||||
iter = pool.map(self.download_image, self.artists)
|
iter = pool.map(self.download_image, self.artists)
|
||||||
[print(i) for i in iter]
|
[i for i in iter]
|
||||||
|
|
||||||
print("Done fetching images")
|
print("Done fetching images")
|
||||||
|
|
||||||
@@ -149,7 +151,8 @@ def fetch_album_bio(title: str, albumartist: str) -> str | None:
|
|||||||
Returns the album bio for a given album.
|
Returns the album bio for a given album.
|
||||||
"""
|
"""
|
||||||
last_fm_url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key={}&artist={}&album={}&format=json".format(
|
last_fm_url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key={}&artist={}&album={}&format=json".format(
|
||||||
settings.LAST_FM_API_KEY, albumartist, title)
|
settings.LAST_FM_API_KEY, albumartist, title
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(last_fm_url)
|
response = requests.get(last_fm_url)
|
||||||
@@ -158,8 +161,7 @@ def fetch_album_bio(title: str, albumartist: str) -> str | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bio = data["album"]["wiki"]["summary"].split(
|
bio = data["album"]["wiki"]["summary"].split('<a href="https://www.last.fm/')[0]
|
||||||
'<a href="https://www.last.fm/')[0]
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
bio = None
|
bio = None
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,3 @@ class Handler(PatternMatchingEventHandler):
|
|||||||
|
|
||||||
|
|
||||||
watch = OnMyWatch()
|
watch = OnMyWatch()
|
||||||
|
|
||||||
# TODO
|
|
||||||
# When removing a track, check if there are other tracks in the same album,
|
|
||||||
# if it was the last one, remove the album.
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function showDropdown(e: any) {
|
|||||||
.p-header {
|
.p-header {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
height: 16rem;
|
height: 17rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
border-radius: 0.75rem;
|
border-radius: 0.75rem;
|
||||||
color: $white;
|
color: $white;
|
||||||
|
|||||||
@@ -2,56 +2,12 @@ import { Track, AlbumInfo, Artist } from "./../interfaces";
|
|||||||
import { ref } from "@vue/reactivity";
|
import { ref } from "@vue/reactivity";
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
|
|
||||||
const search_query = ref("");
|
|
||||||
|
|
||||||
const queue = ref(
|
|
||||||
Array<Track>({
|
|
||||||
title: "Nothing played yet",
|
|
||||||
artists: ["... blah blah blah"],
|
|
||||||
image: "http://127.0.0.1:8900/images/thumbnails/4.webp",
|
|
||||||
trackid: "",
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const folder_song_list = ref([]);
|
|
||||||
const folder_list = ref([]);
|
|
||||||
|
|
||||||
const current = ref(<Track>{
|
|
||||||
title: "Nothing played yet",
|
|
||||||
artists: ["... blah blah blah"],
|
|
||||||
image: "http://127.0.0.1:8900/images/thumbnails/4.webp",
|
|
||||||
trackid: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const prev = ref(<Track>{
|
|
||||||
title: "Nothing played yet",
|
|
||||||
artists: ["... blah blah blah"],
|
|
||||||
image: "http://127.0.0.1:8900/images/thumbnails/4.webp",
|
|
||||||
trackid: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const album = reactive({
|
|
||||||
tracklist: Array<Track>(),
|
|
||||||
info: <AlbumInfo>{},
|
|
||||||
artists: Array<Artist>(),
|
|
||||||
bio: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const is_playing = ref(false);
|
|
||||||
const settings = reactive({
|
const settings = reactive({
|
||||||
uri: "http://127.0.0.1:9876",
|
uri: "http://127.0.0.1:9876",
|
||||||
});
|
});
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
search_query,
|
|
||||||
queue,
|
|
||||||
folder_song_list,
|
|
||||||
folder_list,
|
|
||||||
current,
|
|
||||||
prev,
|
|
||||||
loading,
|
loading,
|
||||||
is_playing,
|
|
||||||
album,
|
|
||||||
settings,
|
settings,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ function readCurrent(): number {
|
|||||||
|
|
||||||
const defaultTrack = <Track>{
|
const defaultTrack = <Track>{
|
||||||
title: "Nothing played yet",
|
title: "Nothing played yet",
|
||||||
|
albumhash: " ",
|
||||||
artists: ["Alice"],
|
artists: ["Alice"],
|
||||||
trackid: "",
|
trackid: "",
|
||||||
image: "",
|
image: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user