mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Awaiting responses in setPlayedSeconds (#58)
This commit is contained in:
25
src/smapi.ts
25
src/smapi.ts
@@ -265,7 +265,8 @@ export const defaultArtistArtURI = (
|
|||||||
artist: ArtistSummary
|
artist: ArtistSummary
|
||||||
) => bonobUrl.append({ pathname: `/art/artist:${artist.id}/size/180` });
|
) => bonobUrl.append({ pathname: `/art/artist:${artist.id}/size/180` });
|
||||||
|
|
||||||
export const sonosifyMimeType = (mimeType: string) => mimeType == "audio/x-flac" ? "audio/flac" : mimeType;
|
export const sonosifyMimeType = (mimeType: string) =>
|
||||||
|
mimeType == "audio/x-flac" ? "audio/flac" : mimeType;
|
||||||
|
|
||||||
export const album = (bonobUrl: URLBuilder, album: AlbumSummary) => ({
|
export const album = (bonobUrl: URLBuilder, album: AlbumSummary) => ({
|
||||||
itemType: "album",
|
itemType: "album",
|
||||||
@@ -509,7 +510,7 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
return musicLibrary.track(typeId).then((it) => ({
|
return musicLibrary.track(typeId).then((it) => ({
|
||||||
getExtendedMetadataResult: {
|
getExtendedMetadataResult: {
|
||||||
mediaMetadata: {
|
mediaMetadata: {
|
||||||
...track(urlWithToken(accessToken), it)
|
...track(urlWithToken(accessToken), it),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
@@ -887,21 +888,29 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
.then(({ musicLibrary, type, typeId }) => {
|
.then(({ musicLibrary, type, typeId }) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "track":
|
case "track":
|
||||||
musicLibrary.track(typeId).then(({ duration }) => {
|
return musicLibrary
|
||||||
if(+seconds > 0) {
|
.track(typeId)
|
||||||
musicLibrary.nowPlaying(typeId);
|
.then(({ duration }) => {
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
(duration < 30 && +seconds >= 10) ||
|
(duration < 30 && +seconds >= 10) ||
|
||||||
(duration >= 30 && +seconds >= 30)
|
(duration >= 30 && +seconds >= 30)
|
||||||
) {
|
) {
|
||||||
musicLibrary.scrobble(typeId);
|
return musicLibrary.scrobble(typeId);
|
||||||
|
} else {
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
if (+seconds > 0) {
|
||||||
|
return musicLibrary.nowPlaying(typeId);
|
||||||
|
} else {
|
||||||
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.info("Unsupported scrobble", { id, seconds });
|
logger.info("Unsupported scrobble", { id, seconds });
|
||||||
break;
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((_) => ({
|
.then((_) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user