Skip to content

Commit

Permalink
Fixed non-library songs not showing in Last.FM
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandakan committed Jun 23, 2024
1 parent c8fb97b commit 6fa818f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ With simplicity and design in mind, this app was made to overcome problems when

It packs a horizon of features including,

- Organize your songs, artists, albums, and playlists with ease.
- Create playlists that meet your needs.
- Sing along with song lyrics[^1].
- Support for synced lyrics.
- Keep your favorite songs and artists close to you.
- Read your favorite artist's biography.
- Personalized music shuffling[^2].(Upcoming)
- Change between Light and Dark themes with ease.
- A mini-player to help focus on what matters at the moment.
- Edit the metadata of your songs easily and conveniently [^3].
- Search through your library with the help of song filters.
- [x] Organize your songs, artists, albums, and playlists with ease.
- [x] Create playlists that meet your needs.
- [x] Sing along with song lyrics[^1].
- [x] Support for synced lyrics.
- [x] Keep your favorite songs and artists close to you.
- [x] Read your favorite artist's biography.
- [ ] Personalized music shuffling[^2].(Upcoming)
- [x] Change between Light and Dark themes with ease.
- [x] A mini-player to help focus on what matters at the moment.
- [x] Edit the metadata of your songs easily and conveniently [^3].
- [x] Search through your library with the help of song filters.

<br>

Expand Down
8 changes: 1 addition & 7 deletions src/main/core/sendAudioDataFromPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ const sendAudioDataFromPath = async (songPath: string): Promise<AudioPlayerData>
isBlacklisted: false
};

addToSongsOutsideLibraryData({
title: data.title,
songId: data.songId,
artworkPath: data.artworkPath,
duration: data.duration,
path: data.path
});
addToSongsOutsideLibraryData(data);

sendMessageToRenderer({
messageCode: 'PLAYBACK_FROM_UNKNOWN_SOURCE'
Expand Down
6 changes: 3 additions & 3 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,16 +580,16 @@ export async function revealSongInFileExplorer(songId: string) {
);
}

const songsOutsideLibraryData: SongOutsideLibraryData[] = [];
const songsOutsideLibraryData: AudioPlayerData[] = [];

export const getSongsOutsideLibraryData = () => songsOutsideLibraryData;

export const addToSongsOutsideLibraryData = (data: SongOutsideLibraryData) =>
export const addToSongsOutsideLibraryData = (data: AudioPlayerData) =>
songsOutsideLibraryData.push(data);

export const updateSongsOutsideLibraryData = (
songidOrPath: string,
data: SongOutsideLibraryData
data: AudioPlayerData
): void => {
for (let i = 0; i < songsOutsideLibraryData.length; i += 1) {
if (
Expand Down
19 changes: 16 additions & 3 deletions src/main/other/lastFm/sendNowPlayingSongDataToLastFM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { getSongsData, getUserData } from '../../filesystem';
import log from '../../log';
import { LastFMScrobblePostResponse, updateNowPlayingParams } from '../../../@types/last_fm_api';
import { checkIfConnectedToInternet } from '../../main';
import { checkIfConnectedToInternet, getSongsOutsideLibraryData } from '../../main';
import generateApiRequestBodyForLastFMPostRequests from './generateApiRequestBodyForLastFMPostRequests';
import getLastFmAuthData from './getLastFMAuthData';

Expand All @@ -16,7 +16,20 @@ const sendNowPlayingSongDataToLastFM = async (songId: string) => {

if (isScrobblingEnabled && isConnectedToInternet) {
const songs = getSongsData();
const song = songs.find((x) => x.songId === songId);
let song = songs.find((x) => x.songId === songId);

if (song === undefined) {
const songsOutsideLibrary = getSongsOutsideLibraryData();
const data = songsOutsideLibrary.find((x) => x.songId === songId);
if (data)
song = {
...data,
albumArtists: [],
trackNo: undefined,
isArtworkAvailable: !!data.artworkPath,
addedDate: Date.now()
};
}

if (song) {
const authData = getLastFmAuthData();
Expand All @@ -29,7 +42,7 @@ const sendNowPlayingSongDataToLastFM = async (songId: string) => {
artist: song.artists?.map((artist) => artist.name).join(', ') || '',
album: song.album?.name,
albumArtist: song?.albumArtists?.map((artist) => artist.name).join(', '),
trackNumber: song.trackNo,
trackNumber: song?.trackNo,
duration: Math.ceil(song.duration)
};

Expand Down

0 comments on commit 6fa818f

Please sign in to comment.