Skip to content

Commit

Permalink
v0.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
nazegnl authored and nazegnl committed Apr 23, 2020
1 parent 24b44d2 commit ed76f07
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* [v0.0.10](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.10):
* Inserted language code in sub filename

* [v0.0.9](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.9):
* Implemented (orginal, default, none, forced_only) as KODI language setting
* Fixed minor bugs in API implementation
Expand Down Expand Up @@ -37,4 +40,4 @@
* [v0.0.1](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.1):
* initial working version (search and download subtitles)
* OpenSubtitles support with optional authentication
* results ordering with preffered language ordered first
* results ordering with preferred language ordered first
13 changes: 11 additions & 2 deletions a4kSubtitles/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def __download(core, filepath, request):
with open(filepath, 'wb') as f:
core.shutil.copyfileobj(r.raw, f)

def __extract(core, archivepath, filename):
def __extract(core, archivepath, filename, language):
path = core.utils.quote_plus(archivepath)
ext = core.os.path.splitext(filename)[1].lower()
(dirs, files) = core.kodi.xbmcvfs.listdir('archive://%s' % path)
Expand All @@ -18,10 +18,18 @@ def __extract(core, archivepath, filename):
break

src = 'archive://' + path + '/' + subfile
subfile = __insert_language_code_in_filename(core, filename, language)
dest = core.os.path.join(core.utils.temp_dir, subfile)
core.kodi.xbmcvfs.copy(src, dest)
return dest

def __insert_language_code_in_filename(core, filename, language_name):
filename_chunks = filename.split('.')
lang_code = core.kodi.xbmc.convertLanguage(language_name,
core.kodi.xbmc.ISO_639_1)
filename_chunks.insert(-1, lang_code)
return '.'.join(filename_chunks)

def download(core, params):
core.logger.debug(lambda: core.json.dumps(params, indent=2))

Expand All @@ -30,14 +38,15 @@ def download(core, params):

actions_args = params['action_args']
filename = actions_args['filename']
language = actions_args['lang']
archivepath = core.os.path.join(core.utils.temp_dir, 'sub.zip')

service_name = params['service_name']
service = core.services[service_name]
request = service.build_download_request(core, service_name, actions_args)

__download(core, archivepath, request)
filepath = __extract(core, archivepath, filename)
filepath = __extract(core, archivepath, filename, language)

if core.api_mode_enabled:
return filepath
Expand Down
7 changes: 4 additions & 3 deletions a4kSubtitles/lib/kodi_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
xbmc.getInfoLabel = lambda t: ''
xbmc.executeJSONRPC = lambda _: '{ "result": { "value": true } }'

xbmc.convertLanguage = lambda l, f: l[:3].lower()
xbmc.ISO_639_2 = None
xbmc.convertLanguage = lambda l, f: l[:f].lower()
xbmc.ISO_639_1 = 2
xbmc.ISO_639_2 = 3

__player = lambda: None
__player.getPlayingFile = lambda: ''
xbmc.Player = lambda: __player

def __log(msg, lebel):
def __log(msg, label):
print(msg)
xbmc.log = __log
xbmc.LOGDEBUG = 'debug'
Expand Down
1 change: 1 addition & 0 deletions a4kSubtitles/services/opensubtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def map_result(result):
'impaired': 'false' if result['SubHearingImpaired'] == '0' else 'true',
'action_args': {
'url': result['ZipDownloadLink'].replace('/subad/', '/sub/'),
'lang': result['LanguageName'],
'filename': result['SubFileName']
}
}
Expand Down
2 changes: 1 addition & 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="0.0.9"
version="0.0.10"
provider-name="Unknown">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
Expand Down
2 changes: 1 addition & 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="0.0.9"
version="0.0.10"
provider-name="Unknown">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
Expand Down
2 changes: 1 addition & 1 deletion packages/addons.xml.crc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a5fc3e63de303ff726cc8608184b7e0242f50fa7
76ca0d8937ec34388517309f61b6b7b2b0521701

0 comments on commit ed76f07

Please sign in to comment.