Skip to content

Import Watcharr JSON#1244

Open
JodliDev wants to merge 6 commits intoFuzzyGrim:devfrom
JodliDev:import_watcharr
Open

Import Watcharr JSON#1244
JodliDev wants to merge 6 commits intoFuzzyGrim:devfrom
JodliDev:import_watcharr

Conversation

@JodliDev
Copy link
Copy Markdown

@JodliDev JodliDev commented Mar 9, 2026

This adds an option to import the exported JSON from https://github.com/sbondCo/Watcharr
It only imports the "final" state of each entry. So even though the activity for each entry can be found in the Watcharr JSON, I opted to ignore it for now.

The implementation reuses the basic YamtrackImporter and just reformats the data from JSON into CSV.

I mainly wrote this for myself but extended it as a PR to hopefully be helpful for others too.
Thank you for this great project btw! :)

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new feature enabling users to import their media tracking data from Watcharr JSON exports. It efficiently reuses the existing YamtrackImporter by transforming the Watcharr JSON structure into a compatible format, specifically focusing on importing the final state of each entry. This enhancement provides users with increased flexibility in migrating their media consumption history into the application.

Highlights

  • New Watcharr JSON Import: Implemented a new functionality to import media tracking data from Watcharr JSON exports.
  • Dependency Added: Introduced python-dateutil as a new dependency to facilitate robust date and time string parsing.
  • YamtrackImporter Refactoring: Refactored the YamtrackImporter to extract data iteration logic into a new get_iterator method, allowing for greater flexibility and reuse with different input formats like JSON.
  • Integration and UI: Added a dedicated Celery task, URL endpoint, and view function for processing Watcharr JSON imports, along with corresponding updates to the user interface for file uploads.
  • Testing and Mock Data: Included comprehensive test cases and mock JSON data to ensure the correct functionality and data mapping of the Watcharr import process.
Changelog
  • requirements.txt
    • Added python-dateutil dependency for robust date parsing.
  • src/integrations/imports/watcharr.py
    • Added a new Python module to handle Watcharr JSON imports, including state conversion and data reformatting for the YamtrackImporter.
  • src/integrations/imports/yamtrack.py
    • Refactored the YamtrackImporter to extract the data iteration logic into a new get_iterator method, making it extensible for different input formats.
  • src/integrations/tasks.py
    • Registered a new Celery task, import_watcharr, to asynchronously process Watcharr JSON file imports.
  • src/integrations/tests/imports/test_watcharr.py
    • Added a new test file with a TestCase to verify the correct import and counting of media types from Watcharr JSON data.
  • src/integrations/tests/mock_data/import_watcharr.json
    • Included a mock JSON file containing sample Watcharr export data for testing purposes.
  • src/integrations/urls.py
    • Added a new URL pattern, /import/watcharr, to expose the Watcharr import functionality via a web endpoint.
  • src/integrations/views.py
    • Implemented the import_watcharr view function to handle file uploads and queue the Celery task for Watcharr JSON imports.
  • src/templates/users/import_data.html
    • Integrated a new form section into the import data page, allowing users to upload their Watcharr JSON files.
  • src/users/models.py
    • Updated the get_import_tasks method to include 'Watcharr' as a recognized import source.
  • src/users/templatetags/user_tags.py
    • Added 'Watcharr' to the SOURCE_DISPLAY_INFO dictionary, providing its name and logo path for UI display.
Activity
  • JodliDev created the pull request titled "Import Watcharr JSON" with a description outlining the new import functionality for Watcharr JSON exports, noting it reuses the YamtrackImporter and focuses on final states.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new importer for Watcharr JSON exports, which is a great addition. The implementation is well-structured, reusing the existing YamtrackImporter by refactoring it to be more extensible. The changes are consistent with the project's patterns for importers, including adding a Celery task, URL, view, and UI components. The new tests cover the basic import counts. My review includes a few suggestions for improvement, such as pinning the new dependency, enhancing error messages, making the tests more comprehensive, and some minor code simplifications and fixes.

@66Bunz
Copy link
Copy Markdown
Contributor

66Bunz commented Mar 9, 2026

Just wanted to ask the format of the Watcharr dates, because I think that importing the whole python-dateutil module might be a bit overkill. Maybe the same result could be reached using the default libraries?

@JodliDev
Copy link
Copy Markdown
Author

Yes, good point. It should definitely be possible with standard library. My python game is just a bit rusty and I was going safe rather than sorry :)

From what I can see, the format of watcharr is also ISO 8601 but with the Z notation instead of "+00:00" and an undefined number of digits for the fractional seconds (e.g. 2024-07-26T15:16:49.6934216Z or 2024-08-02T20:22:57.407627351Z). So simple string manipulation should do the trick.
I will push a commit

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