Skip to content

Commit

Permalink
release: v0.0.29
Browse files Browse the repository at this point in the history
  • Loading branch information
newt-sc committed May 13, 2020
1 parent fe2546e commit 76a2108
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* [v0.0.29](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.29):
* Fix Podnadpisi download of results missing filename meta

* [v0.0.28](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.28):
* Attempt scrape of imdb id when missing
* Improve filename parsing
Expand Down
30 changes: 8 additions & 22 deletions a4kSubtitles/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,17 @@ def __extract_gzip(core, archivepath, filename):
return filepath

def __extract_zip(core, archivepath, filename, episodeid):
path = core.utils.quote_plus(archivepath)
ext = core.os.path.splitext(filename)[1].lower()
(dirs, files) = core.kodi.xbmcvfs.listdir('archive://%s' % path)

first_subfile = None
subfile = None
for file in files:
if core.utils.py2:
file = file.decode('utf8')

file_lower = file.lower()
if file_lower.endswith(ext):
if not first_subfile:
first_subfile = file
if (episodeid == '' or episodeid in file_lower):
subfile = file
break
sub_exts = ['.srt', '.sub']
sub_exts_secondary = ['.smi', '.ssa', '.aqt', '.jss', '.ass', '.rt', '.txt']

archivepath = core.utils.quote_plus(archivepath)
subfile = core.utils.find_file_in_archive(core, archivepath, sub_exts, episodeid)
if not subfile:
if first_subfile:
subfile = first_subfile
else:
subfile = filename
subfile = core.utils.find_file_in_archive(core, archivepath, sub_exts_secondary, episodeid)
if not subfile:
subfile = filename

src = 'archive://' + path + '/' + subfile
src = 'archive://' + archivepath + '/' + subfile
dest = core.os.path.join(core.utils.temp_dir, filename)
core.kodi.xbmcvfs.copy(src, dest)
return dest
Expand Down
2 changes: 2 additions & 0 deletions a4kSubtitles/lib/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def get_meta_hash(meta):
return hash_data({
'imdb_id': meta.imdb_id,
'filename': meta.filename,
'languages': meta.languages,
'preferredlanguage': meta.preferredlanguage
})

def get_meta_cache():
Expand Down
19 changes: 19 additions & 0 deletions a4kSubtitles/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,22 @@ def get_relative_json(relative_file, filename):
json_path = os.path.join(os.path.dirname(relative_file), filename + '.json')
with open(json_path) as json_result:
return json.load(json_result)

def find_file_in_archive(core, archivepath, exts, part_of_filename=''):
(dirs, files) = core.kodi.xbmcvfs.listdir('archive://%s' % archivepath)

first_ext_match = None
exact_file = None
for file in files:
if core.utils.py2:
file = file.decode('utf8')

file_lower = file.lower()
if any(file_lower.endswith(ext) for ext in exts):
if not first_ext_match:
first_ext_match = file
if (part_of_filename == '' or part_of_filename in file_lower):
exact_file = file
break

return exact_file if exact_file is not None else first_ext_match
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="0.0.28"
version="0.0.29"
provider-name="Unknown">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
Expand All @@ -24,6 +24,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, SubDB, Subscene, Addic7ed
<icon>icon.png</icon>
</assets>
<news>
[v0.0.29]:
* Fix Podnadpisi download of results missing filename meta

[v0.0.28]:
* Attempt scrape of imdb id when missing
* Improve filename parsing
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="0.0.28"
version="0.0.29"
provider-name="Unknown">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
Expand All @@ -27,6 +27,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, SubDB, Subscene, Addic7ed
<icon>icon.png</icon>
</assets>
<news>
[v0.0.29]:
* Fix Podnadpisi download of results missing filename meta

[v0.0.28]:
* Attempt scrape of imdb id when missing
* Improve filename parsing
Expand Down
2 changes: 1 addition & 1 deletion packages/addons.xml.crc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
833c8c46e7dd451395e9f3c678a91600803a4954
e71d452c7b619d76d51dd5b7687dc145ec0393e9

0 comments on commit 76a2108

Please sign in to comment.