Skip to content

Replace jsoup with ksoup for HTML parsing - #57

Merged
andrikeev merged 1 commit into
masterfrom
claude/wizardly-gates-netx2r
Jun 23, 2026
Merged

andrikeev merged 1 commit into
masterfrom
claude/wizardly-gates-netx2r

Conversation

@andrikeev

Copy link
Copy Markdown
Owner

Summary

Replaces jsoup with ksoup (com.fleeksoft.ksoup), a Kotlin Multiplatform port of jsoup, and removes jsoup entirely from the project.

Changes

  • Version catalog (gradle/libs.versions.toml): drop jsoup 1.22.2, add ksoup 0.2.6.
  • Dependencies: switch libs.jsoup → libs.ksoup in :core:network:rutracker and :proxy.
  • Source (:core:network:rutracker parsers, 12 files):
    • org.jsoup.* → com.fleeksoft.ksoup.* imports.
    • Jsoup.parse(...) → Ksoup.parse(...).
    • Two small API differences adapted in ParsePostUseCase:
      • Tag.name (property) → Tag.name() (function)
      • TextNode.wholeText (property) → TextNode.getWholeText() (function)

The rest of the jsoup API (select, selectFirst, first/last, attr, text, hasClass, children, childNodes, remove, …) is identical in ksoup, so the parsing logic is otherwise untouched.

Behaviour compatibility

The main risk in this swap is Elements.first() / last(): the parsers rely on jsoup's null-on-empty semantics (rather than Kotlin's List.first(), which throws). Verified that ksoup's Nodes declares its own first()/last() members returning a nullable Element? (bytecode shows return null when empty), so behaviour is preserved.

Local verification

  • ./gradlew :core:network:rutracker:compileKotlin — ✅ compiles clean (the jsoup jspecify nullability warnings are also gone, since ksoup is pure Kotlin).
  • Temporary runtime smoke test (removed before commit) exercising Ksoup.parse, CSS selection, first()-null-on-empty, ParseTorrentStatusUseCase, and ParsePostUseCase (text/<br>/bold → getWholeText() + tag().name() paths) — all passed.
  • grep confirms zero remaining jsoup references.

Note: the full Android app build (:app:assembleDebug / lintDebug / testDebugUnitTest) was not run locally — it requires the Android SDK and the google-services.json secret, which aren't available in this environment. The change is contained to :core:network:rutracker (the only module that referenced jsoup) and its public API is unchanged, so downstream modules are unaffected at the source level. ksoup officially supports Android and pulls only small, pure-Kotlin, Android-safe transitive deps.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EPxhiZbmURTJvhRzAHcpGu


Generated by Claude Code

Swap the jsoup dependency for ksoup (com.fleeksoft.ksoup), a Kotlin
Multiplatform port of jsoup, and remove jsoup entirely.

- Version catalog: drop jsoup 1.22.2, add ksoup 0.2.6
- Switch the dependency in :core:network:rutracker and :proxy
- Migrate imports (org.jsoup.* -> com.fleeksoft.ksoup.*) and the
  Jsoup.parse entry point to Ksoup.parse across the rutracker parsers
- Adapt the two API differences: Tag.name() and TextNode.getWholeText()

ksoup's Elements API preserves jsoup's null-on-empty semantics for
first()/last(), so parsing behaviour is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EPxhiZbmURTJvhRzAHcpGu
@andrikeev
andrikeev marked this pull request as ready for review June 23, 2026 14:23
@andrikeev
andrikeev merged commit 54b9606 into master Jun 23, 2026
1 check passed
@andrikeev
andrikeev deleted the claude/wizardly-gates-netx2r branch June 23, 2026 14:30
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.

2 participants