Skip to content

Commit

Permalink
add external subtitles support
Browse files Browse the repository at this point in the history
  • Loading branch information
vanchaxy committed Dec 3, 2024
1 parent e185a22 commit 52c210a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ app = 'plexio'
primary_region = 'iad'

[build]
image = 'ghcr.io/vanchaxy/plexio:0.1.5'
image = 'ghcr.io/vanchaxy/plexio:0.1.6'

[env]
CACHE_TYPE = 'redis'
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "frontend",
"private": true,
"version": "0.1.5",
"version": "0.1.6",
"type": "module",
"scripts": {
"dev": "vite --host",
Expand Down
2 changes: 1 addition & 1 deletion plexio/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.5'
__version__ = '0.1.6'
18 changes: 18 additions & 0 deletions plexio/models/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def get_stremio_streams(self, configuration):

audio_languages = set()
subtitles_languages = set()
external_subtitles = []
for part_stream in media['Part'][0].get('Stream', []):
if part_stream['streamType'] == 2:
audio_languages.add(
Expand All @@ -180,6 +181,20 @@ def get_stremio_streams(self, configuration):
subtitles_languages.add(
get_flag_emoji(part_stream.get('languageTag', 'Unknown')),
)
if 'key' in part_stream:
external_subtitles.append(
{
'id': str(part_stream['id']),
'lang': part_stream['displayTitle'],
'url': str(
configuration.streaming_url
/ part_stream['key'][1:]
% {
'X-Plex-Token': configuration.access_token,
}
),
}
)

description_template = '{filename}\n{quality}\n{languages}'
languages = '/'.join(sorted(audio_languages))
Expand All @@ -202,6 +217,7 @@ def get_stremio_streams(self, configuration):
'X-Plex-Token': configuration.access_token,
},
),
subtitles=external_subtitles,
behaviorHints={'bingeGroup': quality_description},
),
)
Expand Down Expand Up @@ -233,6 +249,7 @@ def get_stremio_streams(self, configuration):
languages=languages,
),
url=str(transcode_url % {'videoQuality': 100}),
subtitles=external_subtitles,
behaviorHints={'bingeGroup': quality_description},
),
)
Expand All @@ -252,6 +269,7 @@ def get_stremio_streams(self, configuration):
languages=languages,
),
url=str(transcode_url % quality_params['plex_args']),
subtitles=external_subtitles,
behaviorHints={'bingeGroup': quality_description},
),
)
Expand Down

0 comments on commit 52c210a

Please sign in to comment.