5 Commits

Author SHA1 Message Date
mcarlton00
569462f755 Merge pull request #177 from jellyfin/prepare-0.5.2
Some checks failed
Build JellyCon / build (py2) (push) Has been cancelled
Build JellyCon / build (py3) (push) Has been cancelled
Prepare for release v0.5.2
2022-06-20 09:32:07 -04:00
jellyfin-bot
658050548c bump version to 0.5.2 2022-06-20 13:25:17 +00:00
mcarlton00
4d635f6eb4 Merge pull request #176 from mcarlton00/external-subs-10.8
Download all external subs when playback starts
2022-06-20 09:24:14 -04:00
mcarlton00
a0b1e9177b Merge branch 'master' into external-subs-10.8 2022-06-19 16:01:12 -04:00
Matt
7a1a7843e6 Download all external subs when playback starts 2022-06-19 15:55:46 -04:00
3 changed files with 30 additions and 16 deletions

View File

@@ -1,16 +1,8 @@
version: '0.5.1'
version: '0.5.2'
changelog: |-
New features and improvements
-----------------------------
+ Add context menu play options for music (#173) @mcarlton00
Bug Fixes
---------
+ Do all date comparisons in UTC (#172) @mcarlton00
Documentation updates
---------------------
+ Update README.md (#170) @nitschis
+ Download all external subs when playback starts (#176) @mcarlton00
dependencies:
py2:
- addon: 'xbmc.python'

View File

@@ -15,7 +15,7 @@ from six.moves.urllib.parse import urlencode
from .jellyfin import api
from .lazylogger import LazyLogger
from .dialogs import ResumeDialog
from .utils import send_event_notification, convert_size, get_device_id, translate_string, load_user_details, translate_path, get_jellyfin_url
from .utils import send_event_notification, convert_size, get_device_id, translate_string, load_user_details, translate_path, get_jellyfin_url, download_external_sub
from .kodi_utils import HomeWindow
from .datamanager import clear_old_cache_data
from .item_functions import extract_item_info, add_gui_item, get_art
@@ -843,12 +843,18 @@ def external_subs(media_source, list_item, item_id):
language = stream.get('Language', '')
codec = stream.get('Codec', '')
url_root = '{}/Videos/{}/{}/Subtitles/{}'.format(server, item_id, source_id, index)
url = '{}{}'.format(server, stream.get('DeliveryUrl'))
if language:
url = '{}/0/Stream.{}.{}?api_key={}'.format(
url_root, language, codec, token)
'''
Starting in 10.8, the server no longer provides language
specific download points. We have to download the file
and name it with the language code ourselves so Kodi
will parse it correctly
'''
subtitle_file = download_external_sub(language, codec, url)
else:
url = '{}/0/Stream.{}?api_key={}'.format(url_root, codec, token)
# If there is no language defined, we can go directly to the server
subtitle_file = url
default = ""
if stream['IsDefault']:
@@ -860,7 +866,7 @@ def external_subs(media_source, list_item, item_id):
sub_name = '{} ( {} ) {} {}'.format(language, codec, default, forced)
sub_names.append(sub_name)
externalsubs.append(url)
externalsubs.append(subtitle_file)
if len(externalsubs) == 0:
return

View File

@@ -15,6 +15,7 @@ import time
import math
import os
import hashlib
import requests
from datetime import datetime
from dateutil import tz
import re
@@ -363,3 +364,18 @@ def translate_path(path):
return xbmcvfs.translatePath(path)
else:
return xbmc.translatePath(path)
def download_external_sub(language, codec, url):
# Download the subtitle file
r = requests.get(url)
r.raise_for_status()
# Write the subtitle file to the local filesystem
file_name = 'Stream.{}.{}'.format(language, codec)
file_path = py2_decode(translate_path('special://temp/{}'.format(file_name)))
with open(file_path, 'wb') as f:
f.write(r.content)
return file_path