Coder Social home page Coder Social logo

radarrsync's Introduction

RadarrSync

Syncs two Radarr servers through web API.

Why

Many Plex servers choke if you try to transcode 4K files. To address this a common approach is to keep a 4k and a 1080/720 version in seperate libraries.

Radarr does not support saving files to different folder roots for different quality profiles. To save 4K files to a seperate library in plex you must run two Radarr servers. This script looks for movies with a quality setting of 4k on one server and creates the movies on a second server.

Configuration

  1. Edit the Config.txt file and enter your servers URLs and API keys for each server.

    Example Config.txt:

    [Radarr]
    url = https://example.com:443
    key = FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8
    
    [Radarr4k]
    url = http://127.0.0.1:8080
    key = FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8
  2. Edit 4K profile on the server that will download 1080/720p files. You want the quality profile to download the highest non-4k quality your Plex server can stream with choking.

How to Run

Recomended to run using cron every 15 minutes or an interval of your preference.

python RadarSync.py

Requirements

  • Python 3.4 or greater
  • 2x Radarr servers
  • Install requirements.txt

Notes

  • Ensure that the root path is the same on both servers. ie /movies

radarrsync's People

Contributors

fryfrog avatar funkypenguin avatar hjone72 avatar sperryfreak01 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar

radarrsync's Issues

Unable to get script to run

so i installed the extra instance its up and running. port is 9000 on the 4k server and 7878 on the main. I only have one profile so its set at 1.

main server is set at 12.0.0.1
4k server set at *
i basically left everything default

I run the script with " python3 sudo python3 RadarrSync.py and i get this

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 453, in wrap_socket
cnx.do_handshake()
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1915, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1647, in _raise_ssl_error
_raise_current_error()
File "/usr/lib/python3/dist-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl3_get_record', 'wrong version number')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 841, in validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 344, in connect
ssl_context=context)
File "/usr/lib/python3/dist-packages/urllib3/util/ssl
.py", line 357, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 459, in wrap_socket
raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_record', 'wrong version number')])",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='127.0.0.1', port=7878): Max retries exceeded with url: /api/movie?apikey=FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_record', 'wrong version number')])")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "RadarrSync.py", line 55, in
radarrMovies = radarrSession.get('{0}/api/movie?apikey={1}'.format(radarr_url, radarr_key))
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='127.0.0.1', port=7878): Max retries exceeded with url: /api/movie?apikey=FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_record', 'wrong version number')])")))

RadarrSync adding every single movie to 4K Radarr

Describe the bug
I use UnRAID v6.8.3
Docker version 19.03.5
RadarrSync: latest
Docker mount points for both: /data

I just spun up a RadarrSync container, and set it up with my normal Radarr URL + API and my 4K Radarr + API + Profile ID.

In my standard Radarr I have a profile called “Best Available” - that is ID 7. This is the profile I use for movies I want to grab 1080p versions of and then also send to 4K Radarr.
image

I also have another profile “Only 1080p” (profile ID 4) for movies that I don’t want to send to my 4K Radarr. I also confirmed the profile IDs in both Radarr and Radarr 4K databases using DB browser for SQLite.

I also use the custom format options just for tighter control on matching:

Custom Formats for "Best Available" in normal Radarr Profile ID 7
image

However, this is not working ... all my movies in both “Best Available” and “Only 1080p” are getting sent to Radarr 4K, which is not the expected behavior.

Expected behavior
Expected behavior is for it to honor the profile with the corresponding Profile ID set in the containers Radarr 4K setting, and only pass movies through to 4K Radarr when that profile is selected. Movies with other profiles should be excluded.

Configuration
Docker version doesn't have a config.txt file.
Just uses container variables to pass through to RadarrSync.py

image

Logs
No useful debug info at all in output.txt - unless there is a way to enable a debug output?

2020-06-14 17:45:29,949 [MainThread ] [INFO ] adding John Dies at the End to server
2020-06-14 17:45:30,508 [MainThread ] [INFO ] adding Johnny English to server
2020-06-14 17:45:31,074 [MainThread ] [INFO ] adding Johnny English Reborn to server
2020-06-14 17:45:31,655 [MainThread ] [INFO ] adding Johnny English Strikes Again to server
2020-06-14 17:45:32,057 [MainThread ] [INFO ] adding Johnny Mnemonic to server
2020-06-14 17:45:32,431 [MainThread ] [INFO ] adding Joy to server
2020-06-14 17:45:32,867 [MainThread ] [INFO ] adding Judge Dredd to server
2020-06-14 17:45:33,356 [MainThread ] [INFO ] adding Juno to server
2020-06-14 17:45:33,750 [MainThread ] [INFO ] adding Jupiter Ascending to server
2020-06-14 17:45:34,135 [MainThread ] [INFO ] adding Just Getting Started to server
2020-06-14 17:45:34,644 [MainThread ] [INFO ] adding Just Go with It to server
2020-06-14 17:45:35,110 [MainThread ] [INFO ] adding Just Mercy to server
2020-06-14 17:45:35,509 [MainThread ] [INFO ] adding K-19: The Widowmaker to server
2020-06-14 17:45:35,923 [MainThread ] [INFO ] adding K-9 to server
2020-06-14 17:45:36,422 [MainThread ] [INFO ] adding The Bourne Identity to server
2020-06-14 17:45:36,811 [MainThread ] [INFO ] adding The Bourne Legacy to server
2020-06-14 17:45:37,202 [MainThread ] [INFO ] adding The Bourne Ultimatum to server
2020-06-14 17:45:37,729 [MainThread ] [INFO ] adding The Bourne Supremacy to server

