mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-10 14:22:46 +02:00
add initial files
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
const getJellyfinImageUrl = (baseUrl: string, item: any, size?: number) => {
|
||||
return (
|
||||
`${baseUrl}/Items` +
|
||||
`/${item.Id}` +
|
||||
`/Images/Primary${
|
||||
size ? `?width=${size}&height=${size}` : '?height=350'
|
||||
}&quality=90`
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Song } from 'renderer/api/types';
|
||||
// import { ServerFolderAuth } from 'renderer/features/servers';
|
||||
|
||||
export const getJellyfinStreamUrl = (
|
||||
auth: any,
|
||||
song: Song,
|
||||
deviceId: string
|
||||
) => {
|
||||
return (
|
||||
`${auth.url}/audio` +
|
||||
`/${song.remoteId}/universal` +
|
||||
`?userId=${auth.userId}` +
|
||||
`&deviceId=sonixd_${deviceId}` +
|
||||
`&audioCodec=aac` +
|
||||
`&api_key=${auth.token}` +
|
||||
`&playSessionId=${deviceId}` +
|
||||
`&container=opus,mp3,aac,m4a,m4b,flac,wav,ogg` +
|
||||
`&transcodingContainer=ts` +
|
||||
`&transcodingProtocol=hls`
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import md5 from 'md5';
|
||||
import { ServerFolderAuth } from 'types';
|
||||
|
||||
export const getServerFolderAuth = (
|
||||
serverUrl: string,
|
||||
serverFolderId: number
|
||||
) => {
|
||||
const storedServersKey = `servers_${md5(serverUrl)}`;
|
||||
const serversFromLocalStorage = localStorage.getItem(storedServersKey);
|
||||
|
||||
if (serversFromLocalStorage) {
|
||||
const existingServers: ServerFolderAuth[] = JSON.parse(
|
||||
serversFromLocalStorage
|
||||
);
|
||||
|
||||
const server = existingServers.find((s) => s.id === serverFolderId);
|
||||
return server;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Song } from 'renderer/api/types';
|
||||
// import { ServerFolderAuth } from 'renderer/features/servers';
|
||||
|
||||
export const getSubsonicStreamUrl = (
|
||||
auth: any,
|
||||
song: Song,
|
||||
deviceId: string
|
||||
) => {
|
||||
return (
|
||||
`${auth.url}/rest/stream.view` +
|
||||
`?id=${song.remoteId}` +
|
||||
`&${auth.token}` +
|
||||
`&v=1.13.0` +
|
||||
`&c=sonixd_${deviceId}`
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
export * from './randomString';
|
||||
export * from './normalizeServerUrl';
|
||||
export * from './getJellyfinStreamUrl';
|
||||
export * from './getSubsonicStreamUrl';
|
||||
export * from './getServerFolderAuth';
|
||||
export * from './setLocalStorageSettings';
|
||||
@@ -0,0 +1,4 @@
|
||||
export const normalizeServerUrl = (url: string) => {
|
||||
// Remove trailing slash
|
||||
return url.endsWith('/') ? url.slice(0, -1) : url;
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
export const randomString = () => {
|
||||
const charSet =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let string = '';
|
||||
for (let i = 0; i < 12; i += 1) {
|
||||
const randomPoz = Math.floor(Math.random() * charSet.length);
|
||||
string += charSet.substring(randomPoz, randomPoz + 1);
|
||||
}
|
||||
return string;
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
export const setLocalStorageSettings = (type: 'player', object: any) => {
|
||||
const settings = JSON.parse(localStorage.getItem('settings') || '{}');
|
||||
|
||||
const newSettings = {
|
||||
...settings,
|
||||
[type]: { ...object },
|
||||
};
|
||||
|
||||
localStorage.setItem('settings', JSON.stringify(newSettings));
|
||||
};
|
||||
Reference in New Issue
Block a user