diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4e5e14b8738..f73bfe3d4e1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -93,6 +93,7 @@ - [Connor Smith](https://github.com/ConnorS1110) - [iFraan](https://github.com/iFraan) - [Ali](https://github.com/bu3alwa) +- [K. Kyle Puchkov](https://github.com/kepper104) ## Emby Contributors diff --git a/src/components/apphost.js b/src/components/apphost.js index b92bb6faa08..984c3a77bf6 100644 --- a/src/components/apphost.js +++ b/src/components/apphost.js @@ -8,6 +8,20 @@ import profileBuilder from '../scripts/browserDeviceProfile'; const appName = 'Jellyfin Web'; +const BrowserName = { + tizen: 'Samsung Smart TV', + web0s: 'LG Smart TV', + operaTv: 'Opera TV', + xboxOne: 'Xbox One', + ps4: 'Sony PS4', + chrome: 'Chrome', + edgeChromium: 'Edge Chromium', + edge: 'Edge', + firefox: 'Firefox', + opera: 'Opera', + safari: 'Safari' +}; + function getBaseProfileOptions(item) { const disableHlsVideoAudioCodecs = []; @@ -132,42 +146,26 @@ function getDeviceId() { } function getDeviceName() { - if (!deviceName) { - if (browser.tizen) { - deviceName = 'Samsung Smart TV'; - } else if (browser.web0s) { - deviceName = 'LG Smart TV'; - } else if (browser.operaTv) { - deviceName = 'Opera TV'; - } else if (browser.xboxOne) { - deviceName = 'Xbox One'; - } else if (browser.ps4) { - deviceName = 'Sony PS4'; - } else if (browser.chrome) { - deviceName = 'Chrome'; - } else if (browser.edgeChromium) { - deviceName = 'Edge Chromium'; - } else if (browser.edge) { - deviceName = 'Edge'; - } else if (browser.firefox) { - deviceName = 'Firefox'; - } else if (browser.opera) { - deviceName = 'Opera'; - } else if (browser.safari) { - deviceName = 'Safari'; - } else { - deviceName = 'Web Browser'; - } + if (deviceName) { + return deviceName; + } - if (browser.ipad) { - deviceName += ' iPad'; - } else if (browser.iphone) { - deviceName += ' iPhone'; - } else if (browser.android) { - deviceName += ' Android'; + deviceName = 'Web Browser'; // Default device name + + for (const key in BrowserName) { + if (browser[key]) { + deviceName = BrowserName[key]; + break; } } + if (browser.ipad) { + deviceName += ' iPad'; + } else if (browser.iphone) { + deviceName += ' iPhone'; + } else if (browser.android) { + deviceName += ' Android'; + } return deviceName; }