Allow for movies to sync to a different destination profile

Today the profile from the primary or default server is used at the destination sync server as well. This means that an 'Ultra-HD' profile on the primary server can only be sync'd to an 'Ultra-HD' profile on the destination server.

Support should fail gracefully so if the user does not provide a destination status it defaults to using the profile from the primary server as it works today.

Unable to run RadarrSync configparser.NoSectionError: No section: 'Radarr'

Describe the bug
A clear and concise description of what the bug is.
Receiving the below when running RadarrSync.py
File "RadarrSync/RadarrSync.py", line 51, in
radarr_url = ConfigSectionMap("Radarr")['url']
File "RadarrSync/RadarrSync.py", line 29, in ConfigSectionMap
options = Config.options(section)
File "/usr/lib/python3.5/configparser.py", line 674, in options
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'Radarr'

To Reproduce
Steps to reproduce the behavior:
Running: python3 RadarrSync/RadarrSync.py

Expected behavior

Configuration
Please attach your configuration file (Config.txt), remember to remove any personal information (api key especially if your radarr install is accessible from the web)
[Radarr]
url = http://10.25.10.4:7878
key = APIKEY

[Radarr4K]
url = http://10.25.10.4:7879
key = APIKEY
profile = 1080P-UHD-REMUX-AA

Logs
Please include a log of the issue happening. Delete the Output.txt file, run RadarrSync and attache the new Output.txt file.

Don't see an Output.txt file in the directory.

Error when running for first time

When I run RadarrSync for the first time, I get the following error.

Traceback (most recent call last):
File "RadarrSync.py", line 3, in
import requests
ModuleNotFoundError: No module named 'requests'

Script Errors Out

Describe the bug
Can't run the script

To Reproduce
Edited the file, input my own radarr links, APIs and profiles

Expected behavior
When I run Config.txt, I get the following

Traceback (most recent call last):
File "RadarrSync.py", line 239, in
syncServer['url'] = ConfigSectionMap(syncServer['name'])['url']
KeyError: 'url'

However if I rename to DevConfig.txt, I get the following

Traceback (most recent call last):

File "RadarrSync.py", line 51, in

radarr_url = ConfigSectionMap("Radarr")['url']

File "RadarrSync.py", line 29, in ConfigSectionMap

options = Config.options(section)

File "/usr/lib/python3.6/configparser.py", line 675, in options

raise NoSectionError(section) from None

configparser.NoSectionError: No section: 'Radarr'

Configuration
[General]

[Radarr]
url = https://radarr.mydomain.ca
profile = HD

[Radarr4k]
url = https://radarr4k.mydomain.ca
destination_profile = UltraHD

Logs
Output.txt is empty if I run DevConfig.txt or run it as Config.txt

Elaborate on usage

Hey!

This seems to be what I need, but I'm not I understand how it's supposed to work. Maybe the docs could be clarified?

I'm starting to gather a bunch of 4K content and will use double radarr clients for this, but I'm unsure how this work. Will this script sync my 4K radarr 'watch list' with my 1080p radarr 'watch list'? I.e. I add whatever I want to grab to my 4K client and it will automatically sync that to the 1080p client so it'll fetch 1080p content aswell?

Thanks!

Script crashes on invalid Profile ID

Hi,

I am getting a python error when I run this script(and other forks of this script). But perhaps this may be to do with my python environment? I have not changed anything other than the profile id from 5 to 7 which is hardcoded in the script.

Traceback (most recent call last):
  File "RadarrSync.py", line 93, in <module>
    searchid.append(int(r.json()['id']))
TypeError: list indices must be integers or slices, not str

I am running the script with
python3 RadarrSync.py

Can I please have some help to get this running?

Thanks in advance :)

add way for users to see what would sync without syncing

I think the best way would be to create a sync report "Sync_Test.txt" or something like it


RadarrSync/RadarrSync.py

Lines 11 to 16 in d2a86ee

