Skip to content

Commit

Permalink
Combine Emby and Jellyfin (#520)
Browse files Browse the repository at this point in the history
* Add Retry for if Session for device can't be found

* Combined emby and Jellyfin

* spacing

* prettier
  • Loading branch information
bpwhelan authored Sep 22, 2024
1 parent 88d6fc6 commit 3013bed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 105 deletions.
1 change: 0 additions & 1 deletion extension/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
"pages/viki-page.js",
"pages/unext-page.js",
"pages/emby-page.js",
"pages/jellyfin-page.js",
"pages/osnplus-page.js",
"pages/bilibili-page.js",
"pages/nrk-tv-page.js",
Expand Down
12 changes: 2 additions & 10 deletions extension/src/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,9 @@
}
},
{
"host": "jellyfin*|:8096*",
"script": "jellyfin-page.js",
"hash": "#/video",
"autoSync": {
"enabled": true
}
},
{
"host": "emby*|:8096*",
"host": "jellyfin*|emby*|:8096*",
"script": "emby-page.js",
"hash": "#!/videoosd/videoosd.html",
"hash": "#!/videoosd/videoosd.html|#/video",
"autoSync": {
"enabled": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ document.addEventListener(
})
);
}

const deviceID = ApiClient?._deviceId;
const apikey = ApiClient?._userAuthInfo.AccessToken;

let session;
for (let attempt = 0; attempt < 5; attempt++) {
Expand All @@ -40,31 +40,25 @@ document.addEventListener(

var mediaID = session.PlayState.MediaSourceId;
var nowPlayingItem = session.NowPlayingItem;
response.basename = nowPlayingItem.FileName;
response.basename = nowPlayingItem.FileName ?? nowPlayingItem.Name;

const subtitles: VideoDataSubtitleTrack[] = [];
nowPlayingItem.MediaStreams.filter(
(stream: { IsTextSubtitleStream: any }) => stream.IsTextSubtitleStream
).forEach((sub: { Codec: string; DisplayTitle: any; Language: any; Index: number }) => {
).forEach((sub: { Codec: string; DisplayTitle: any; Language: any; Index: number; Path: string }) => {
const extension = sub.Path ? sub.Path.split('.').pop()! : sub.Codec;
var url =
'/Videos/' +
nowPlayingItem.Id +
'/' +
mediaID +
'/Subtitles/' +
sub.Index +
'/Stream.' +
sub.Codec +
'?api_key=' +
apikey;
'/Videos/' + nowPlayingItem.Id + '/' + mediaID + '/Subtitles/' + sub.Index + '/Stream.' + extension;
subtitles.push(
trackFromDef({
label: sub.DisplayTitle,
language: sub.Language || '',
url: url,
extension: sub.Codec,
extension,
})
);
});

response.subtitles = subtitles;

document.dispatchEvent(
Expand Down
80 changes: 0 additions & 80 deletions extension/src/pages/jellyfin-page.ts

This file was deleted.

0 comments on commit 3013bed

Please sign in to comment.