mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Compare commits
1 Commits
v0.6.3
...
feature/ar
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b381b4ab1 |
@@ -48,7 +48,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rm -Rf build",
|
"clean": "rm -Rf build",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"dev": "BONOB_SONOS_SERVICE_NAME=bonobDev BONOB_SONOS_DEVICE_DISCOVERY=true BONOB_SONOS_AUTO_REGISTER=false nodemon ./src/app.ts",
|
"dev": "BONOB_SONOS_SERVICE_NAME=bonobDev BONOB_SONOS_DEVICE_DISCOVERY=true BONOB_SONOS_AUTO_REGISTER=true nodemon ./src/app.ts",
|
||||||
"register-dev": "ts-node ./src/register.ts http://$(hostname):4534",
|
"register-dev": "ts-node ./src/register.ts http://$(hostname):4534",
|
||||||
"test": "jest --testPathIgnorePatterns=build"
|
"test": "jest --testPathIgnorePatterns=build"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,6 +325,12 @@ function server(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get("/stream/artistRadio/:id", async (req, res) => {
|
||||||
|
const id = req.params["id"]!;
|
||||||
|
console.log(`----------> Streaming artist radio!! ${id}`)
|
||||||
|
res.status(404).send()
|
||||||
|
});
|
||||||
|
|
||||||
app.get("/:type/:id/art/size/:size", (req, res) => {
|
app.get("/:type/:id/art/size/:size", (req, res) => {
|
||||||
const authToken = accessTokens.authTokenFor(
|
const authToken = accessTokens.authTokenFor(
|
||||||
req.query[BONOB_ACCESS_TOKEN_HEADER] as string
|
req.query[BONOB_ACCESS_TOKEN_HEADER] as string
|
||||||
|
|||||||
55
src/smapi.ts
55
src/smapi.ts
@@ -333,7 +333,7 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
i8n: I8N
|
i8n: I8N
|
||||||
) {
|
) {
|
||||||
const sonosSoap = new SonosSoap(bonobUrl, linkCodes);
|
const sonosSoap = new SonosSoap(bonobUrl, linkCodes);
|
||||||
|
|
||||||
const urlWithToken = (accessToken: string) =>
|
const urlWithToken = (accessToken: string) =>
|
||||||
bonobUrl.append({
|
bonobUrl.append({
|
||||||
searchParams: {
|
searchParams: {
|
||||||
@@ -385,13 +385,30 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
) =>
|
) =>
|
||||||
auth(musicService, accessTokens, soapyHeaders?.credentials)
|
auth(musicService, accessTokens, soapyHeaders?.credentials)
|
||||||
.then(splitId(id))
|
.then(splitId(id))
|
||||||
.then(async ({ musicLibrary, accessToken, typeId }) =>
|
.then(async ({ musicLibrary, accessToken, type, typeId }) => {
|
||||||
musicLibrary.track(typeId!).then((it) => ({
|
console.log(`!!! getMediaMetadata->${id}`)
|
||||||
getMediaMetadataResult: track(
|
switch (type) {
|
||||||
urlWithToken(accessToken),
|
case "track": return musicLibrary.track(typeId!).then((it) => ({
|
||||||
it
|
getMediaMetadataResult: track(
|
||||||
),
|
urlWithToken(accessToken),
|
||||||
}))
|
it,
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
case "artistRadio": return {
|
||||||
|
getMediaMetadataResult: {
|
||||||
|
id,
|
||||||
|
itemType: "stream",
|
||||||
|
title: "Foobar100",
|
||||||
|
mimeType: 'audio/x-scpls',
|
||||||
|
// streamMetadata: {
|
||||||
|
// logo: "??"
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw `Unsupported search by:${id}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
),
|
),
|
||||||
search: async (
|
search: async (
|
||||||
{ id, term }: { id: string; term: string },
|
{ id, term }: { id: string; term: string },
|
||||||
@@ -439,7 +456,7 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
index,
|
index,
|
||||||
count,
|
count,
|
||||||
}: // recursive,
|
}: // recursive,
|
||||||
{ id: string; index: number; count: number; recursive: boolean },
|
{ id: string; index: number; count: number; recursive: boolean },
|
||||||
_,
|
_,
|
||||||
soapyHeaders: SoapyHeaders,
|
soapyHeaders: SoapyHeaders,
|
||||||
) =>
|
) =>
|
||||||
@@ -464,12 +481,18 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
relatedBrowse:
|
relatedBrowse:
|
||||||
artist.similarArtists.filter(it => it.inLibrary).length > 0
|
artist.similarArtists.filter(it => it.inLibrary).length > 0
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
id: `relatedArtists:${artist.id}`,
|
id: `relatedArtists:${artist.id}`,
|
||||||
type: "RELATED_ARTISTS",
|
type: "RELATED_ARTISTS",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
|
relatedPlay: {
|
||||||
|
id: `artistRadio:${artist.id}`,
|
||||||
|
itemType: "stream",
|
||||||
|
title: "Foobar radio",
|
||||||
|
canPlay: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -527,7 +550,7 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
index,
|
index,
|
||||||
count,
|
count,
|
||||||
}: // recursive,
|
}: // recursive,
|
||||||
{ id: string; index: number; count: number; recursive: boolean },
|
{ id: string; index: number; count: number; recursive: boolean },
|
||||||
_,
|
_,
|
||||||
soapyHeaders: SoapyHeaders,
|
soapyHeaders: SoapyHeaders,
|
||||||
{ headers }: Pick<Request, 'headers'>
|
{ headers }: Pick<Request, 'headers'>
|
||||||
@@ -538,7 +561,7 @@ function bindSmapiSoapServiceToExpress(
|
|||||||
const paging = { _index: index, _count: count };
|
const paging = { _index: index, _count: count };
|
||||||
const lang = i8n((headers["accept-language"] || "en-US") as LANG);
|
const lang = i8n((headers["accept-language"] || "en-US") as LANG);
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Fetching metadata type=${type}, typeId=${typeId}, lang=${lang}`
|
`Fetching metadata type=${type}, typeId=${typeId}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const albums = (q: AlbumQuery): Promise<GetMetadataResponse> =>
|
const albums = (q: AlbumQuery): Promise<GetMetadataResponse> =>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { URLBuilder } from "./url_builder";
|
|||||||
|
|
||||||
export const SONOS_LANG = ["en-US", "da-DK", "de-DE", "es-ES", "fr-FR", "it-IT", "ja-JP", "nb-NO", "nl-NL", "pt-BR", "sv-SE", "zh-CN"]
|
export const SONOS_LANG = ["en-US", "da-DK", "de-DE", "es-ES", "fr-FR", "it-IT", "ja-JP", "nb-NO", "nl-NL", "pt-BR", "sv-SE", "zh-CN"]
|
||||||
|
|
||||||
export const PRESENTATION_AND_STRINGS_VERSION = "19";
|
export const PRESENTATION_AND_STRINGS_VERSION = "20";
|
||||||
|
|
||||||
// NOTE: manifest requires https for the URL,
|
// NOTE: manifest requires https for the URL,
|
||||||
// otherwise you will get an error trying to register
|
// otherwise you will get an error trying to register
|
||||||
@@ -20,6 +20,7 @@ export type Capability =
|
|||||||
| "alFavorites"
|
| "alFavorites"
|
||||||
| "ucPlaylists"
|
| "ucPlaylists"
|
||||||
| "extendedMD"
|
| "extendedMD"
|
||||||
|
| "radioExtendedMD"
|
||||||
| "contextHeaders"
|
| "contextHeaders"
|
||||||
| "authorizationHeader"
|
| "authorizationHeader"
|
||||||
| "logging"
|
| "logging"
|
||||||
@@ -32,6 +33,7 @@ export const BONOB_CAPABILITIES: Capability[] = [
|
|||||||
"ucPlaylists",
|
"ucPlaylists",
|
||||||
"extendedMD",
|
"extendedMD",
|
||||||
"logging",
|
"logging",
|
||||||
|
"radioExtendedMD"
|
||||||
];
|
];
|
||||||
|
|
||||||
export type Device = {
|
export type Device = {
|
||||||
|
|||||||
Reference in New Issue
Block a user