Skip to content

Commit c3aa8a7

Browse files
committed
TautulliPython2Trakt v1.0.0
TautulliPython2Trakt v1.0.0 Python script to scrobble what you watch, sync your collected movies and TV shows from [Tautulli](https://github.com/Tautulli/Tautulli) to [Trakt.tv](https://trakt.tv/).
1 parent 1a34a11 commit c3aa8a7

13 files changed

Lines changed: 1337 additions & 2 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.env
2+
log.txt
3+
ratingkeys.db
4+
__pycache__/

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"[python]": {
3+
"editor.defaultFormatter": "ms-python.black-formatter"
4+
},
5+
"python.formatting.provider": "none"
6+
}

Pipfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
requests = "==2.31.0"
8+
python-dotenv = "==1.0.0"
9+
plexapi = "==4.14.0"
10+
certifi = "==2023.7.22"
11+
charset-normalizer = "==3.2.0"
12+
idna = "==3.4"
13+
urllib3 = "==2.0.4"
14+
15+
[dev-packages]
16+
17+
[requires]
18+
python_version = "3.11"

Pipfile.lock

Lines changed: 150 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,132 @@
1-
# TautulliPython2Trakt
2-
Python script to send Tautulli notifications to Trakt
1+
<p align="center">
2+
<a href="https://github.com/TheGeeKing/TautulliPython2Trakt">
3+
<img src="image.png" alt="TautulliPython2Trakt's logo" width="80" height="80">
4+
</a>
5+
<h1 align="center">Tautulli Python 2 Trakt</h1>
6+
</p>
7+
8+
<h2> Table of Contents </h2>
9+
10+
- [Description](#description)
11+
- [What it can do](#what-it-can-do)
12+
- [Requirements](#requirements)
13+
- [Installation](#installation)
14+
- [Script Setup](#script-setup)
15+
- [Tautulli Setup](#tautulli-setup)
16+
- [Scrobbling](#scrobbling)
17+
- [Collection](#collection)
18+
- [Usage](#usage)
19+
- [More info](#more-info)
20+
- [Similar Projects](#similar-projects)
21+
22+
## Description
23+
24+
Python script to scrobble what you watch, sync your collected movies and TV shows from [Tautulli](https://github.com/Tautulli/Tautulli) to [Trakt.tv](https://trakt.tv/).
25+
26+
## What it can do
27+
28+
- Track watched status of movies and TV shows
29+
- Sync collected movies and TV shows to Trakt.tv
30+
31+
## Requirements
32+
33+
- Tautulli 2.12.5 or higher
34+
- Python 3.11 or higher
35+
- install requirements.txt
36+
1. `pip install -r requirements.txt`
37+
38+
## Installation
39+
40+
### Script Setup
41+
42+
Download the latest release from [here](https://github.com/TheGeeKing/TautulliPython2Trakt/releases), unzip it and place all files in a folder.
43+
44+
Create a new [application](https://trakt.tv/oauth/applications) Add the follow settings:
45+
46+
**Name:** `TautulliPython2Trakt` **Redirect uri:** `urn:ietf:wg:oauth:2.0:oob` **Permissions:** `/scrobble`
47+
48+
Run the script:
49+
50+
```bash
51+
python TautulliPython2Trakt.py -setup
52+
```
53+
54+
Follow the setup steps.
55+
56+
If you want to collect your movies and TV shows, you need to do the Plex Media Server setup! You might also want to add credentials/token to access your Plex Media Server as this can help to scrobble the correct episode to Trakt.tv if you don't use the TMDB database for sorting your shows. [How to find my token ?](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/)
57+
58+
### Tautulli Setup
59+
60+
#### Scrobbling
61+
62+
1. Go to Tautulli > `Settings` > `Notification Agents` > `Add a new notification agent` > `Script`
63+
2. Set the `Script Folder` to the folder where you placed the script, then select the script `TautulliPython2Trakt.py` in the `Script File` field. Put the `Script Timeout` to `0`.
64+
3. In the `Triggers` section, select:
65+
1. `Playback Start`
66+
2. `Playback Stop`
67+
3. `Playback Pause`
68+
4. `Playback Resume`
69+
5. `Watched`
70+
4. Put conditions if you want to, like username, media type, etc.
71+
5. In the `Arguments` tab, put the following arguments:
72+
1. Playback Start / Playback Resume: `pythonw -m {media_type} -s "{show_name}" -M "{title}" -y "{year}" -t "{thetvdb_id}" -i "{imdb_id}" -r {rating_key} -S {season_num} -E {episode_num} -P {progress_percent} -a start -PlexUser {username}`
73+
2. Playback Stop / Watched: `pythonw -m {media_type} -s "{show_name}" -M "{title}" -y "{year}" -t "{thetvdb_id}" -i "{imdb_id}" -r {rating_key} -S {season_num} -E {episode_num} -P {progress_percent} -a stop -PlexUser {username}`
74+
3. Playback Pause: `pythonw -m {media_type} -s "{show_name}" -M "{title}" -y "{year}" -t "{thetvdb_id}" -i "{imdb_id}" -r {rating_key} -S {season_num} -E {episode_num} -P {progress_percent} -a pause -PlexUser {username}`
75+
76+
#### Collection
77+
78+
1. Go to Tautulli > `Settings` > `Notification Agents` > `Add a new notification agent` > `Script`.
79+
2. Set the `Script Folder` to the folder where you placed the script, then select the script `TautulliPython2Trakt.py` in the `Script File` field. Put the `Script Timeout` to `0`.
80+
3. In the `Triggers` section, select `Recently Added`.
81+
4. Put conditions if you want to, like media type, etc.
82+
5. In the `Arguments` tab, put the following argument:
83+
1. Recently Added: `<movie>pythonw -c movies -PlexUser {username}</movie><episode>pythonw -c episodes -PlexUser {username}</episode><season>pythonw -c episodes -PlexUser {username}</season><show>pythonw -c episodes -PlexUser {username}</show>`
84+
85+
## Usage
86+
87+
```
88+
-h Help
89+
-setup Setup aplication
90+
-reset Reset settings and revoke token
91+
-refreshToken Refreshes the Trakt token
92+
-add Add a new Plex user
93+
-remove Remove a Plex user
94+
95+
------------------ Trakt Scrobbling ------------------
96+
-m Media type (movie, show, episode)
97+
-a Action (start, pause, stop)
98+
-s Name of the TV Series
99+
-M Name of the Moviename
100+
-y Year of the movie/TV Show
101+
-S Season number
102+
-E Episode number
103+
-t TVDB ID
104+
-i IMDB ID
105+
-r ratingKey (Plex Server internal content id)
106+
-P Percentage progress (Ex: 10.0)
107+
-PlexUser The Plex username
108+
109+
------------------ Trakt Collection ------------------
110+
-c Media type (movies, episodes)
111+
-PlexUser The Plex username
112+
```
113+
114+
## More info
115+
116+
Default scrobbler behavior is for:
117+
118+
- Movies, the data from Tautulli is sent directly to Trakt.
119+
- Episodes:
120+
- If your Plex Media Server is connected, we get the ratingkey from the data sent by Tautulli. We make a database filled with ratingkey paired to ids. We search for the ids linked to the ratingkey in the database. We send the ids to Trakt. Trakt.tv uses TMDB database, so sending basic info like season and episode number can mismatch with your plex configuration. This way we ensure that the episode is scrobbled to the correct one on the Trakt end.
121+
- If you are not connected to your Plex Media Server, we send the data from Tautulli directly to Trakt.
122+
123+
## Similar Projects
124+
125+
Inspired from: https://github.com/frugglehost/TautulliBatch2Trakt
126+
127+
- https://github.com/JvSomeren/tautulli-watched-sync
128+
- https://github.com/xanderstrike/goplaxt
129+
- https://github.com/gazpachoking/trex
130+
- https://github.com/dabiggm0e/plextrakt
131+
- https://github.com/trakt/Plex-Trakt-Scrobbler
132+
- https://github.com/Generator/tautulli2trakt

0 commit comments

Comments
 (0)