Skip to content

About

Kodi add-on to sync watched status between multiple Kodi instances

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Watched Sync 0.4.2

Synchronize watched/unwatched status and resume points between two Kodi 21 Omega devices through an existing LAN SMB share. No cloud service, database server, pip installation, or additional server is required.

Status: automated checks pass; complete two-device and Chromecast validation is still pending. Treat this as a test build. The smaller target is Chromecast with Google TV 4K; Google TV Streamer uses the same protocol.

Behavior

  • Changes are committed to profile-local SQLite before attempting SMB delivery.
  • Each device publishes its own immutable batches with SHA-256 verification.
  • Pending transfers and capture jobs survive Kodi restarts. Unavailable SMB is retried with increasing delays, capped at five minutes.
  • Resume includes fractional seconds and duration. A forced exit/power cut can lose seconds Kodi had not saved yet.
  • Watched and resume merge independently. Concurrent edits to one field use a deterministic logical version; alternatives remain available in Review conflicts.
  • Existing meaningful history that conflicts during initial joining is held for review. Initial unwatched/zero defaults never erase another device's history.
  • Snapshots compact old batches without requiring both devices to stay online.
  • No shared mutable CSV, directory lock, or shared SQLite database is used.

The plugin synchronizes movies, episodes and music videos in the Kodi library. It does not synchronize manual bookmarks, full play counts, lastplayed, PVR, non-library files, or movie-version selection. Content matches by shared external IDs already stored in Kodi, falling back to an exact video path when no IDs are compatible. For that fallback, an IP address and a hostname are different. SMB credentials are removed from shared media paths; configure authentication in Kodi.

Build and automated checks

On a development computer with Python 3.8 or newer:

python -B -m unittest discover -s tests -p "test_*.py" -v
python -B tools/build_release.py

The ZIP is written to releases/service.watched.sync-0.4.2.zip. release.bat invokes the same builder on Windows. The ZIP contains only the addon files; tests, development tools and removed SQL dependencies are excluded.

CI is configured to run the suite on Python 3.8 and 3.12. Tests cover real local SQLite persistence, two-device convergence, network faults, corruption, restart, duplicate publication, compaction, Kodi integration boundaries and resource limits with 10,000 items. Tests do not require Kodi or access your SMB share.

Configure the test build

  1. Back up both Kodi profiles, including their video databases. Start with a small disposable library for the first device tests.
  2. Install the ZIP through Kodi's Install from zip file option.
  3. In the addon's settings, choose an SMB shared folder accessible by both Kodi devices. The account needs read/create/write/rename/delete permissions for files and directories in that folder.
  4. Enable Enable Sync Service on each device. The default is disabled.
  5. Start with the default 30-second shared-folder interval. Initial indexing proceeds in pages while Kodi is not playing video.
  6. Open the addon and check Status, then review any initial conflicts.

The service starts automatically with Kodi and observes the enable setting. After configuring the folder, enable the service and save with OK; Run is only needed to open the manual menu. Basic and Standard show the essential settings; Advanced and Expert also show the polling interval and sync subfolder options. The interval defaults to 30 seconds when left hidden. Settings use Kodi's version 1 format and retain the existing setting ids and values.

By default the addon creates watched-sync-v2/<unique-device-id>/ below the chosen SMB folder. Its SQLite file stays in the local addon profile. Install separately on each device; do not clone the live addon profile/device identity.

Already watched or partially watched movies and episodes ARE included on first run, without having to play or mark them again. The addon reads the Kodi library in pages of 50 and pauses during playback and Kodi library scans. Items with default unwatched/zero state are indexed locally but do not produce bootstrap events. Shared files are batches containing several items, not one file per movie/episode. Status shows reconciliation progress, completion, pauses or errors; Reread local watch history requests another pass. Content outside the Kodi video library is not included.

The SMB folder in the addon's Settings controls where synchronization documents are exchanged. It does not change the video paths already stored in Kodi's library. For example, changing the sync folder from an IP address to a hostname does not update episodes still indexed with the IP address. Shared content IDs allow those different video paths to match without changing Kodi's sources.

How content is identified

