Skip to content

[service.subtitles.napiprojekt] 3.0.0 - #2889

Open
CaTzil wants to merge 1 commit into
xbmc:nexusfrom
XBMCil:napiprojekt-nexus
Open

[service.subtitles.napiprojekt] 3.0.0#2889
CaTzil wants to merge 1 commit into
xbmc:nexusfrom
XBMCil:napiprojekt-nexus

Conversation

@CaTzil

@CaTzil CaTzil commented Aug 29, 2026

Copy link
Copy Markdown

Description

This update restores the functionality of the NapiProjekt subtitle add-on for modern Kodi versions and the current NapiProjekt API.

Main changes

  • fixed subtitle downloading under Kodi and Python 3;
  • switched both NapiProjekt endpoints from HTTP to HTTPS;
  • added request throttling and HTTP 429 Retry-After handling;
  • limited searches to one request for Polish subtitles;
  • added clear Kodi notifications for:
    • no matching subtitles;
    • missing or unreadable video files;
    • video hash calculation failures;
    • NapiProjekt request limits;
    • network errors;
    • invalid API responses;
  • fixed Base64, UTF-8 and CP1250 decoding;
  • added automatic detection of:
    • SubRip (.srt);
    • MicroDVD [start][end] (.sub);
    • MicroDVD {start}{end} (.sub);
  • added protection against treating a 7-Zip archive as subtitle text;
  • reduced API requests to parameters verified against the current service;
  • reorganized the Kodi entry point to comply with repository guidelines;
  • added the required 1920×1080 fanart;
  • corrected add-on metadata and removed obsolete links;
  • added a bilingual English/Polish README;

Checklist:

  • My code follows the add-on rules and piracy stance of this project.
  • I have read the CONTRIBUTING document
  • Each add-on submission should be a single commit with using the following style: [script.foo.bar] 1.0.0

Additional information :

  • Submitting your add-on to this specific branch makes it available to any Kodi version equal or higher than the branch name with the applicable Kodi dependencies limits.
  • add-on development wiki page.
  • Kodi pydocs provide information about the Python API
  • PEP8 codingstyle which is considered best practise but not mandatory.
  • This add-on repository has automated code guideline check which could help you improve your coding. You can find the results of these check at Codacy. You can create your own account as well to continuously monitor your python coding before submitting to repo.
  • Development questions can be asked in the add-on development section on the Kodi forum.

@greptile-apps

greptile-apps Bot commented Aug 29, 2026

Copy link
Copy Markdown

Greptile Summary

This PR restores the NapiProjekt subtitle add-on for current Kodi and Python 3 while updating its service integration and user-facing diagnostics.

  • Adds HTTPS search and XML download handling with subtitle-format and character-encoding detection.
  • Adds persistent request throttling, HTTP 429 handling, and localized failure notifications.
  • Reorganizes the entry point and refreshes metadata, documentation, licensing, translations, and artwork.

Confidence Score: 4/5

The Retry-After parser should be fixed before merging because valid server cooldown dates can be shortened and cause repeated rate-limit failures.

The request path handles only numeric Retry-After values, while the new cross-invocation throttle and hash timeout also have non-blocking lifecycle and concurrency weaknesses.

Files Needing Attention: service.subtitles.napiprojekt/resources/lib/napiprojekt.py, service.subtitles.napiprojekt/resources/lib/addon.py

Important Files Changed

Filename Overview
service.subtitles.napiprojekt/resources/lib/addon.py Implements Kodi request dispatch and video hashing, but its timeout leaves a slow VFS worker running after the search reports failure.
service.subtitles.napiprojekt/resources/lib/napiprojekt.py Implements API access, throttling, response decoding, and subtitle persistence; valid date-form Retry-After values are ignored and shared throttle state is race-prone.
service.subtitles.napiprojekt/service.py Provides a minimal Kodi entry point that imports and executes the add-on request handler.
service.subtitles.napiprojekt/addon.xml Updates add-on metadata, Python dependency, subtitle entry point, licensing, language, and artwork declarations.

Reviews (1): Last reviewed commit: "[service.subtitles.napiprojekt] 3.0.0" | Re-trigger Greptile

Comment on lines +111 to +117
with urlopen(request, timeout=REQUEST_TIMEOUT) as response:
return response.read()
except HTTPError as exc:
if exc.code == 429:
try:
retry_after = float(
exc.headers.get("Retry-After", RATE_LIMIT_FALLBACK)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Retry-After dates are discarded

When NapiProjekt returns HTTP 429 with a valid HTTP-date in Retry-After, float() rejects it and substitutes the ten-second fallback, causing requests to resume before the server's requested cooldown and potentially repeat the rate-limit failure.

Comment on lines +92 to +101
@classmethod
def _throttle(cls):
wait_seconds = cls._read_next_request_time() - time.time()
if wait_seconds > 0:
log("Waiting %.1f seconds before the next API request" % wait_seconds)
xbmc.sleep(int(wait_seconds * 1000) + 1)

# Reserve the next slot before opening the connection. This also
# limits a download launched by a separate Kodi plugin invocation.
cls._write_next_request_time(time.time() + API_MIN_INTERVAL)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Throttle reservations are not atomic

If separate add-on invocations overlap, both can read and reserve the same timestamp or overwrite a longer 429 cooldown, defeating the cross-invocation interval and producing avoidable rate-limit failures.

Comment on lines +42 to +48
it.daemon = True
it.start()
it.join(timeout_duration)
if it.is_alive():
return it.result
else:
return it.result

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Timed-out hash workers remain active

When a network-backed video read exceeds fifteen seconds, timeout() returns without cancelling or joining the worker, so Kodi reports a hash failure while the abandoned thread continues reading and retaining its VFS resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant