Giter VIP home page Giter VIP logo

retraktarr's Introduction

MIT License GitHub issues GitHub pull requests GitHub stars Python Support

retraktarr

retraktarr is a "reverse" Trakt.tv list implementation for Radarr/Sonarr that creates Trakt.tv lists for your movies/series using APIs.

Introduction

retraktarr is a Python script to sync your Radarr/Sonarr library to a Trakt.tv list using the respective APIs.

The original idea stemmed from my wanting to have a list of monitored movies I could share with friends. This was to be the equivalent of a mdblist, but cherry-picked. Providing a more curated list of what I believed was worth considering to watch for downloading.

Uses

The goal was to add the list to Radarr, set up a filter for the list with Exists in Library and On Exclusion List = false, and allow friends to easily keep up to date with my recommended movies through the Discover tab.

This use case was admittedly very narrow, and a few more use cases have emerged since.

  • Backing up entire Radarr/Sonarr libraries, including movies/shows you do not already have downloaded. For example, if it's missing in Radarr, PlexTraktSync would not help.
  • Restoring your library easily by importing an entire (backed up) list (in the case of migrating OSs or catastrophic failures)
  • Giving someone the ability to browse media you have (without giving them access to Plex/Jellyfin/Emby)
  • Sync multiple instances of Sonarr/Radarr
  • Possibly more I have not considered...

Requirements

Arr Support

retraktarr supports both Radarr and Sonarr in sourcing the media to sync to your lists. You can specify either or both for syncing, as well as filter what should be added with CLI arguments.

retraktarr will need API access to whichever Arr(s) you intend to use.

Trakt.tv API App Setup

A Trakt.tv account with an API set up is obviously necessary.

  • 🚨Note: Trakt.tv lists have limits. You can read their official statement here🚨
  1. Head to Trakt.tv API App Setup Page
  2. Create a new application, you will only need to fill Name and RedirectURI
    • I suggest using https://google.com for your redirect URI. We will need to steal a parameter from the redirect to complete the OAuth2 process.
  3. After creating the application, click on it and you will see your Client ID, Client Secret, and an Authorize button.
  4. Click Authorize. Click Yes. You will be redirected to Google (or your URI) and in the URL bar you will see ?code= followed by 64 alphanumeric characters. Save this for now. This is your OAuth2 Authorization code.
  5. You can now complete the OAuth2 process when you're ready using the retraktarr.

Installing retraktarr

You can either download the source yourself or install the package from PyPI using the pip3 install retraktarr command.

Configuring retraktarr

retraktarr uses a config file, named retraktarr.conf (by default) to get many of its settings. However, some of these can be overridden with an argument you pass. You can run retraktarr at any time to see the available options.

To generate the config template, simply run retraktarr without a .conf file present. It will tell you exactly where the default config file was generated and it's location.

Open in your favorite text editor and complete the necessary details for your usage.

If you've never run retraktarr before, you will need to leave your oauth2_token and oauth2_refresh options blank and use the --oauth argument to complete the authorization process and automatically save your tokens. They will be automatically refreshed if a valid refresh token is available upon expiration.

Usage (CLI)

options:
  -h, --help            show this help message and exit
  --oauth OAUTH, -o OAUTH
                        Update OAuth2 Bearer Token. Accepts the auth code and requires valid Trakt config settings
                        (ex: -o CODE_HERE)
  --radarr, -r          Synchronize Radarr movies with Trakt.tv
  --sonarr, -s          Synchronize Sonarr series with Trakt.tv
  --all, -all, -a       Synchronize both Starr apps with Trakt.tv
  --mon, -m             Synchronize only monitored content with Trakt.tv
  --missing             Synchronize only missing Radarr content with Trakt.tv
  --qualityprofile QUALITYPROFILE, -qp QUALITYPROFILE
                        The quality profile you wish to sync to Trakt.tv
  --tag TAG, -t TAG     The arr tag you wish to sync to Trakt.tv
  --cat, -c             Add to the Trakt.tv list without deletion (concatenate/append to list)
  --list LIST, -l LIST  Specifies the Trakt.tv list name. (overrides config file settings)
  --wipe, -w            Erases the associated list and performs a sync (requires -all or -r/s)
  --privacy PRIVACY, -p PRIVACY
                        Specifies the Trakt.tv list privacy settings (private/friends/public - overrides config file
                        settings)
  --genre GENRE, -g GENRE
                        Specifies the genre(s) of content to add to your list (OR logic)
  --refresh             Forces a refresh_token exchange (oauth) and sets the config to a new tokens.
  --timeout TIMEOUT     Specifies the timeout in seconds to use for POST commands to Trakt.tv
  --version             Displays version information
  --config CONFIG       If a path is provided, retraktarr will use this config file, otherwise it outputs default config location.

