Sperryfreak01 / RadarrSync

120 stars 46 forks source link

Script Ran but not syncing #9

Closed mrnoisytiger closed 6 years ago

mrnoisytiger commented 6 years ago

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!

mrnoisytiger commented 6 years ago

Updating to the latest commit solved the issue!

Sperryfreak01 commented 6 years ago

Two things.

Sperryfreak01 commented 6 years ago

you beat me to it, guess there was something else besides the DEV mode that changed. I did a lot of refactoring in the two hours the DEV mode issue was up there.

mrnoisytiger commented 6 years ago

My config.txt looks like this:

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

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

It appears that I'm still having a bit of trouble with the sync. No matter whether I set profile=5 or profile=6, I still can't seem to get it to sync by running python3 RadarrSync.py

My output looks like:

2018-09-03 20:02:25,201 [MainThread  ] [DEBUG]  Starting new HTTP connection (1): 127.0.0.1
2018-09-03 20:02:25,283 [MainThread  ] [DEBUG]  http://127.0.0.1:7878 "GET /api/movie?apikey=7c6ef2bca5174f9c8ad203927b5766d1 HTTP/1.1" 200 None
2018-09-03 20:02:25,309 [MainThread  ] [DEBUG]  syncing to Radarr4k
2018-09-03 20:02:25,310 [MainThread  ] [DEBUG]  Starting new HTTP connection (1): 127.0.0.1
2018-09-03 20:02:25,386 [MainThread  ] [DEBUG]  http://127.0.0.1:7879 "GET /api/movie?apikey=7c6ef2bca5174f9c8ad203927b5766d1 HTTP/1.1" 200 None

I know the config URL's are correct since curling them gives the expected output.

mrnoisytiger commented 6 years ago

Also, the API keys are indeed the same between the two instances.

mrnoisytiger commented 6 years ago

As well, during my testing, I've been trying to sync from 4K to 1080p. However, in production, I would actually like it the other way around, so I don't have to wait for a cron tick for a search.

Sperryfreak01 commented 6 years ago

My api keys are the same as well, a convient by product of cloning the docker container. Did you copy a docker container? If so does your 4K server still have all the same movies in the DB as your original install?

mrnoisytiger commented 6 years ago

Instead of cloning the docker container (linuxserver.io), I created a new one and simply make a duplicate of the config directory.

As a result, all the movies are copied over but after a rescan of each one's individual directory, the appropriate ones are missing and have been searched for. Everything is good on that end.

However, now, I added a movie to the 4K one and want to push it over to the 1080p one but it's not going through. :cry:

I also tried adding a different movie to the 1080p and tried to push it over but didn't work either.

Sperryfreak01 commented 6 years ago

RadarrSync is a one way sync, from the primary server '[Radarr]' to '[Radarr4k]' in the case of your config. So if you add it to the 4k server it will not sync back to the regular server.

When you created a copy of your primary Radarr servers config and used it for your 4K server it brought the movie database it. So even if it cant find the files the movies have already been added to Radar and RadarrSync wont add them again.

But even still, I also left the logging in DEBUG mode so even if the movies were already when sync ran it would show debug messages.... I am still looking for what it could be

mrnoisytiger commented 6 years ago

Ah didn't realize it was from the regular to 4K. I thought it was the other way around.

Though my new movie on the regular one does not sync to the 4K one either.

Running curl http://127.0.0.1:7878/api/movie?apikey=7c6ef2bca5174f9c8ad20927b5766d1 shows the new movie.

Sperryfreak01 commented 6 years ago

you willing to edit some python code and see if we can isolate it?

mrnoisytiger commented 6 years ago

Not the exactly familiar with Python but I don't mind at all! Just tell me what to change! 😄

Sperryfreak01 commented 6 years ago

BTW, if you want to sync the opposite way you could...though not officially supported just flip the ports. It still wont be bidirectional though.

mrnoisytiger commented 6 years ago

🤣 Fair point. Didn't need it to be bidirectional at all! 😆 Was just for testing purposes!

Sperryfreak01 commented 6 years ago

you can open the script in notepad or a text editor of your choice

