Skip to content

Commit

Permalink
release: v3.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
newt-sc committed May 24, 2024
1 parent 53dc34c commit 94c2033
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 226 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ jobs:
env:
A4KSUBTITLES_OPENSUBTITLES_USERNAME: ${{ secrets.A4KSUBTITLES_OPENSUBTITLES_USERNAME }}
A4KSUBTITLES_OPENSUBTITLES_PASSWORD: ${{ secrets.A4KSUBTITLES_OPENSUBTITLES_PASSWORD }}
A4KSUBTITLES_SUBDL_APIKEY: ${{ secrets.A4KSUBTITLES_SUBDL_APIKEY }}
run: |
coverage run -m pytest -v
coverage run -m pytest -v -s --log-level=DEBUG
- name: coverage
if: "${{ !startsWith(needs.validate.outputs.commit, 'chore:') }}"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cron-tests-opensubtitles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ jobs:
env:
A4KSUBTITLES_OPENSUBTITLES_USERNAME: ${{ secrets.A4KSUBTITLES_OPENSUBTITLES_USERNAME }}
A4KSUBTITLES_OPENSUBTITLES_PASSWORD: ${{ secrets.A4KSUBTITLES_OPENSUBTITLES_PASSWORD }}
A4KSUBTITLES_SUBDL_APIKEY: ${{ secrets.A4KSUBTITLES_SUBDL_APIKEY }}
run: |
pytest -v -k 'test_opensubtitles' ./tests/test_suite.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Subscene
name: SubDL
on:
push:
branches:
- master
paths:
- '.github/workflows/cron-tests-subscene.yml'
- '.github/workflows/cron-tests-subdl.yml'
schedule:
- cron: '0 7 * * *'
workflow_dispatch: ~
Expand All @@ -28,4 +28,4 @@ jobs:
- name: test
run: |
pytest -v -k 'test_subscene' ./tests/test_suite.py
pytest -v -k 'test_subdl' ./tests/test_suite.py
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* [v3.15.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-3.15.0):
* Remove Subscene
* Add SubDL

