Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

radarr_collection_syn #3

Open
stempest opened this issue Dec 31, 2020 · 2 comments
Open

radarr_collection_syn #3

stempest opened this issue Dec 31, 2020 · 2 comments

Comments

@stempest
Copy link

Hi
Thanks for writting this code it's greatly appreciated. I've been searching for years for a good stable way of doing this as I dont have kodi nor do I want to use it.

I had a couple of errors when values did not exist in the data provided by Radarr. I'm not very good at coding but believe I've got it working.

I really only want to mark an item as collected so I just defaulted some of the values in the event that info was missing.

As is said I'm really not a very good programmer.

` radarr_resolution = movie['movieFile']['quality']['quality']['resolution']
#scan_type = movie['movieFile']['mediaInfo']['scanType']
resolution_mapping = {
2160:"uhd_4k",
1080:"hd_1080",
720:"hd_720p",
480:"sd_480",
576:"sd_576"
}
resolution = resolution_mapping.get(radarr_resolution, "hd_720p")
if resolution in ["hd_1080", "sd_480", "sd_576"]:
#if scan_type in ['Interlaced', 'MBAFF', 'PAFF']:
# resolution = '{}i'.format(resolution)
#else:
resolution = '{}p'.format(resolution)
#pprint(movie)

if 'mediaInfo' in movie['movieFile']:
    #print("mediaInfo Key exists")
    if 'audioCodec' in movie['movieFile']['mediaInfo']:
        #print("audioCodec Key exists")
        audio_codec = movie['movieFile']['mediaInfo']['audioCodec']
        audio_mapping = {
            "AC3": "dolby_digital",
            "EAC3": "dolby_digital_plus",
            "TrueHD": "dolby_truehd",
            "EAC3 Atmos": "dolby_digital_plus_atmos",
            "TrueHD Atmos": "dolby_atmos",
            "DTS": "dts",
            "DTS-ES": "dts",
            "DTS-HD MA": "dts_ma",
            "DTS-HD HRA": "dts_hr",
            "DTS-X": "dts_x",
            "MP3": "mp3",
            "MP2": "mp2",
            "Vorbis": "ogg",
            "WMA": "wma",
            "AAC": "aac",
            "PCM": "lpcm",
            "FLAC": "flac",
            "Opus": "ogg_opus"
        }
        audio = audio_mapping.get(audio_codec, None)

        audio_channel_count = movie['movieFile']['mediaInfo']['audioChannels']
        channel_mapping = str(audio_channel_count)
        audio_channels = channel_mapping
    else:
        print("audioCodec does not exist")
        audio = "flac"
        audio_channels = str(2.0)
else:
    print("mediaInfo does not exist")
    audio = "flac"
    audio_channels = str(2.0)`
@rg9400
Copy link
Owner

rg9400 commented Dec 31, 2020

So basically, your issue was that not all files had mediaInfo available for them, right? Because the various pieces of info like scanType, audioCodec, audio_channel_count should all be found in the MI of the file. Either Radarr didn't scan the files for MediaInfo, or there's some malformed files. I'd be curious to see cases where you don't have audioCodec info for example, but do have MediaInfo scanned in. Similarly with ScanType.

@stempest
Copy link
Author

stempest commented Jan 1, 2021

Yes i believe your right, only files with no mediaInfo failed, I added too much code while trying to work out what is going wrong.

There are no instances where MediaInfo is present and other values are missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants