Skip to content

Commit

Permalink
Merge 85944f8 into 318bbc6
Browse files Browse the repository at this point in the history
  • Loading branch information
newt-sc committed May 9, 2021
2 parents 318bbc6 + 85944f8 commit 420b7df
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* [v2.6.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-2.6.0):
* Support imdb id passed from video file url.

* [v2.5.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-2.5.0):
* Add TLS adapter fallback

Expand Down
2 changes: 2 additions & 0 deletions a4kSubtitles/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def get_info_label(label):
return meta.get('_title', '')
if label == 'VideoPlayer.IMDBNumber':
return meta.get('imdb_id', '')
if label == 'Player.FilenameAndPath':
return meta.get('url', '')
default = self.core.kodi.xbmc.getInfoLabel
self.core.kodi.xbmc.getInfoLabel = get_info_label

Expand Down
5 changes: 5 additions & 0 deletions a4kSubtitles/lib/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ def __get_basic_info():
meta.filename_without_ext = meta.filename
meta.imdb_id = xbmc.getInfoLabel('VideoPlayer.IMDBNumber')

if meta.imdb_id == '':
regex_result = re.search(r'.*(tt\d{7,}).*', xbmc.getInfoLabel('Player.FilenameAndPath'), re.IGNORECASE)
if regex_result:
meta.imdb_id = regex_result.group(1)

return meta

def get_meta(core):
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="2.5.0"
version="2.6.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>
[v2.6.0]:
* Support imdb id passed from video file url.

[v2.5.0]:
* Add TLS adapter fallback

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="2.5.0"
version="2.6.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>
[v2.6.0]:
* Support imdb id passed from video file url.

[v2.5.0]:
* Add TLS adapter fallback

Expand Down
2 changes: 1 addition & 1 deletion packages/addons.xml.crc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ffd194a94b96801a0bf4512fcd5d65ac00836de4
3e49ed72de384e85712a5c6e9074690f8c7a8520
16 changes: 16 additions & 0 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,22 @@ def test_opensubtitles_missing_imdb_id():

assert len(search.results) > 0

def test_opensubtitles_missing_imdb_id_but_in_url():
a4ksubtitles_api = api.A4kSubtitlesApi({'kodi': True})
__remove_all_cache(a4ksubtitles_api)

# search
settings = {
'opensubtitles.enabled': 'true',
}
video_meta = {
'imdb_id': '',
'url': 'https://example.com/example.mkv?imdb_id=tt3183660'
}
search = __search_movie(a4ksubtitles_api, settings, video_meta)

assert len(search.results) > 0

def test_opensubtitles_tvshow_missing_imdb_id():
a4ksubtitles_api = api.A4kSubtitlesApi({'kodi': True})
__remove_all_cache(a4ksubtitles_api)
Expand Down

0 comments on commit 420b7df

Please sign in to comment.