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 23, 2024
1 parent 53dc34c commit ae381d7
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 149 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ 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
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
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 ""
6 changes: 5 additions & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<setting id="bsplayer.enabled" label="33202" type="bool" default="true"/>
<setting id="opensubtitles.enabled" label="33201" type="bool" default="true"/>
<setting id="podnadpisi.enabled" label="33203" type="bool" default="true"/>
<setting id="subscene.enabled" label="33205" type="bool" default="true"/>
<setting id="subdl.enabled" label="33205" type="bool" default="true"/>
</category>
<!-- Accounts -->
<category label="33003">
Expand All @@ -26,5 +26,9 @@
<setting type="sep"/>
<setting id="opensubtitles.username" label="33301" type="text" default=""/>
<setting id="opensubtitles.password" label="33302" type="text" default="" option="hidden"/>
<!-- SubDL -->
<setting type="lsep" label="33205"/>
<setting type="sep"/>
<setting id="subdl.apikey" label="33303" type="text" default=""/>
</category>
</settings>
Loading

0 comments on commit ae381d7

Please sign in to comment.