Skip to content

Commit

Permalink
Version 0.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Paco8 committed Mar 4, 2021
1 parent bd81146 commit 5e29556
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion kodi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ install: ../src/ttml2ssa.py ../src/timestampconverter.py addon.xml-k18 addon.xml
install -m 644 icon.png $(OUTPUT_DIR)/
install -m 644 settings.xml-k18 $(OUTPUT_DIR)/resources/
install -m 644 settings.xml-k19 $(OUTPUT_DIR)/resources/
install -m 644 screen*.jpg $(OUTPUT_DIR)/resources/
install -m 644 *.jpg $(OUTPUT_DIR)/resources/
sed -e 's/{version}/$(VERSION)/' -i $(OUTPUT_DIR)/addon.xml-k18
cp $(OUTPUT_DIR)/addon.xml-k18 $(OUTPUT_DIR)/addon.xml
cp $(OUTPUT_DIR)/resources/settings.xml-k18 $(OUTPUT_DIR)/resources/settings.xml
Expand Down
1 change: 1 addition & 0 deletions kodi/addon.xml-k18
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<source>https://github.com/Paco8/ttml2ssa</source>
<assets>
<icon>icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
<screenshot>resources/screen1.jpg</screenshot>
<screenshot>resources/screen2.jpg</screenshot>
</assets>
Expand Down
1 change: 1 addition & 0 deletions kodi/addon.xml-k19
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<source>https://github.com/Paco8/ttml2ssa</source>
<assets>
<icon>icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
<screenshot>resources/screen1.jpg</screenshot>
<screenshot>resources/screen2.jpg</screenshot>
</assets>
Expand Down
Binary file added kodi/fanart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified kodi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion kodi/settings.xml-k18
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<setting label="32006" type="enum" id="borderstyle" lvalues="32007|32008"/>
<setting label="32009" type="number" id="outline" default="2"/>
<setting label="32010" type="number" id="shadow" default="3"/>
<setting label="32011" type="bool" id="bold" default="false"/>
<setting label="32011" type="bool" id="bold" default="true"/>
<setting label="32012" type="bool" id="italic" default="false"/>
<setting label="32013" type="number" id="marginv" default="40"/>
<setting label="32014" type="number" id="marginl" default="40"/>
Expand Down
9 changes: 5 additions & 4 deletions kodi/settings.xml-k19
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
<default>0</default>
<constraints>
<options>
<option label="32203">0</option>
<option label="32204">1</option>
<option label="32204">0</option>
<option label="32203">1</option>
<option label="32205">2</option>
</options>
</constraints>
<control type="spinner" format="string"/>
<control type="list" format="string"/>
<heading>32200</heading>
</setting>
</group>
<group id="2" label="32000">
Expand Down Expand Up @@ -79,7 +80,7 @@
</setting>
<setting id="bold" type="boolean" label="32011" help="">
<level>0</level>
<default>false</default>
<default>true</default>
<control type="toggle"/>
</setting>
<setting id="italic" type="boolean" label="32012" help="">
Expand Down
20 changes: 16 additions & 4 deletions src/ttml2ssa.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

class Ttml2Ssa(object):

VERSION = '0.2.10'
VERSION = '0.2.11'

TIME_BASES = [
'media',
Expand Down Expand Up @@ -156,7 +156,7 @@ def parse_ttml_from_string(self, doc):
):
ttp_val = getattr(
tt_element.attributes.get('ttp:' + ttp_name), 'value', defval)
opttime[Ttml2Ssa.snake_to_camel(ttp_name)] = convfn(ttp_val)
opttime[Ttml2Ssa._snake_to_camel(ttp_name)] = convfn(ttp_val)

if opttime['time_base'] not in Ttml2Ssa.TIME_BASES:
raise NotImplementedError('No support for "{}" time base'.format(
Expand Down Expand Up @@ -251,7 +251,7 @@ def _get_tt_style_attrs(self, node, in_head=False):
style = {}
for attr_name in self._allowed_style_attrs:
tts = 'tts:' + attr_name
attr_name = Ttml2Ssa.snake_to_camel(attr_name)
attr_name = Ttml2Ssa._snake_to_camel(attr_name)
style[attr_name] = node.getAttribute(tts) or ''
if not in_head:
style['style_id'] = node.getAttribute('style')
Expand Down Expand Up @@ -633,7 +633,7 @@ def string_to_color(self, text):
return hex_number

@staticmethod
def snake_to_camel(s):
def _snake_to_camel(s):
camel = ''
for c in s:
d = ord(c)
Expand All @@ -645,6 +645,8 @@ def snake_to_camel(s):

@staticmethod
def parse_m3u8_from_string(m3u8):
""" Parse a m3u8 from a string a return a list of the segments """

segments = []

lines = m3u8.splitlines()
Expand Down Expand Up @@ -692,6 +694,12 @@ def download_m3u8_subtitle(self, url):
return res, segments

def download_m3u8_disney(self, url):
""" Similar to download_m3u8_subtitle but specific for Disney+
Download all segments from a m3u8 file and joins them together.
Return a string with the subtitle and the offset (in milliseconds)
that must be added to the timestamps.
"""

if self.cache_downloaded_subtitles and self.cache_directory:
vtt, offset = self._load_vtt_from_cache(url)
if vtt:
Expand Down Expand Up @@ -737,6 +745,8 @@ def _load_vtt_from_cache(self, url):

@staticmethod
def get_subtitle_list_from_m3u8_string(doc, language_list=None, allow_forced=True, allow_non_forced=True, baseurl='', sort=True):
""" Parse a m3u8 file, look for subtitles and return a list of them """

def lang_allowed(lang, lang_list):
if not lang_list:
return True
Expand Down Expand Up @@ -783,6 +793,8 @@ def lang_allowed(lang, lang_list):
return sub_list

def get_subtitle_list_from_m3u8_url(self, url, language_list=None, allow_forced=True, allow_non_forced=True):
""" Download the m3u8 file from the url, look for subtitles in the file and return a list of them """

import requests
self._printinfo('Downloading {}'.format(url))
baseurl = os.path.dirname(url) + '/'
Expand Down

0 comments on commit 5e29556

Please sign in to comment.