Skip to content

Commit

Permalink
feat(Emby): use compare-versions
Browse files Browse the repository at this point in the history
feat(Emby): use compare-versions
  • Loading branch information
Dark_Ville authored and darkvillager2 committed Oct 19, 2024
1 parent 44a5619 commit 39ddb42
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
17 changes: 17 additions & 0 deletions websites/E/Emby/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions websites/E/Emby/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"compare-versions": "6.1.1"
}
}
5 changes: 3 additions & 2 deletions websites/E/Emby/presence.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { compare } from "compare-versions";
/*
* The interfaces may have some things missing,
* I've tried to set as many properties as I could find.
Expand Down Expand Up @@ -514,7 +515,7 @@ const mediaInfoCache = new Map<string, MediaInfo>();
async function obtainMediaInfo(itemId: string): Promise<MediaInfo> {
if (mediaInfoCache.has(itemId)) return mediaInfoCache.get(itemId);
let ae, accessToken: string;
if (!version.includes("4.7")) {
if (compare(version, "4.7.0", ">")) {
ae = ApiClient._serverInfo as ServerLatest;
accessToken = ae?.Users?.[1]?.AccessToken;
} else {
Expand All @@ -525,7 +526,7 @@ async function obtainMediaInfo(itemId: string): Promise<MediaInfo> {
if (!accessToken) {
// refresh the ApiClient
ApiClient = await getApiClient();
if (!version.includes("4.7")) {
if (compare(version, "4.7.0", ">")) {
ae = ApiClient._serverInfo as ServerLatest;
accessToken = ae?.Users?.[1]?.AccessToken;
} else {
Expand Down

0 comments on commit 39ddb42

Please sign in to comment.