The addon reads provider IDs already saved in Kodi's uniqueid metadata. It does not contact TMDb, TVDb, IMDb or any other provider. There is no preferred provider: any shared, consistent provider + ID can match two library entries. Local Kodi database numbers (movieid, episodeid, tvshowid) are never used as portable identifiers. Titles and filenames are not guessed equivalent.

  • Movies can match any shared movie provider ID.
  • Episodes can match a shared episode provider ID, or a shared series provider ID + season + episode. Both libraries must use compatible episode numbering. Series and episode IDs have separate namespaces. Specials in season zero are supported; missing/zero episode numbers cannot form a series-based identity.
  • Without compatible IDs, matching requires the complete video path. If one library only has TMDb and the other only TVDb, the addon cannot translate between them; it falls back to the exact path. Music videos use this fallback because Kodi 21's music-video JSON-RPC fields do not expose uniqueid.
  • Conflicting IDs for the same provider, conflicting episode numbering, multiple possible local matches, or multiple library entries for one file block automatic imports. The addon does not choose an arbitrary edition or entry. Fix the metadata/duplicate entries in Kodi, then choose Reread local watch history.
  • An ID identifies the title/episode, not a specific cut. Exact resume seconds require equivalent versions of the video. Different cuts and multi-episode files are outside the supported matching model.

Open Content matching / Identificación del contenido in the addon menu to see counts of local entries with IDs, entries requiring exact paths, remote matches by ID/path, unmatched content and blocked matches. It also lists up to 20 identification problems and 20 local entries without usable IDs. Status shows a compact identification summary. Counts describe the current index and can change while the library is being read. History conflicts have a separate Review conflicts action; it does not override identification problems.

IDs are bounded to 16 per scope, validated and indexed in profile-local SQLite. Generic provider names are supported; empty, malformed and local/unknown IDs are ignored. Provider names are normalized to lowercase; opaque ID values keep their case, with numeric/IMDb normalization. Names or IDs with URLs, whitespace inside values or unsupported characters cannot become cross-device identities. TV-show ID lookups use a 64-show cache, cleared for each library pass. No media hashing, full-library Python dictionary or provider-network requests are added.

Updating from 0.3.x

Install 0.4.2 independently on both devices, keeping their existing final sync folder and local addon profiles. Do not delete the shared files or local history. Restart Kodi after installing so the background service loads the new code. Let the initial library pass finish without playing video, or request Reread local watch history if needed. Each device announces its existing authored history with the newly read IDs; the field versions and any already frozen transfer bytes remain unchanged. Metadata announcements add source sequence numbers so peers that already consumed older snapshots learn the IDs. New snapshots include the IDs too. Legacy documents remain readable.

Remote imports wait for a complete library pass and pending identity checks so a duplicate discovered on a later page cannot cause an early import. Ordinary capture/outgoing changes still work during playback. A full pass removes stale local index entries, while retaining authored history, outbox and shared files. The local SQLite schema becomes version 2; older addon versions cannot open it. Downgrading requires restoring the saved pre-upgrade addon profile.

Sequential changes and history notices in 0.4.1

Sequential means the second device received the first device's change before making its next edit. Two actions made at different real-world times can still be independent when the second device has not received the first edit. The addon cannot infer that order from playback position or unsynchronized device clocks.

Version 0.4.1 fixes false conflict notices caused by replaying an older ancestor after several sequential edits. Each field now carries bounded causal knowledge of observed versions, and repeated older versions do not create another notice. No provider/server calls or extra shared files are needed. Legacy documents remain readable; missing old causal information is not invented.

Status separates history requiring review, which blocks imports for that item, from retained alternatives, for which a deterministic state has already been selected. Review conflicts labels each category and shows the current synchronized value as a choice. Nonblocking notices also offer Dismiss notice without changing the synchronized state: this acknowledges only that local notice and does not publish an old playback position. Blocking initial-history differences still require an explicit state choice.

Since 0.4.2, each alternative also shows its original author: Local (this device) or Remote (device ID). The current synchronized choice shows its author too. Local/remote is relative to the Kodi where the menu is opened; both alternatives can be remote. Status shows this device's eight-character ID so the same ID can be identified on the other device. No device-name or network lookup is needed. An imported value keeps its original remote author.

Initial/reconciliation differences label the actual Kodi observation as local and retain the author of the compared history. Older notices recover authors only when their exact saved versions include that information. Value-only notices show Origin not recorded; neither the current winner nor a matching playback position is used to invent an origin. Provenance remains attached to the original alternatives even if the synchronized state subsequently changes.

Old notices are preserved during the update because earlier versions did not record enough causal detail to safely classify every existing alternative. They may include false positives from 0.4.0. Do not select an old position merely to clear a nonblocking notice; dismiss it to preserve the synchronized state.

Playback positions in the menu use HH:MM:SS. Fractional seconds remain stored and synchronized internally. Content matching also shows the last import whose values were confirmed by rereading Kodi. If that value is correct while the Kodi list still shows an older value, leave and reopen the list before restarting; this distinguishes a stale view from an import that has not completed. Restart Kodi after an addon update to load the new service code. Ordinary synchronization should not require restarting Kodi.

