Skip to content

Commit

Permalink
release: v3.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
newt-sc committed Jan 6, 2024
1 parent ab82bac commit 46edcd3
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* [v3.12.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-3.12.0):
* Fix OpenSubtitles not working for titles with IMDB ID less than 1_000_000

* [v3.11.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-3.11.0):
* Fix auto-selection and add debug logs.

Expand Down
21 changes: 9 additions & 12 deletions a4kSubtitles/lib/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,23 @@ def __get_debug_logenabled():

return False

def __log(message, level=xbmc.LOGDEBUG):
is_lazy_msg = callable(message)
if is_lazy_msg and level == xbmc.LOGDEBUG and not __get_debug_logenabled():
try:
notice_type = xbmc.LOGNOTICE
except:
notice_type = xbmc.LOGINFO

def __log(message, level):
if level == notice_type and not __get_debug_logenabled():
return

is_lazy_msg = callable(message)
if is_lazy_msg:
message = message()

xbmc.log('{0}: {1}'.format(addon_id, message), level)

try:
notice_type = xbmc.LOGNOTICE
except:
notice_type = xbmc.LOGINFO

def notice(message):
__log(message, notice_type)

def error(message):
__log(message, xbmc.LOGERROR)

def debug(message):
__log(message, xbmc.LOGDEBUG)
__log(message, notice_type)
2 changes: 1 addition & 1 deletion a4kSubtitles/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def cleanup_subtitles(core, sub_contents):
)

if line_contains_ad:
logger.notice('(detected ad) %s' % line.encode('ascii', errors='ignore'))
logger.debug('(detected ad) %s' % line.encode('ascii', errors='ignore'))
if not re.match(r'^\{\d+\}\{\d+\}', line):
garbage = True
buffer = []
Expand Down
5 changes: 5 additions & 0 deletions a4kSubtitles/lib/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,9 @@ def get_meta(core):
meta.tvshow_year_thread = threading.Thread(target=__scrape_tvshow_year, args=(core, meta))
meta.tvshow_year_thread.start()

try:
if len(meta.imdb_id) > 2:
meta.imdb_id_as_int = int(meta.imdb_id[2:].lstrip('0'))
except: pass

return meta
6 changes: 4 additions & 2 deletions a4kSubtitles/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ def find_sub_index():
sub_index = sub['index']
break

if sub_index == -1:
if sub_index is None:
for sub in player_props['subtitles']:
subname = sub['name'].lower()
if sub['isdefault'] or ('forced' not in subname and 'songs' not in subname):
if sub['language'] != preferredlang_code:
continue
if sub['isdefault'] or all(s not in subname for s in ['forced', 'songs', 'commentary']):
core.logger.debug('found default subtitles: %s' % subname)
sub_index = sub['index']
break
Expand Down
3 changes: 2 additions & 1 deletion a4kSubtitles/services/opensubtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ def parse_search_response(core, service_name, meta, response):
def map_result(result):
result = result['attributes']
imdb_id = result.get('feature_details', {}).get('imdb_id', None)
if len(result['files']) == 0 or imdb_id is not None and ('tt%s' % imdb_id) != meta.imdb_id:
if len(result['files']) == 0 or imdb_id is not None and imdb_id != meta.imdb_id_as_int:
return None

filename = result['files'][0]['file_name']
language = core.utils.get_lang_id(result['language'], core.kodi.xbmc.ENGLISH_NAME)

return {
'service_name': service_name,
'service': service.display_name,
Expand Down
5 changes: 4 additions & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.subtitles.a4ksubtitles"
name="a4kSubtitles"
version="3.11.0"
version="3.12.0"
provider-name="Unknown">
<requires>
<import addon="script.module.requests"/>
Expand All @@ -27,6 +27,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
<screenshot>screenshot-03.png</screenshot>
</assets>
<news>
[v3.12.0]:
* Fix OpenSubtitles not working for titles with IMDB ID less than 1_000_000

[v3.11.0]:
* Fix auto-selection and add debug logs.

Expand Down
5 changes: 4 additions & 1 deletion packages/addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<addons>
<addon id="service.subtitles.a4ksubtitles"
name="a4kSubtitles"
version="3.11.0"
version="3.12.0"
provider-name="Unknown">
<requires>
<import addon="script.module.requests"/>
Expand All @@ -30,6 +30,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
<screenshot>screenshot-03.png</screenshot>
</assets>
<news>
[v3.12.0]:
* Fix OpenSubtitles not working for titles with IMDB ID less than 1_000_000

[v3.11.0]:
* Fix auto-selection and add debug logs.

Expand Down
2 changes: 1 addition & 1 deletion packages/addons.xml.crc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e71401b7c44e6bf99cdf8534835afa8d9ae20049
17ec6ef140b463ff93b6887a895988cc069ae17e

0 comments on commit 46edcd3

Please sign in to comment.