Troubleshooting

  • If you are running from the source, you will need to run retraktarr.py in the root directory, and not in the retraktarr directory.
  • If you are having problems with old entries not being removed, feel free to use the -wipe command in addition, it will delete the entire contents of the list without deleting the list itself, and then resync.
  • If you want to sync multiple "filters" (tag, profile, etc) to one list, consider running multiple times with your filter arguments and the additional --cat/-c parameter.
  • Privacy can only be set when the list is first created, specifying privacy on an already created list will do nothing.
  • Unless a list is specified using -list - when you use --all or -r -s - each Arr will sync to the list specified in the config.conf file.
  • Using filtered syncs with -all is not generally recommended, consider chaining multiple runs.
  • Syncing an instance will only remove non-syncing media in its associated type. If you have a list with movies and TV added and run a Sonarr sync to it, it will only remove SHOWS that are not present in the sync. (excludes usage of --cat/-c)
  • If you repeatedly get the same movies reporting as deleted, but not actually deleting, this is almost certainly due to an outdated ID (usually TMDB) being associated with the movie on Trakt. Report it and give them the correct link. If after it's updated it does not fix it, create an issue with details.
  • If you're getting timeouts during runs, particularly during --wipe or large list processing, use the --timeout <sec> command. Default is 30, increase it until your list is processed completely.

retraktarr's People

Contributors

laur89 avatar zakkarry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

retraktarr's Issues

Trakt.tv 405 Error

I’m testing out the script for the first time and was able to successfully authenticate with Trakt on the first run. The config file was updated and shows the two tokens. However, when I run the script, I’m getting a 405 error after the validation of the config file. Not sure what I'm doing wrong.

~/.local/bin/retraktarr --oauth REDACTED

retraktarr v1.0.4
Validating Configuration File: /home/yms/.config/retraktarr.conf

Authorization Code:  REDACTED
Access Token:  REDACTED
Refresh Token:  REDACTED
Your configuration file was successfully updated with your access/refresh token.
CONFIG FILE ~/.config/retraktarr.conf
[Trakt]
client_id = REDACTED
client_secret = REDACTED
username = REDACTED
redirect_uri = https://google.com
oauth2_token = REDACTED
oauth2_refresh = REDACTED

[Radarr]
url = https://myradarrinstance
api_key = REDACTED
trakt_list = TestListMovies
trakt_list_privacy = private

[Sonarr]
url = https://mysonarrinstance
api_key = REDACTED
trakt_list = TestListShows
trakt_list_privacy = private
~/.local/bin/retraktarr -r --tag films -c

retraktarr v1.0.4
Validating Configuration File: /home/yms/.config/retraktarr.conf

Trakt.tv Error: Unexpected status code return: 405.

If there is a place where the debug logs are stored, I will happily look at those as well and pass them along. Thanks for any help you can provide.

feat(request): add argument to filter by "missing" status in arrs

Hello,

I am interested in using retraktarr to synchronize my Radarr and Sonarr lists with Trakt. I would like to request a feature that allows syncing only the items marked as "missing" in Radarr and Sonarr to the Trakt list. This feature would be invaluable for users like me who manage files on a seedbox and delete them post-transfer, ensuring that only the necessary "missing" movies and series are tracked and added to Trakt.

Thank you for considering this feature request!

AttributeError: 'NoneType' object has no attribute 'json'

Successfully created API OAuth with Trakt:

retraktarr v1.1.2
Validating Configuration File: C:\Users\user.config\retraktarr.conf

Authorization Code: eec3b49971b1911e#########d4fcd5e3dadaa5f5b38412d117d28
Access Token: 3a47e83dcc20c##############759b06703ee30079a7f7ebfe533a912f4
Refresh Token: 622929698cea7a##############a7b3c71951a738d65cf5bb
Your configuration file was successfully updated with your access/refresh token.

However, when I run retraktarr -r, it returns:

[Radarr]
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Scripts\retraktarr.exe_main
.py", line 7, in
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\retraktarr\retraktarr.py", line 174, in main
trakt_api.add_to_list(
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\retraktarr\api\trakt.py", line 500, in add_to_list
added_items = response.json()["added"][media_type.lower()]
^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'json'

Radarr error

I been using this script to make backups without a problem, but today i get this error

retraktarr -a

retraktarr v1.1.2
Validating Configuration File: /home/med/.config/retraktarr.conf

[Radarr]
Traceback (most recent call last):
File "/home/med/.local/bin/retraktarr", line 8, in
sys.exit(main())
^^^^^^
File "/home/med/.local/lib/python3.12/site-packages/retraktarr/retraktarr.py", line 174, in main
trakt_api.add_to_list(
File "/home/med/.local/lib/python3.12/site-packages/retraktarr/api/trakt.py", line 469, in add_to_list
needed_ids = self.del_from_list(
^^^^^^^^^^^^^^^^^^^
File "/home/med/.local/lib/python3.12/site-packages/retraktarr/api/trakt.py", line 323, in del_from_list
data[media_type.rstrip("s")]["ids"].get(
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'movie'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.