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,27 +432,45 @@
|
||||
.then( data => {
|
||||
try {
|
||||
const searchTerm = data.common.title
|
||||
? data.common.title + ' ' + data.common.artist
|
||||
: songDetails.filename.split( '.' )[ 0 ];
|
||||
? data.common.title + ( data.common.artist ? ' ' + data.common.artist : '' )
|
||||
: songDetails.filename.split( '.' )[ 0 ].replace( '_', ' ' );
|
||||
|
||||
console.debug( 'Searching for', searchTerm );
|
||||
|
||||
player.findSongOnAppleMusic( searchTerm )
|
||||
.then( d => {
|
||||
let url = d.data.results.songs.data[ 0 ].attributes.artwork.url;
|
||||
if ( d.data.results.songs ) {
|
||||
let url = d.data.results.songs.data[ 0 ].attributes.artwork.url;
|
||||
|
||||
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 ) );
|
||||
const song: Song = {
|
||||
'artist': d.data.results.songs.data[ 0 ].attributes.artistName,
|
||||
'title': d.data.results.songs.data[ 0 ].attributes.name,
|
||||
'duration': data.format.duration ?? ( d.data.results.songs.data[ 0 ].attributes.durationInMillis / 1000 ),
|
||||
'id': songDetails.url,
|
||||
'origin': 'disk',
|
||||
'cover': url
|
||||
};
|
||||
console.debug(
|
||||
'Result used for', searchTerm, 'is', d.data.results.songs.data[0]
|
||||
);
|
||||
|
||||
resolve( song );
|
||||
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 ) );
|
||||
const song: Song = {
|
||||
'artist': d.data.results.songs.data[ 0 ].attributes.artistName,
|
||||
'title': d.data.results.songs.data[ 0 ].attributes.name,
|
||||
'duration': data.format.duration ?? ( d.data.results.songs.data[ 0 ].attributes.durationInMillis / 1000 ),
|
||||
'id': songDetails.url,
|
||||
'origin': 'disk',
|
||||
'cover': url
|
||||
};
|
||||
|
||||
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 => {
|
||||
console.error( e );
|
||||
|
||||
@@ -38,7 +38,13 @@
|
||||
: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' : '' )"
|
||||
>
|
||||
<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 class="playing-symbols-wrapper">
|
||||
<div id="bar-1" class="playing-bar"></div>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div v-if="hasLoaded && !showCouldNotFindRoom" style="width: 100%">
|
||||
<div class="current-song-wrapper">
|
||||
<img
|
||||
v-if="playlist[ playingSong ]"
|
||||
v-if="playlist[ playingSong ] && playlist[ playingSong ].cover"
|
||||
id="current-image"
|
||||
:src="playlist[ playingSong ].cover"
|
||||
class="fancy-view-song-art"
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<div v-if="hasLoaded && !showCouldNotFindRoom" class="showcase-wrapper">
|
||||
<div class="current-song-wrapper">
|
||||
<img
|
||||
v-if="playlist[ playingSong ]"
|
||||
v-if="playlist[ playingSong ] && playlist[ playingSong ].cover"
|
||||
id="current-image"
|
||||
:src="playlist[ playingSong ].cover"
|
||||
class="fancy-view-song-art"
|
||||
@@ -52,7 +52,8 @@
|
||||
</div>
|
||||
<div class="song-list-wrapper">
|
||||
<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
|
||||
v-if="( playlist[ playingSong ] ? playlist[ playingSong ].id : '' ) === song.id && isPlaying"
|
||||
class="playing-symbols"
|
||||
@@ -97,7 +98,7 @@
|
||||
Song
|
||||
} from '@/scripts/song';
|
||||
import {
|
||||
computed, ref, type Ref
|
||||
type Ref, computed, ref
|
||||
} from 'vue';
|
||||
import bizualizer from '@/scripts/bizualizer';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user