Skip to content

Show a QR code for device-code login (text dialog fallback)#710

Open
magne4000 wants to merge 1 commit into
anxdpanic:masterfrom
magne4000:feature/qr-device-login
Open

Show a QR code for device-code login (text dialog fallback)#710
magne4000 wants to merge 1 commit into
anxdpanic:masterfrom
magne4000:feature/qr-device-login

Conversation

@magne4000

Copy link
Copy Markdown

Summary

The device-code login now shows a scannable QR code of the Twitch activation URL alongside the short user code, so viewers can sign in with their phone camera instead of typing a URL. Both the regular and the private (Turbo/ad-free) login get it, since they share do_device_login().

How it works

  • QR is rendered dependency-free: a vendored QR generator (Project Nayuki, MIT) produces the module matrix and a small zlib-based PNG writer emits the image — no PIL/Pillow or other binary library required.
  • Shown in a lightweight WindowDialog that polls for the token on a background thread.
  • Fallback: any problem with the QR path (render failure, an image-less skin, an exception building the window) falls back to the existing text-only DialogProgress flow, which is preserved unchanged, so login still works everywhere. Polling, slow_down, cancel, expiry and Kodi-shutdown handling are shared by both paths.

Changes

  • routes/device_login.py — QR window + shared poller, text flow kept as fallback.
  • addon/qr.py (new) — QR→PNG rendering.
  • addon/vendor/qrcodegen.py (new, vendored, MIT) + addon/vendor/__init__.py.
  • New strings #30334#30336.

Backward compatibility

Additive; no settings or stored-token changes. Falls back to the current text flow on any device where the QR window can't be shown.

New strings

  • #30334 "Scan the QR code, or go to [B]%s[/B]"
  • #30335 "Enter this code: [B]%s[/B]"
  • #30336 "Waiting for authorization... (press Back to cancel)"

Testing

  • QR window shows; scanning it completes sign-in (regular login)
  • Same for the private (Turbo) login
  • Back/cancel and code-expiry behave correctly
  • Text fallback still works (e.g. force a QR-render failure)

Note: the vendored qrcodegen.py accounts for most of the diff size.
Independent of my other two PRs.

The device-code login now displays a scannable QR code of the Twitch
activation URL alongside the short user code, so viewers can sign in by
pointing their phone camera at the TV instead of typing a URL. Both the
regular and the private (Turbo/ad-free) login get this, since they share
do_device_login().

The QR is rendered dependency-free: a vendored QR generator (Project
Nayuki, MIT) produces the module matrix and a tiny zlib-based PNG writer
emits the image, so no PIL/Pillow or other binary library is required. It
is shown in a lightweight WindowDialog that polls in a background thread.

Anything that can go wrong with the QR path (rendering failure, an
image-less skin, an exception building the window) falls back to the
previous text-only DialogProgress flow, which is preserved unchanged, so
login still works everywhere. Polling, slow_down handling, cancel, expiry
and Kodi-shutdown behaviour are shared between both paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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