# TODO add way for users to see what would sync without syncing
# @body I think the best way would be to create a sync report "Sync_Test.txt" or something like it
WHAT_IF = True
# TODO move log level into config file


This issue was generated by todo based on a TODO comment in d2a86ee when #17 was merged. cc @Sperryfreak01.

Add AND search

You should modify the payload to add
'addOptions':{'searchForMovie':'true'},

And this should prob be a True/False option under [Radarr4k] or [Radarr] 'sections'.

Add --option to specify config location

It would be great if the config didn't need to live with the script.

For example, I'm making an AUR package for this and would like the script to live in /usr/lib/radarrsync or /usr/bin, but store the config in /var/lib/radarrsync or /etc.

Can't handle Unicode characters

When running the script, i get the following error below:

2018-04-17 15:44:00,709 [MainThread  ] [INFO ]  Starting new HTTP connection (1): 10.100.2.130
2018-04-17 15:44:01,023 [MainThread  ] [INFO ]  Starting new HTTP connection (1): 10.100.2.130
Traceback (most recent call last):
  File "RadarrSync.py", line 79, in <module>
    logging.debug('path: {0}'.format(movie['path']))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 31: ordinal not in range(128)

(That's the entire contents of the error log)

My guess is that it's due to the fact that i have movies that have non-ascii characters in the titles, such as "Alien³". Can you take a look?

Error upon running script

I get the following error when running the script.

Traceback (most recent call last):
File "radarrsync.py", line 254, in
sync_test = ConfigSectionMap('General')['sync_test']
File "radarrsync.py", line 19, in ConfigSectionMap
options = Config.options(section)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 675, in options
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'General'

Would you consider making this more generic?

Right now I understand it is specifically designed to handle 4k and 1080 videos. I want to basically do exactly the same thing but with Stereoscopic and Monoscopic.

Would you consider making this a bit more generic or adding options for different profiles to handle something like this?

Script Ran but not syncing

Hey man! I found your script while browsing Reddit for a solution two keeping my 2 Radarr instances in sync.

Right now, I have the script set up and the config info set correctly. However, when I try to run the script, the script errors out with:

Traceback (most recent call last): File "RadarrSync.py", line 54, in <module> radarr4k_url = ConfigSectionMap("Radarr4k")['url'] File "RadarrSync.py", line 28, in ConfigSectionMap options = Config.options(section) File "/usr/lib/python3.5/configparser.py", line 674, in options raise NoSectionError(section) from None configparser.NoSectionError: No section: 'Radarr4k'

I narrowed it down to the DEV=True line. When I switched it to false and ran the script, the script pauses for about a second, and then ends. there are no errors or logs or anything.

I'm running it on Ubuntu 16.04 with Python 3.5. I downloaded the GitHub repo as a zip and just unzipped it. I ran pip3 install -r requirements.txt before first running the script.

Any help on getting it working would be super duper appreciated!

Question: does this still work for Radarr v3?

I'd used this script for a long time with v2 and noticed today it hasn't been working for some time... I suspect because I migrated to v3 of Radarr, after which I just get 404 errors when running this script.

Can you confirm please? Thanks!

Add a --help option

It'd be really awesome if you could run the script w/ a --help option instead of having it barf because the config file isn't found.

$ python /usr/lib/radarrsync/RadarrSync.py --help
Traceback (most recent call last):
  File "/usr/lib/radarrsync/RadarrSync.py", line 215, in <module>
    radarrServer['url'] = ConfigSectionMap("Radarr")['url']
  File "/usr/lib/radarrsync/RadarrSync.py", line 19, in ConfigSectionMap
    options = Config.options(section)
  File "/usr/lib/python3.7/configparser.py", line 674, in options
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'Radarr'

subsequent runs do nothing

Describe the bug
subsequent runs of sync does nothing if you change to a different radarr instance or if there is an error

To Reproduce
run sync, let it complete

Remove all movies from 4k radarr instance

run sync again, it just ends with no error or msg

Expected behavior
syncs all content again

Configuration
[Radarr]
url = http://xxxxxx:7878
key = xxxxxx

[Radarr4k]
url = http://xxxxx:7874
key = xxxxx
profile = Ultra-HD

[General]

Logs
empty

Add Sonarr Support

I know this program is called RadarrSync but support for Sonarr would be nice. There is already a Fork of this script here that works, but it would be nice if the two maintained feature parity and support.

"ValueError: invalid literal for int() with base 10:"

Describe the bug
A clear and concise description of what the bug is.
Receiving "ValueError: invalid literal for int() with base 10: 'PROFILENAME'" when running RadarrSync.py

2018-10-13 20:59:36,223 [MainThread ] [INFO ] Starting new HTTP connection (1): 10.25.10.4
2018-10-13 20:59:36,958 [MainThread ] [INFO ] Starting new HTTP connection (1): 10.25.10.4
Traceback (most recent call last):
File "RadarrSync.py", line 89, in
if movie['profileId'] == int(ConfigSectionMap(server)['profile']):

To Reproduce
Steps to reproduce the behavior:
running the command python3 RadarrSync.py

Expected behavior
A clear and concise description of what you expected to happen.
Sync profile content between both Radarr instances.

Configuration
Please attach your configuration file (Config.txt), remember to remove any personal information (api key especially if your radarr install is accessible from the web)

[Radarr]
url = http://10.25.10.4:7878
key = APIKEY

[Radarr4k]
url = http://10.25.10.4:7879
key = APIKEY
profile = 1080P-UHD-REMUX-AA

Logs
Please include a log of the issue happening. Delete the Output.txt file, run RadarrSync and attache the new Output.txt file.

2018-10-13 20:59:36,223 [MainThread ] [INFO ] Starting new HTTP connection (1): 10.25.10.4
2018-10-13 20:59:36,958 [MainThread ] [INFO ] Starting new HTTP connection (1): 10.25.10.4

Radarr server error - response 401

Describe the bug
A clear and concise description of what the bug is.
Try to run the script and get this error
2020-05-23 22:23:38,167 [MainThread ] [ERROR] Radarr server error - response 401

To Reproduce
root@PEXTP02:~/RadarrSync# python RadarrSync.py
2020-05-23 22:23:38,167 [MainThread ] [ERROR] Radarr server error - response 401

Expected behavior
The script to work

Configuration
`[Radarr]
url = http://localhost:7878
key = 7cxxxxxxxxxxxx0a

[Radarr4k]
url = http://4kdarr:7878
key = 96xxxxxxxxxxxxxx8a9
profile = 5

`

Logs
root@PEXTP02:~/RadarrSync# cat Output.txt
2020-05-23 22:20:36,940 [MainThread ] [ERROR] Radarr server error - response 401
2020-05-23 22:22:45,464 [MainThread ] [ERROR] Radarr server error - response 401
2020-05-23 22:23:38,167 [MainThread ] [ERROR] Radarr server error - response 401

Running from directory other than the install dir results in error

Describe the bug

When trying to run the script from any other directory, other than where the configuration file is, the script fails, because it can not find the config. This makes running from cron rather difficult.

To Reproduce

  1. Install the script and configure.

  2. Attempt to run script using absolute path away from the install directory. python3 /path/to/script.py

Expected behavior

Script runs.

Configuration

[Radarr]
url = http://127.0.0.1:7878
key = 7c6ef2bca5174f9c8ad203927b5766d1


[Radarr4k]
url = http://127.0.0.1:7879
key = 7c6ef2bca5174f9c8ad203927b5766d1
profile = 8

Logs

Traceback (most recent call last):
  File "/home/fjen/RadarrSync/RadarrSync.py", line 50, in <module>
    radarr_url = ConfigSectionMap("Radarr")['url']
  File "/home/fjen/RadarrSync/RadarrSync.py", line 28, in ConfigSectionMap
    options = Config.options(section)
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 671, in options
    raise from_none(NoSectionError(section))
backports.configparser.NoSectionError: No section: 'Radarr'

Same idea but for sonarr V3

Tried to get this to run with sonarr V3, no go
Simple request is make Sonarr V3 work just like radarrsync

sonarr V3 introduces remux quality

Failing to find primary server in config

Describe the bug
Not finding the Primary Server in the config file source

To Reproduce
Hi there - just grabbed this and ran into an issue running it. Installed per the instructions, made sure all my prerequisites were in, and edited the Config file...The Radarr section is definitely there (didn't touch the headers in the config file).....thoughts?

Expected behavior
Not crash

Configuration
N/A

Logs

feez@dh-download:~/RadarrSync-1.2$ python3 ./RadarrSync.py
Traceback (most recent call last):
File "./RadarrSync.py", line 213, in <module>
radarrServer['url'] = ConfigSectionMap("Radarr")['url']
File "./RadarrSync.py", line 19, in ConfigSectionMap
options = Config.options(section)
File "/usr/lib/python3.6/configparser.py", line 675, in options
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'Radarr'

Primary server config hardcoded

need to modify this section to look for default or Radarr or remove default as option, though I like it for 3.0


RadarrSync/RadarrSync.py

Lines 46 to 51 in a3c6696

return False
except:
for i in range(0, len(profiles)):
if profiles[i]['name'].lower() == profileName.lower():
logger.debug('{0} is profile {1}'.format(profiles[i]['name'], i + 1))
return i + 1 # validated the profile is on the server so return the ID number


This issue was generated by todo based on a TODO comment in a3c6696 when #24 was merged. cc @Sperryfreak01.

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.