* [v3.14.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-3.14.0):
* Handle invalid `VideoPlayer.IMDBNumber` meta

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[![BSPlayer](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-bsplayer.yml/badge.svg)](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-bsplayer.yml)
[![OpenSubtitles](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-opensubtitles.yml/badge.svg)](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-opensubtitles.yml)
[![Podnadpisi.NET](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-podnadpisi.yml/badge.svg)](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-podnadpisi.yml)
[![Subscene](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-subscene.yml/badge.svg)](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-subscene.yml)
[![SubDL](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-subdl.yml/badge.svg)](https://github.com/a4k-openproject/a4kSubtitles/actions/workflows/cron-tests-subdl.yml)

## Description

Expand All @@ -23,7 +23,7 @@ Subtitle addon for KODI with support for multiple subtitle services:
* BSPlayer
* OpenSubtitles
* Podnadpisi.NET
* Subscene
* SubDL

## Configuration
![configuration](https://media.giphy.com/media/kewuE4BgfOnFin0vEC/source.gif)
Expand Down
9 changes: 3 additions & 6 deletions a4kSubtitles/lib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ def __retry(core, request, response, next, cfscrape, retry=0):
if retry > 5:
return None

if response.status_code in [503, 429, 409, 403]:
if response.status_code == 503:
core.time.sleep(2)
if response.status_code in [502, 503, 429, 409, 403]:
if response.status_code in [503, 403]:
retry = 5
if response.status_code == 429:
core.time.sleep(3)
if response.status_code == 409:
else:
core.time.sleep(3)

retry += 1
Expand Down
2 changes: 1 addition & 1 deletion a4kSubtitles/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'bsplayer': 'BSPlayer',
'opensubtitles': 'OpenSubtitles',
'podnadpisi': 'Podnadpisi',
'subscene': 'Subscene',
'subdl': 'SubDL',
}

def __set_fn_if_missing(service, fn_name, fn):
Expand Down
93 changes: 93 additions & 0 deletions a4kSubtitles/services/subdl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-

def build_search_requests(core, service_name, meta):
apikey = core.kodi.get_setting(service_name, 'apikey')

if not apikey:
core.kodi.notification('SubDL requires API Key! Enter it in the addon Settings->Accounts or disable the service.')
core.logger.error('%s - API Key is missing' % service_name)
return []

lang_ids = core.utils.get_lang_ids(meta.languages, core.kodi.xbmc.ISO_639_1)
params = {
'api_key': apikey,
'languages': ','.join(lang_ids),
'type': 'movie' if not meta.is_tvshow else 'tv',
'subs_per_page': 30
}

if meta.is_tvshow:
params.update({
'film_name': meta.tvshow,
'file_name': meta.filename_without_ext,
'season_number': meta.season,
'episode_number': meta.episode,
})

if meta.tvshow_year_thread:
meta.tvshow_year_thread.join()
if meta.tvshow_year:
params['year'] = meta.tvshow_year
else:
params.update({
'imdb_id': meta.imdb_id,
'year': meta.year,
})

request = {
'method': 'GET',
'url': 'https://api.subdl.com/api/v1/subtitles',
'params': params,
}

return [request]

def parse_search_response(core, service_name, meta, response):
try:
results = core.json.loads(response.text)
except Exception as exc:
core.logger.error('%s - %s' % (service_name, exc))
return []

if not results.get('status', False):
core.logger.error('%s - %s' % (service_name, results.get('message', 'Unknown error')))
return []

core.logger.debug('%s - Found %d subtitles' % (service_name, len(results['subtitles'])))

service = core.services[service_name]
lang_ids = core.utils.get_lang_ids(meta.languages, core.kodi.xbmc.ISO_639_1)

def map_result(result):
filename = result['release_name']
lang_code = result['language'].lower()
lang = meta.languages[lang_ids.index(lang_code)]

return {
'service_name': service_name,
'service': service.display_name,
'lang': lang,
'name': filename,
'rating': 0,
'lang_code': lang_code,
'sync': 'false',
'impaired': 'true' if result['hi'] else 'false',
'color': 'springgreen',
'action_args': {
'url': result['url'],
'lang': lang,
'filename': filename,
}
}

return list(map(map_result, results['subtitles']))

def build_download_request(core, service_name, args):
request = {
'method': 'GET',
'url': 'https://dl.subdl.com' + args['url']
}

core.logger.debug('%s - Downloading %s' % (service_name, args['filename']))

return request
121 changes: 0 additions & 121 deletions a4kSubtitles/services/subscene.py

This file was deleted.

8 changes: 6 additions & 2 deletions 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="3.14.0"
version="3.15.0"
provider-name="Unknown">
<requires>
<import addon="script.module.requests"/>
Expand All @@ -13,7 +13,7 @@
<summary lang="en">a4kSubtitles - Multi-Source Subtitles Addon</summary>
<description>
Multi-source subtitles addon optimized for Seren and a4kScrapers.
Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, SubDL, Addic7ed
</description>
<platform>all</platform>
<reuselanguageinvoker>true</reuselanguageinvoker>
Expand All @@ -27,6 +27,10 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
<screenshot>screenshot-03.png</screenshot>
</assets>
<news>
[v3.15.0]:
* Remove Subscene
* Add SubDL

[v3.14.0]:
* Handle invalid `VideoPlayer.IMDBNumber` meta

Expand Down
8 changes: 6 additions & 2 deletions 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="3.14.0"
version="3.15.0"
provider-name="Unknown">
<requires>
<import addon="script.module.requests"/>
Expand All @@ -16,7 +16,7 @@
<summary lang="en">a4kSubtitles - Multi-Source Subtitles Addon</summary>
<description>
Multi-source subtitles addon optimized for Seren and a4kScrapers.
Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, SubDL, Addic7ed
</description>
<platform>all</platform>
<reuselanguageinvoker>true</reuselanguageinvoker>
Expand All @@ -30,6 +30,10 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
<screenshot>screenshot-03.png</screenshot>
</assets>
<news>
[v3.15.0]:
* Remove Subscene
* Add SubDL

[v3.14.0]:
* Handle invalid `VideoPlayer.IMDBNumber` meta

Expand Down
2 changes: 1 addition & 1 deletion packages/addons.xml.crc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5fc9c8b22c62b581d86dad09e25af4086b3ffc5a
d8ee5059ea7680d1c5001bc49d4287ad966f4bc3
6 changes: 5 additions & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ msgid "Podnadpisi"
msgstr ""

msgctxt "#33205"
msgid "Subscene"
msgid "SubDL"
msgstr ""

msgctxt "#33206"
Expand All @@ -81,3 +81,7 @@ msgstr ""
msgctxt "#33302"
msgid "Password"
msgstr ""

msgctxt "#33303"
msgid "API Key"
msgstr ""
Loading

2 comments on commit 94c2033

@alexj876
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent effort . "https://subscene.best" is already inhireted former subscene.com. worth to add.

@alexj876
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subscene.best is the replacemet of former subscene. looking forward to see it in the next release. thank you

Please sign in to comment.