Skip to content

Commit

Permalink
release: v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
newt-sc committed May 30, 2020
1 parent 8719118 commit a2459e3
Show file tree
Hide file tree
Showing 6 changed files with 48 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 @@
* [v1.5.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-1.5.0):
* Auto open search dialog only on movie and tvshow videos

* [v1.4.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-1.4.0):
* Add option to auto open the search dialog when the video does not have subtitles

Expand Down
8 changes: 5 additions & 3 deletions a4kSubtitles/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ def start(core):
if not core.kodi.get_bool_setting('general', 'auto_search'):
continue

has_video = core.kodi.xbmc.getCondVisibility('Player.HasVideo')
has_video = (core.kodi.xbmc.getCondVisibility('VideoPlayer.Content(movies)')
or core.kodi.xbmc.getCondVisibility('VideoPlayer.Content(episodes)'))
if not has_video and has_done_subs_check:
has_done_subs_check = False

if not has_video or has_done_subs_check:
has_video_duration = core.kodi.xbmc.getCondVisibility('Player.HasDuration')

if not has_video or not has_video_duration or has_done_subs_check:
continue

has_done_subs_check = True
Expand All @@ -24,6 +27,5 @@ def start(core):
has_subtitles = core.kodi.xbmc.getCondVisibility('VideoPlayer.HasSubtitles') and has_subtitles_enabled

if not has_subtitles:
core.time.sleep(0.5)
core.kodi.xbmc.executebuiltin('ActivateWindow(SubtitleSearch)')
continue
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="1.4.0"
version="1.5.0"
provider-name="Unknown">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
Expand All @@ -28,6 +28,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, SubDB, Subscene, Addic7ed
<screenshot>screenshot-03.png</screenshot>
</assets>
<news>
[v1.5.0]:
* Auto open search dialog only on movie and tvshow videos

[v1.4.0]:
* Add option to auto open the search dialog when the video does not have subtitles

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="1.4.0"
version="1.5.0"
provider-name="Unknown">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
Expand All @@ -31,6 +31,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, SubDB, Subscene, Addic7ed
<screenshot>screenshot-03.png</screenshot>
</assets>
<news>
[v1.5.0]:
* Auto open search dialog only on movie and tvshow videos

[v1.4.0]:
* Add option to auto open the search dialog when the video does not have subtitles

Expand Down
2 changes: 1 addition & 1 deletion packages/addons.xml.crc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6e36d33f6e61337b90cf18add8c7f42fabd29b2a
da66c1a421c613825773c5f2066a4366d0d7cb2a
44 changes: 31 additions & 13 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,12 @@ def restore():
api.core.kodi.xbmc.getCondVisibility = default
return restore

def __mock_time_sleep(api):
default = api.core.time.sleep
api.core.time.sleep = lambda _: None
def restore():
api.core.time.sleep = default
return restore

def __mock(api, settings):
restore_monitor = __mock_monitor(api)
restore_time_sleep = __mock_time_sleep(api)
restore_settings = api.mock_settings(settings)

def restore():
restore_monitor()
restore_time_sleep()
restore_settings()
return restore

Expand Down Expand Up @@ -81,7 +72,8 @@ def test_service_when_video_has_subtitles():
'general.auto_search': 'true',
})
restore_get_cond_visibility = __mock_get_cond_visibility(a4ksubtitles_api, {
'Player.HasVideo': True,
'VideoPlayer.Content(movies)': True,
'Player.HasDuration': True,
'VideoPlayer.HasSubtitles': True,
'VideoPlayer.SubtitlesEnabled': True,
})
Expand All @@ -103,7 +95,8 @@ def test_service_when_video_does_not_have_subtitles():
'general.auto_search': 'true',
})
restore_get_cond_visibility = __mock_get_cond_visibility(a4ksubtitles_api, {
'Player.HasVideo': True,
'VideoPlayer.Content(episodes)': True,
'Player.HasDuration': True,
'VideoPlayer.HasSubtitles': False,
'VideoPlayer.SubtitlesEnabled': False,
})
Expand All @@ -125,7 +118,8 @@ def test_service_when_video_has_disabled_subtitles():
'general.auto_search': 'true',
})
restore_get_cond_visibility = __mock_get_cond_visibility(a4ksubtitles_api, {
'Player.HasVideo': True,
'VideoPlayer.Content(movies)': True,
'Player.HasDuration': True,
'VideoPlayer.HasSubtitles': True,
'VideoPlayer.SubtitlesEnabled': False,
})
Expand All @@ -147,7 +141,8 @@ def test_service_when_subs_check_done():
'general.auto_search': 'true',
})
restore_get_cond_visibility = __mock_get_cond_visibility(a4ksubtitles_api, {
'Player.HasVideo': True,
'VideoPlayer.Content(movies)': True,
'Player.HasDuration': True,
'VideoPlayer.HasSubtitles': True,
'VideoPlayer.SubtitlesEnabled': True,
})
Expand All @@ -161,3 +156,26 @@ def test_service_when_subs_check_done():
executebuiltin_spy.restore()

assert executebuiltin_spy.call_count == 0

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

restore = __mock(a4ksubtitles_api, {
'general.auto_search': 'true',
})
restore_get_cond_visibility = __mock_get_cond_visibility(a4ksubtitles_api, {
'VideoPlayer.Content(movies)': True,
'Player.HasDuration': False,
'VideoPlayer.HasSubtitles': False,
'VideoPlayer.SubtitlesEnabled': False,
})

executebuiltin_spy = utils.spy_fn(a4ksubtitles_api.core.kodi.xbmc, 'executebuiltin')

service.start(a4ksubtitles_api.core)

restore()
restore_get_cond_visibility()
executebuiltin_spy.restore()

assert executebuiltin_spy.call_count == 0

0 comments on commit a2459e3

Please sign in to comment.