parent
1acfa93f1a
commit
0ae53b023c
1 changed files with 29 additions and 1 deletions
|
@ -54,11 +54,37 @@ import { jfType } from '/@/renderer/api/jellyfin/jellyfin-types';
|
||||||
import packageJson from '../../../../package.json';
|
import packageJson from '../../../../package.json';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { JFSongListSort, JFSortOrder } from '/@/renderer/api/jellyfin.types';
|
import { JFSongListSort, JFSortOrder } from '/@/renderer/api/jellyfin.types';
|
||||||
|
import isElectron from 'is-electron';
|
||||||
|
|
||||||
const formatCommaDelimitedString = (value: string[]) => {
|
const formatCommaDelimitedString = (value: string[]) => {
|
||||||
return value.join(',');
|
return value.join(',');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getHostname(): string {
|
||||||
|
if (isElectron()) {
|
||||||
|
return 'Desktop Client';
|
||||||
|
}
|
||||||
|
const agent = navigator.userAgent;
|
||||||
|
switch (true) {
|
||||||
|
case agent.toLowerCase().indexOf('edge') > -1:
|
||||||
|
return 'Microsoft Edge';
|
||||||
|
case agent.toLowerCase().indexOf('edg/') > -1:
|
||||||
|
return 'Edge Chromium'; // Match also / to avoid matching for the older Edge
|
||||||
|
case agent.toLowerCase().indexOf('opr') > -1:
|
||||||
|
return 'Opera';
|
||||||
|
case agent.toLowerCase().indexOf('chrome') > -1:
|
||||||
|
return 'Chrome';
|
||||||
|
case agent.toLowerCase().indexOf('trident') > -1:
|
||||||
|
return 'Internet Explorer';
|
||||||
|
case agent.toLowerCase().indexOf('firefox') > -1:
|
||||||
|
return 'Firefox';
|
||||||
|
case agent.toLowerCase().indexOf('safari') > -1:
|
||||||
|
return 'Safari';
|
||||||
|
default:
|
||||||
|
return 'PC';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const authenticate = async (
|
const authenticate = async (
|
||||||
url: string,
|
url: string,
|
||||||
body: {
|
body: {
|
||||||
|
@ -74,7 +100,9 @@ const authenticate = async (
|
||||||
Username: body.username,
|
Username: body.username,
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'x-emby-authorization': `MediaBrowser Client="Feishin", Device="PC", DeviceId="Feishin", Version="${packageJson.version}"`,
|
'x-emby-authorization': `MediaBrowser Client="Feishin", Device="${getHostname()}", DeviceId="Feishin", Version="${
|
||||||
|
packageJson.version
|
||||||
|
}"`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Reference in a new issue