Skip to content

Adds XTC support#31

Open
Joe-K2018 wants to merge 1 commit into
crosspoint-reader:masterfrom
Joe-K2018:add-xtc-support
Open

Adds XTC support#31
Joe-K2018 wants to merge 1 commit into
crosspoint-reader:masterfrom
Joe-K2018:add-xtc-support

Conversation

@Joe-K2018
Copy link
Copy Markdown

Crosspoint can display EPUB and XTC files but previously only EPUB files could be sent from Calibre to Crosspoint devices using this plugin. This adds XTC support for sending to Crosspoint devices.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR extends CrossPoint Reader plugin to support XTC files in addition to EPUB. The device driver version was bumped, supported format declarations were expanded, file listing logic was updated to include XTC files, and documentation was clarified to reflect dual format support.

Changes

XTC Format Support for CrossPoint Reader

Layer / File(s) Summary
Driver format support and file listing
crosspoint_reader/driver.py
Device version incremented to 0.1.5. Format constants FORMATS and ALL_FORMATS expanded from ['epub'] to ['epub', 'xtc']. The _list_files_recursive method docstring updated and file filtering logic changed from isEpub to isEpub OR isXTC to include both file types in device listings.
Documentation updates
README.md, crosspoint_reader/README.md
Plugin descriptions updated to clarify that both EPUB and XTC files are uploaded to CrossPoint Reader over WebSocket, reflecting the expanded format support.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'Adds XTC support' directly and clearly summarizes the main change—extending the plugin to support XTC files in addition to EPUB files.
Description check ✅ Passed The description clearly explains the context and purpose of the changes: the plugin previously only supported EPUB but now adds XTC support for sending files to Crosspoint devices.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
crosspoint_reader/driver.py (2)

410-416: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Temp file always uses '.epub' suffix regardless of actual file type.

The _download_temp method hardcodes suffix='.epub' even when downloading XTC files. This could cause issues with metadata extraction or other tools that rely on file extensions.

🔧 Proposed fix to use correct suffix based on file extension
-    def _download_temp(self, path):
+    def _download_temp(self, path, suffix=None):
         from calibre.ptempfile import PersistentTemporaryFile
-        tf = PersistentTemporaryFile(suffix='.epub')
+        if suffix is None:
+            suffix = os.path.splitext(path)[1] or '.epub'
+        tf = PersistentTemporaryFile(suffix=suffix)
         self.get_file(path, tf)
         tf.flush()
         tf.seek(0)

Then update the call site on line 188 if needed, or rely on the automatic suffix detection from the path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crosspoint_reader/driver.py` around lines 410 - 416, The _download_temp
function always creates a PersistentTemporaryFile with suffix='.epub', which is
incorrect for XTC or other file types; change it to derive the suffix from the
incoming path (e.g., take the extension from path and pass suffix=f'.{ext}' or
omit suffix to let the OS choose) when creating PersistentTemporaryFile in
_download_temp, ensure you still call self.get_file(path, tf), flush and seek as
before, and if any callers (e.g., the call site referenced in the review) assume
'.epub' adjust them to handle the actual suffix or rely on automatic detection.

184-194: ⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

Fix hardcoded stream_type='epub' when reading metadata for non-EPUB inputs (e.g., XTC)

  • The code always calls Calibre get_metadata(..., stream_type='epub', ...), so when processing XTC it will force the EPUB metadata reader path.
  • Calibre’s get_metadata dispatcher does not provide any support/remapping for stream_type='xtc' (no xtc reader path in the dispatcher), so changing the call to stream_type='xtc' won’t solve it.
  • Adjust the logic to use a Calibre-supported stream_type for XTC, or avoid forcing stream_type and ensure Calibre can autodetect from the temp file type (so metadata isn’t dropped into the exception handler when fetch_metadata is enabled).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crosspoint_reader/driver.py` around lines 184 - 194, The metadata reader is
forcing stream_type='epub' in the fetch_metadata block which breaks non‑EPUB
inputs (e.g., XTC); update the logic in the fetch_metadata branch that calls
get_metadata to either omit the stream_type argument so Calibre will autodetect
from the temp file created by _download_temp(lpath), or choose a
Calibre‑supported stream_type based on the input extension (inspect lpath
suffix/mime) before calling get_metadata; keep the existing quick_metadata
context and preserve the current exception logging via self._log if autodetect
still fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@crosspoint_reader/driver.py`:
- Around line 410-416: The _download_temp function always creates a
PersistentTemporaryFile with suffix='.epub', which is incorrect for XTC or other
file types; change it to derive the suffix from the incoming path (e.g., take
the extension from path and pass suffix=f'.{ext}' or omit suffix to let the OS
choose) when creating PersistentTemporaryFile in _download_temp, ensure you
still call self.get_file(path, tf), flush and seek as before, and if any callers
(e.g., the call site referenced in the review) assume '.epub' adjust them to
handle the actual suffix or rely on automatic detection.
- Around line 184-194: The metadata reader is forcing stream_type='epub' in the
fetch_metadata block which breaks non‑EPUB inputs (e.g., XTC); update the logic
in the fetch_metadata branch that calls get_metadata to either omit the
stream_type argument so Calibre will autodetect from the temp file created by
_download_temp(lpath), or choose a Calibre‑supported stream_type based on the
input extension (inspect lpath suffix/mime) before calling get_metadata; keep
the existing quick_metadata context and preserve the current exception logging
via self._log if autodetect still fails.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8329df17-8409-4325-ae4e-2329ade195e5

📥 Commits

Reviewing files that changed from the base of the PR and between 1877d96 and 39f29c1.

⛔ Files ignored due to path filters (2)
  • crosspoint_reader-v0.1.1.zip is excluded by !**/*.zip
  • crosspoint_reader-v0.1.5.zip is excluded by !**/*.zip
📒 Files selected for processing (3)
  • README.md
  • crosspoint_reader/README.md
  • crosspoint_reader/driver.py
📜 Review details
🧰 Additional context used
🪛 Ruff (0.15.14)
crosspoint_reader/driver.py

[warning] 27-27: Mutable default value for class attribute

(RUF012)


[warning] 28-28: Mutable default value for class attribute

(RUF012)


[warning] 29-29: Mutable default value for class attribute

(RUF012)


[warning] 31-31: Mutable default value for class attribute

(RUF012)


[warning] 32-32: Mutable default value for class attribute

(RUF012)

🔇 Additional comments (4)
crosspoint_reader/driver.py (2)

24-24: LGTM!

Also applies to: 31-32


154-154: ⚡ Quick win

Verify/correct the server’s XTC flag casing to ensure XTC files are included.

crosspoint_reader/driver.py checks entry.get('isXTC') (line 171) while there are no other isXtc/isxtc references in the repo. If the server/API returns a differently cased field (e.g., isXtc), XTC files won’t be listed—confirm the exact /api/files response field name and update the condition to match (or accept both casings).

README.md (1)

9-9: LGTM!

crosspoint_reader/README.md (1)

4-4: LGTM!

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