Skip to content

Commit

Permalink
release: v0.0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
newt-sc committed May 6, 2020
1 parent b83a126 commit b1b6f9c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit =
a4kSubtitles/lib/num2ordinal.py
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ jobs:
- name: Test
if: "startsWith(needs.validate.outputs.commit, 'release: v')"
run: |
coverage run -m pytest -v
coverage run --parallel-mode -m pytest -v
- name: Coverage
if: "startsWith(needs.validate.outputs.commit, 'release: v') && matrix.python-version == 3.7"
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
coverage combine
coveralls
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* [v0.0.22](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.22):
* Fix meta string conversion issue

* [v0.0.21](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.21):
* TVShow year scrape from imdb when necessary

Expand Down
6 changes: 5 additions & 1 deletion a4kSubtitles/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
except ImportError:
from urllib.parse import quote_plus, unquote, parse_qsl
from io import StringIO
unicode = None

__url_regex = r'(([a-z0-9][a-z0-9-]{1,5}[a-z0-9]\.[a-z0-9]{2,20})|(opensubtitles))\.[a-z]{2,5}'
__credit_part_regex = r'(sync|synced|fix|fixed|corrected|corrections)'
Expand All @@ -39,7 +40,10 @@ def get_all_relative_py_files(file):
return [filename[:-3] for filename in files if not filename.startswith('__') and filename.endswith('.py')]

def strip_non_ascii_and_unprintable(text):
if isinstance(text, int):
if not isinstance(text, str):
return str(text)

if PY2 and not isinstance(text, unicode):
return str(text)

result = ''.join(char for char in text if char in string.printable)
Expand Down
21 changes: 12 additions & 9 deletions a4kSubtitles/services/bsplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'Connection': 'close',
}

__subdomains = [1, 2, 4, 5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109]
__subdomains = [1, 2, 3, 4, 5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109]

def __get_url(core, service_name):
context = core.services[service_name].context
Expand All @@ -29,17 +29,13 @@ def __get_url(core, service_name):

return "http://s%s.api.bsplayer-subtitles.com/v1.php" % context.subdomain

def __validate_response(core, service_name, request, response):
context = core.services[service_name].context
if not context.tries:
context.tries = 1
else:
context.tries += 1
def __validate_response(core, service_name, request, response, retry=True):
if not retry:
return None

def get_retry_request():
core.time.sleep(2)
if context.tries <= 2:
request['validate'] = lambda response: __validate_response(core, service_name, request, response)
request['validate'] = lambda response: __validate_response(core, service_name, request, response, retry=False)
return request

if response is None:
Expand All @@ -59,6 +55,13 @@ def get_retry_request():
if status_code.text != '200' and status_code.text != '402':
return get_retry_request()

results = response.findall('data/item')
if not results:
return get_retry_request()

if len(results) == 0:
return get_retry_request()

return None

def __get_request(core, service_name, action, params):
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="0.0.21"
version="0.0.22"
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
<icon>icon.png</icon>
</assets>
<news>
[v0.0.22]:
* Fix meta string conversion issue

[v0.0.21]:
* TVShow year scrape from imdb when necessary

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.21"
version="0.0.22"
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
<icon>icon.png</icon>
</assets>
<news>
[v0.0.22]:
* Fix meta string conversion issue

[v0.0.21]:
* TVShow year scrape from imdb when necessary

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

0 comments on commit b1b6f9c

Please sign in to comment.