Replace the following block

    for movie in radarrMovies.json():
        if movie['profileId'] == int(ConfigSectionMap(server)['profile']):
            if movie['tmdbId'] not in movieIds_to_syncserver:
                logging.debug('title: {0}'.format(movie['title']))
                logging.debug('qualityProfileId: {0}'.format(movie['qualityProfileId']))
                logging.debug('titleSlug: {0}'.format(movie['titleSlug']))
                images = movie['images']
                for image in images:
                    image['url'] = '{0}{1}'.format(radarr_url, image['url'])
                    logging.debug(image['url'])
                logging.debug('tmdbId: {0}'.format(movie['tmdbId']))
                logging.debug('path: {0}'.format(movie['path']))
                logging.debug('monitored: {0}'.format(movie['monitored']))

                payload = {'title': movie['title'],
                           'qualityProfileId': movie['qualityProfileId'],
                           'titleSlug': movie['titleSlug'],
                           'tmdbId': movie['tmdbId'],
                           'path': movie['path'],
                           'monitored': movie['monitored'],
                           'images': images,
                           'profileId': movie['profileId'],
                           'minimumAvailability': 'released'
                           }

                r = session.post('{0}/api/movie?apikey={1}'.format(SyncServer_url, SyncServer_key), data=json.dumps(payload))
                searchid.append(int(r.json()['id']))
                logger.info('adding {0} to {1} server'.format(movie['title'], server))
            else:
                logging.debug('{0} already in {1} library'.format(movie['title'], server))

with

    for movie in radarrMovies.json():
        if movie['profileId'] == int(ConfigSectionMap(server)['profile']):
            if movie['tmdbId'] not in movieIds_to_syncserver:
                logging.debug('title: {0}'.format(movie['title']))
                logging.debug('qualityProfileId: {0}'.format(movie['qualityProfileId']))
                logging.debug('titleSlug: {0}'.format(movie['titleSlug']))
                images = movie['images']
                for image in images:
                    image['url'] = '{0}{1}'.format(radarr_url, image['url'])
                    logging.debug(image['url'])
                logging.debug('tmdbId: {0}'.format(movie['tmdbId']))
                logging.debug('path: {0}'.format(movie['path']))
                logging.debug('monitored: {0}'.format(movie['monitored']))

                payload = {'title': movie['title'],
                           'qualityProfileId': movie['qualityProfileId'],
                           'titleSlug': movie['titleSlug'],
                           'tmdbId': movie['tmdbId'],
                           'path': movie['path'],
                           'monitored': movie['monitored'],
                           'images': images,
                           'profileId': movie['profileId'],
                           'minimumAvailability': 'released'
                           }

                r = session.post('{0}/api/movie?apikey={1}'.format(SyncServer_url, SyncServer_key), data=json.dumps(payload))
                searchid.append(int(r.json()['id']))
                logger.info('adding {0} to {1} server'.format(movie['title'], server))
            else:
                logging.debug('{0} already in {1} library'.format(movie['title'], server))
        else:
            logging.debug('Skipping {0}, wanted profile: {1} found profile: {2}'.format(movie['title'],
                                                                                        movie['profileId'],
                                                                                        int(ConfigSectionMap(server)['profile'])
                                                                                        ))
mrnoisytiger commented 6 years ago

Here's a block of relevant output!

2018-09-03 20:32:37,409 [MainThread  ] [DEBUG]  Skipping A Ghost Story, wanted profile: 8 found profile: 5
2018-09-03 20:32:37,409 [MainThread  ] [DEBUG]  Skipping Mamma Mia!, wanted profile: 8 found profile: 5
2018-09-03 20:32:37,409 [MainThread  ] [DEBUG]  Skipping Mamma Mia! Here We Go Again, wanted profile: 8 found profile: 5
2018-09-03 20:32:37,409 [MainThread  ] [DEBUG]  Skipping Atomic Blonde, wanted profile: 7 found profile: 5
2018-09-03 20:32:37,409 [MainThread  ] [DEBUG]  Skipping Ant-Man, wanted profile: 8 found profile: 5
2018-09-03 20:32:37,409 [MainThread  ] [DEBUG]  Skipping Princess Mononoke, wanted profile: 7 found profile: 5

The one I'm having an issue with not syncing over is Ant-Man!

mrnoisytiger commented 6 years ago

I'm going to try changing the config to profile=8 and see what happens!

mrnoisytiger commented 6 years ago

Looks like that did it! Apparently, I was not using the needed profile number for it to sync over...

Sperryfreak01 commented 6 years ago

yeah, its because the wrong profile. by default profile 8 is... nothing. Hmm at least on mines its nothing.

if you go to http://127.0.0.1:7878/settings/profiles what are your profiles? It counts left to right row by row. I only have 7 profiles.

mrnoisytiger commented 6 years ago

Ah I added a custom profile for RadarrSync on both of my installations! I didn't realize that's how the profile setting worked! 😿

mrnoisytiger commented 6 years ago

Thanks for all your help man!!!!

Sperryfreak01 commented 6 years ago

yeah, there is no way for the script to get the profiles today. The radarr API doesnt support it. Glad you got it working, so was your 4K profile the 4th profile on the second row?

mrnoisytiger commented 6 years ago

Yep exactly!

Imgur

I made a custom profile for RadarrSync for internal naming consistency. Didn't want the 1080p instance to be called UHD, but that's just because I'm a tad OCD with naming.

Explains why I could never get it working...

Sperryfreak01 commented 6 years ago

No justification needed, glad its working.