mirror of
https://github.com/janishutz/MusicPlayerV2.git
synced 2025-11-25 04:54:23 +00:00
Fixes for uncommon songs with that are not on apple music
This commit is contained in:
@@ -432,15 +432,19 @@
|
|||||||
.then( data => {
|
.then( data => {
|
||||||
try {
|
try {
|
||||||
const searchTerm = data.common.title
|
const searchTerm = data.common.title
|
||||||
? data.common.title + ' ' + data.common.artist
|
? data.common.title + ( data.common.artist ? ' ' + data.common.artist : '' )
|
||||||
: songDetails.filename.split( '.' )[ 0 ];
|
: songDetails.filename.split( '.' )[ 0 ].replace( '_', ' ' );
|
||||||
|
|
||||||
console.debug( 'Searching for', searchTerm );
|
|
||||||
|
|
||||||
player.findSongOnAppleMusic( searchTerm )
|
player.findSongOnAppleMusic( searchTerm )
|
||||||
.then( d => {
|
.then( d => {
|
||||||
|
if ( d.data.results.songs ) {
|
||||||
let url = d.data.results.songs.data[ 0 ].attributes.artwork.url;
|
let url = d.data.results.songs.data[ 0 ].attributes.artwork.url;
|
||||||
|
|
||||||
|
console.debug(
|
||||||
|
'Result used for', searchTerm, 'is', d.data.results.songs.data[0]
|
||||||
|
);
|
||||||
|
|
||||||
url = url.replace( '{w}', String( d.data.results.songs.data[ 0 ].attributes.artwork.width ) );
|
url = url.replace( '{w}', String( d.data.results.songs.data[ 0 ].attributes.artwork.width ) );
|
||||||
url = url.replace( '{h}', String( d.data.results.songs.data[ 0 ].attributes.artwork.height ) );
|
url = url.replace( '{h}', String( d.data.results.songs.data[ 0 ].attributes.artwork.height ) );
|
||||||
const song: Song = {
|
const song: Song = {
|
||||||
@@ -453,6 +457,20 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
resolve( song );
|
resolve( song );
|
||||||
|
} else {
|
||||||
|
const song: Song = {
|
||||||
|
'artist': data.common.artist ?? 'Unknown artist',
|
||||||
|
'title': data.common.title ?? 'Unknown song title',
|
||||||
|
'duration': data.format.duration ?? 1000,
|
||||||
|
'id': songDetails.url,
|
||||||
|
'origin': 'disk',
|
||||||
|
'cover': ''
|
||||||
|
};
|
||||||
|
|
||||||
|
console.warn( 'No results found for', searchTerm );
|
||||||
|
|
||||||
|
resolve( song );
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
.catch( e => {
|
.catch( e => {
|
||||||
console.error( e );
|
console.error( e );
|
||||||
|
|||||||
@@ -38,7 +38,13 @@
|
|||||||
:class="( song.id === ( $props.playlist ? $props.playlist [ $props.currentlyPlaying ?? 0 ].id : '' ) && isPlaying ? 'playing' : ' not-playing' )
|
:class="( song.id === ( $props.playlist ? $props.playlist [ $props.currentlyPlaying ?? 0 ].id : '' ) && isPlaying ? 'playing' : ' not-playing' )
|
||||||
+ ( ( !isPlaying && ( song.id === ( $props.playlist ? $props.playlist [ $props.currentlyPlaying ?? 0 ].id : '' ) ) ) ? ' active-song' : '' )"
|
+ ( ( !isPlaying && ( song.id === ( $props.playlist ? $props.playlist [ $props.currentlyPlaying ?? 0 ].id : '' ) ) ) ? ' active-song' : '' )"
|
||||||
>
|
>
|
||||||
<img :src="song.cover" alt="Song cover" class="song-cover">
|
<img
|
||||||
|
v-if="song.cover"
|
||||||
|
:src="song.cover"
|
||||||
|
alt="Song cover"
|
||||||
|
class="song-cover"
|
||||||
|
>
|
||||||
|
<span v-else class="material-symbols-outlined song-cover">music_note</span>
|
||||||
<div v-if="song.id === ( $props.playlist ? $props.playlist [ $props.currentlyPlaying ?? 0 ].id : '' ) && $props.isPlaying" class="playing-symbols">
|
<div v-if="song.id === ( $props.playlist ? $props.playlist [ $props.currentlyPlaying ?? 0 ].id : '' ) && $props.isPlaying" class="playing-symbols">
|
||||||
<div class="playing-symbols-wrapper">
|
<div class="playing-symbols-wrapper">
|
||||||
<div id="bar-1" class="playing-bar"></div>
|
<div id="bar-1" class="playing-bar"></div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<div v-if="hasLoaded && !showCouldNotFindRoom" style="width: 100%">
|
<div v-if="hasLoaded && !showCouldNotFindRoom" style="width: 100%">
|
||||||
<div class="current-song-wrapper">
|
<div class="current-song-wrapper">
|
||||||
<img
|
<img
|
||||||
v-if="playlist[ playingSong ]"
|
v-if="playlist[ playingSong ] && playlist[ playingSong ].cover"
|
||||||
id="current-image"
|
id="current-image"
|
||||||
:src="playlist[ playingSong ].cover"
|
:src="playlist[ playingSong ].cover"
|
||||||
class="fancy-view-song-art"
|
class="fancy-view-song-art"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<div v-if="hasLoaded && !showCouldNotFindRoom" class="showcase-wrapper">
|
<div v-if="hasLoaded && !showCouldNotFindRoom" class="showcase-wrapper">
|
||||||
<div class="current-song-wrapper">
|
<div class="current-song-wrapper">
|
||||||
<img
|
<img
|
||||||
v-if="playlist[ playingSong ]"
|
v-if="playlist[ playingSong ] && playlist[ playingSong ].cover"
|
||||||
id="current-image"
|
id="current-image"
|
||||||
:src="playlist[ playingSong ].cover"
|
:src="playlist[ playingSong ].cover"
|
||||||
class="fancy-view-song-art"
|
class="fancy-view-song-art"
|
||||||
@@ -52,7 +52,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="song-list-wrapper">
|
<div class="song-list-wrapper">
|
||||||
<div v-for="song in songQueue" :key="song.id" class="song-list">
|
<div v-for="song in songQueue" :key="song.id" class="song-list">
|
||||||
<img :src="song.cover" class="song-image">
|
<img v-if="song.cover" :src="song.cover" class="song-image">
|
||||||
|
<span v-else class="material-symbols-outlined song-cover">music_note</span>
|
||||||
<div
|
<div
|
||||||
v-if="( playlist[ playingSong ] ? playlist[ playingSong ].id : '' ) === song.id && isPlaying"
|
v-if="( playlist[ playingSong ] ? playlist[ playingSong ].id : '' ) === song.id && isPlaying"
|
||||||
class="playing-symbols"
|
class="playing-symbols"
|
||||||
@@ -97,7 +98,7 @@
|
|||||||
Song
|
Song
|
||||||
} from '@/scripts/song';
|
} from '@/scripts/song';
|
||||||
import {
|
import {
|
||||||
computed, ref, type Ref
|
type Ref, computed, ref
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import bizualizer from '@/scripts/bizualizer';
|
import bizualizer from '@/scripts/bizualizer';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user