{"id":17788447,"url":"https://github.com/purarue/traktexport","last_synced_at":"2025-07-15T06:42:46.461Z","repository":{"id":49753526,"uuid":"351957394","full_name":"purarue/traktexport","owner":"purarue","description":"Export your movie/tv show ratings and history from trakt.tv","archived":false,"fork":false,"pushed_at":"2025-02-01T08:41:42.000Z","size":65,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T13:48:16.400Z","etag":null,"topics":["export","imdb","movies","trakt","trakt-tv"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/traktexport/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purarue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-27T01:48:58.000Z","updated_at":"2025-03-05T22:36:43.000Z","dependencies_parsed_at":"2024-10-27T10:27:53.147Z","dependency_job_id":"7c7f90c5-362c-4429-a2e0-f7ae3527812d","html_url":"https://github.com/purarue/traktexport","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":0.07407407407407407,"last_synced_commit":"a67a67b47603290f947d5c04740a34f09e7043bb"},"previous_names":["seanbreckenridge/traktexport"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Ftraktexport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Ftraktexport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Ftraktexport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Ftraktexport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purarue","download_url":"https://codeload.github.com/purarue/traktexport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809844,"owners_count":20351406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["export","imdb","movies","trakt","trakt-tv"],"created_at":"2024-10-27T10:19:10.177Z","updated_at":"2025-03-16T09:33:10.357Z","avatar_url":"https://github.com/purarue.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# traktexport\n\nExport your Movie/TV shows ratings and history from https://trakt.tv/\n\nThis isn't meant to be used to re-import info back into Trakt or export to another site, its just meant to save all my data so I have it locally, and can do analysis or graph my history (e.g., on [my feed](https://purarue.xyz/feed/?order_by=when\u0026sort=desc\u0026ftype=trakt_history_episode%2Ctrakt_history_movie))\n\nThis is also used internally in [trakt-watch](https://github.com/purarue/trakt-watch/tree/main), a small CLI to let you mark episodes/movies as watched on Trakt\n\n## Installation\n\nRequires `python3.8+`\n\nTo install with pip, run:\n\n    pip install traktexport\n\n## Usage\n\n```\nUsage: traktexport [OPTIONS] COMMAND [ARGS]...\n\n  Export data from your Trakt account\n\nOptions:\n  --help  Show this message and exit.\n\nCommands:\n  auth            setup authentication\n  export          run an account export\n  inspect         read/interact with an export file\n  merge           merge multiple exports\n  partial_export  run a partial export\n```\n\n### Auth\n\nThis uses OAuth to authenticate with the Trakt API, see [here](https://glensc.github.io/python-pytrakt/getstarted.html#oauth-auth) for more info.\n\nThis requires a manual setup the first time you use it, after which credentials are stored and this can run without any interaction.\n\n### Setup\n\n- Go to \u003chttps://trakt.tv/oauth/applications\u003e and create a new application\n- Use `urn:ietf:wg:oauth:2.0:oob` for the Redirect URI\n- Run `traktexport auth yourTraktUsername`\n- Follow the instructions, pasting in your Client ID/Secret from the Trakt dashboard, going to the link and pasting the generated pin back into the terminal\n\nOnce you've done that, this saves OAuth refresh info in `${XDG_DATA_HOME:-$HOME/.local/share}/traktexport.json` (can overwrite location with the `TRAKTEXPORT_CFG` environment variable)\n\n### Export\n\nThen, to export all your ratings/movies/shows, run:\n\n`traktexport export yourTraktUsername \u003e data.json`\n\nThe results are printed to STDOUT, so `\u003e data.json` saves it to `data.json`\n\n```\n$ python3 -m traktexport export yourTraktUsername \u003e data.json\n[D 210326 18:42:43 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/followers'...\n[D 210326 18:42:45 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/following'...\n[D 210326 18:42:48 export:32] Requesting 'https://api-v2launch.trakt.tv/users/settings'...\n[D 210326 18:42:51 export:32] Requesting 'https://api-v2launch.trakt.tv/users/likes'...\n[D 210326 18:42:54 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername'...\n[D 210326 18:42:56 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/comments'...\n[D 210326 18:42:59 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/lists'...\n[D 210326 18:43:01 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/ratings'...\n[D 210326 18:43:05 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/recommendations'...\n[D 210326 18:43:07 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/watchlist'...\n[D 210326 18:43:10 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/watched/movies'...\n[D 210326 18:43:13 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/watched/shows'...\n[D 210326 18:43:21 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/collection/movies'...\n[D 210326 18:43:23 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/collection/shows'...\n[D 210326 18:43:26 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/stats'...\n[D 210326 18:43:29 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/history?limit=100\u0026page=1'...\n[D 210326 18:43:31 export:44] First item: {'id': 7353545729, 'watched_at': '2021-03-22T06:33:24.000Z', 'action': 'watch', 'type': 'movie', 'movie': {'title': 'Rain Man', 'year': 1988, 'ids': {'trakt': 304, 'slug': 'rain-man-1988', 'imdb': 'tt0095953', 'tmdb': 380}}}\n[D 210326 18:43:31 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/history?limit=100\u0026page=2'...\n[D 210326 18:43:34 export:44] First item: {'id': 7178301624, 'watched_at': '2021-01-23T04:25:15.000Z', 'action': 'watch', 'type': 'episode', 'episode': {'season': 7, 'number': 7, 'title': 'Dangerous Debt', 'ids': {'trakt': 2590748, 'tvdb': 7640571, 'imdb': 'tt9313956', 'tmdb': 2201892, 'tvrage': None}}, 'show': {'title': 'Star Wars: The Clone Wars', 'year': 2008, 'ids': {'trakt': 4170, 'slug': 'star-wars-the-clone-wars', 'tvdb': 83268, 'imdb': 'tt0458290', 'tmdb': 4194, 'tvrage': 19187}}}\n[D 210326 18:43:34 export:32] Requesting 'https://api-v2launch.trakt.tv/users/yourTraktUsername/history?limit=100\u0026page=3'...\n```\n\n#### Partial Export\n\nYou can also export a part of your recent history, instead of your entire history (as that tends to take a few minutes)\n\n```\nUsage: traktexport partial_export [OPTIONS] USERNAME\n\n  Run a partial history export - assumes authentication has already been setup\n\n  This exports your movie/TV show history from Trakt without all the other\n  attributes. You can specify --pages or --days to only request the first few\n  pages so this doesn't take ages to run.\n\n  The 'merge' command takes multiple partial exports (or full exports) and\n  merges them all together into a complete history\n\nOptions:\n  --pages INTEGER  Only request these many pages of your history\n  --days INTEGER   Request history till this many days ago\n  --help           Show this message and exit.\n```\n\nE.g. To export your most recent 100 watches, you can run `traktexport partial_export yourTraktUsername --pages 1`. To request till you have history from the last month, you can provide `--days 30`.\n\nThose can then all be combined by the `merge` command, like: `traktexport merge ~/data/trakt/*.json`\n\nTo do that in python, you can also do:\n\n```\nfrom traktexport.merge import read_and_merge_exports\nread_and_merge_exports([\"full_export.json\", \"partial_export.json\"])\n```\n\n### Inspect\n\n[`traktexport.dal`](./traktexport/dal.py) includes some code I use to parse the resulting JSON file into Python objects so its easier to manipulate\n\n```python\nclass TraktExport(NamedTuple):\n    username: str\n    followers: List[Follow]\n    following: List[Follow]\n    likes: List[Like]\n    stats: Dict[str, Any]\n    settings: Dict[str, Any]\n    watchlist: List[WatchListEntry]\n    ratings: List[Rating]\n    history: List[HistoryEntry]\n```\n\n```\npython3 -m traktexport inspect data.json\nUse 'data' to interact with the parsed TraktExport object\n\nIn [1]: data.history[0]\nOut[1]: HistoryEntry(history_id=7353545729, watched_at=datetime.datetime(2021, 3, 22, 13, 33, 24, tzinfo=datetime.timezone.utc), action='watch', media_type='movie', media_data=Movie(title='Rain Man', year=1988, ids=SiteIds(trakt_id=304, trakt_slug='rain-man-1988', imdb_id='tt0095953', tmdb_id=380, tvdb_id=None, tvrage_id=None)))\n\nIn [2]: len(data.history)\nOut[2]: 16063\n\nIn [3]: data.stats[\"movies\"][\"plays\"]\nOut[3]: 1511\n```\n\nNote: This does include this info the export, but it doesn't currently parse:\n\n- collection\n- comments\n- lists\n- recommendations\n\n... because I don't have any of those on trakt. If you use those, a PR would be appreciated!\n\nCreated to use as part of [`HPI`](https://github.com/purarue/HPI)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurarue%2Ftraktexport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurarue%2Ftraktexport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurarue%2Ftraktexport/lists"}