The home-screen widget can retain an older resume label even when the episode's detail view and actual playback use the newly synchronized position. This was observed in user testing between a Chromecast and Windows Kodi: after syncing to about five minutes, the home widget still displayed an earlier point, while opening Foundation's episode entry and resuming playback used five minutes. This observation confirms the stored resume change for that case; it does not identify the precise skin/widget cache responsible.

Kodi's episode update implementation already requests a GUI update. Dynamic widget lists also have their own refresh triggers. A generic Container.Refresh targets the active media listing and is not a universal widget-refresh API. The addon therefore keeps the normal Kodi update path and does not force skin reloads or library rescans after imports. When a widget appears stale, open the episode entry or inspect the last confirmed import in Content matching.

Synchronization groups

Advanced settings offer Create a sync subfolder (default on) and Sync subfolder name (default watched-sync-v2). Turn the first option off to write device directories directly in the selected SMB folder, or choose a custom name to separate synchronization groups. The name is one directory component, without slashes. With the option off, its name is ignored.

Both devices must resolve to the SAME final folder to synchronize. For example:

Selected SMB folder Create subfolder Name Final group folder
smb://nas/sync/ On family smb://nas/sync/family
smb://nas/sync/family/ Off Ignored smb://nas/sync/family
smb://nas/sync/ On private smb://nas/sync/private

The first two configurations share a group. The third is separate. Each Kodi profile uses one active group for its current library; these options do not automatically split one library into multiple simultaneous groups or filters.

Status displays the final folder, without URL credentials. Changing that folder selects separate local history/outbox and does not move or delete the old group's files. Switching back restores its pending changes. Keeping the default preserves the pre-0.3.2 device identity and outbox. Selecting the existing watched-sync-v2 folder directly with subfolder creation off also preserves that same group.

This version replaces the old CSV/MariaDB implementation. Existing watched_status.csv and sidecar files are neither read nor modified. Bootstrap uses the actual Kodi libraries. Stop the old version on both devices before using 0.3.0; old CSV history that is absent from Kodi needs separate migration.

Manual controls

  • Status: local indexed count, unsent changes, capture jobs, conflicts, reconciliation progress, final group folder and the last recorded network error.
  • Sync now: wake the service and request a fresh recovery checkpoint of published history. It queues a request rather than claiming a transfer has already succeeded.
  • Reread local watch history (formerly Reconcile local library): reread the watched states and resume points already saved in this Kodi library and compare them with the addon's local history. Useful after edits made while the service was stopped. The service processes 50 items per page while video playback is stopped. This reads existing library entries; it does not scan media folders, download metadata, rebuild Kodi's library, or fix missing or incorrect metadata in Kodi. It refreshes available content IDs; without compatible IDs, exact video paths must still match. Detected changes are queued for synchronization; ambiguous negative resets require conflict review. See progress in Status.
  • Review conflicts: choose which alternative to keep, one field at a time. An explicit state choice becomes a new durable local event and is replicated. Nonblocking retained alternatives can instead be dismissed locally while preserving the synchronized state. Initial blocked history cannot be dismissed.
  • Settings: open the addon's settings directly, including when no SMB folder is configured. The menu uses Kodi's selected language (English/Spanish).
  • Content matching: inspect the identification rules, actual match counts, blocked/unmatched entries and examples requiring the exact video path.

Manual operations require the background service to be enabled for network work. Disabling the service stops capture and new network work; existing local pending changes remain. A native VFS call already in progress has no cancellation API and can still delay Kodi teardown until its network timeout.

Resource budget

There is one network worker. Library pages contain 50 items, delta batches up to 32 records, snapshot pages up to 128 records, and no document exceeds 64 KiB. VFS I/O uses 16 KiB chunks. The local SQLite cache target is approximately 1 MiB. Full indexing/reconciliation, snapshot downloads, remote imports and compaction pause during video playback; event capture and outgoing deltas continue.

Reconciliation runs at startup, after library scans, on request and every six hours while idle. Initial indexing of a large library takes time. RAM usage is bounded by page/batch sizes, rather than loading all library items at once. Snapshot file count scales with the amount of meaningful history; current and previous snapshots are retained, with covered deltas removed after compaction.

Automated Python allocation measurements are not a substitute for checking CPU, total Kodi memory and playback behavior on the actual Chromecast 4K.

See protocol and failure boundaries and the device validation checklist.

About

Kodi add-on to sync watched status between multiple Kodi instances

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages