def sync_content():
    global instanceA_profile_id, instanceA_profile, instanceB_profile_id, instanceB_profile, instanceA_profile_filter, instanceA_profile_filter_id, instanceB_profile_filter, instanceB_profile_filter_id, tested_api_version, instanceA_language_id, instanceA_language, instanceB_language_id, instanceB_language, instanceA_quality_match, instanceB_quality_match, is_sonarr, instanceA_tag_filter_id, instanceA_tag_filter, instanceB_tag_filter_id, instanceB_tag_filter, is_radarr, instanceA_blacklist, instanceB_blacklist
    instanceA_session = requests.Session()
    instanceA_session.trust_env = False
    instanceB_session = requests.Session()
    instanceB_session.trust_env = False
    if ((not instanceA_profile_id) and instanceA_profile):
        instanceA_profile_id = get_profile_from_id(instanceA_session, instanceA_url, instanceA_key, instanceA_profile, 'A')
    if ((not instanceB_profile_id) and instanceB_profile):
        instanceB_profile_id = get_profile_from_id(instanceB_session, instanceB_url, instanceB_key, instanceB_profile, 'B')
    logger.debug({'instanceA_profile_id': instanceA_profile_id, 'instanceA_profile': instanceA_profile, 'instanceB_profile_id': instanceB_profile_id, 'instanceB_profile': instanceB_profile})
    if ((not instanceA_profile_filter_id) and instanceA_profile_filter):
        instanceA_profile_filter_id = get_profile_from_id(instanceA_session, instanceA_url, instanceA_key, instanceA_profile_filter, 'A')
    if ((not instanceB_profile_filter_id) and instanceB_profile_filter):
        instanceB_profile_filter_id = get_profile_from_id(instanceB_session, instanceB_url, instanceB_key, instanceB_profile_filter, 'B')
    logger.debug({'instanceAprofile_filter_id': instanceA_profile_filter_id, 'instanceAprofile_filter': instanceA_profile_filter, 'instanceBprofile_filter_id': instanceB_profile_filter_id, 'instanceBprofile_filter': instanceB_profile_filter})
    if (is_sonarr or is_radarr):
        if ((not instanceA_tag_filter_id) and instanceA_tag_filter):
            instanceA_tag_filter_id = get_tag_from_id(instanceA_session, instanceA_url, instanceA_key, instanceA_tag_filter, 'A')
        if ((not instanceB_tag_filter_id) and instanceB_tag_filter):
            instanceB_tag_filter_id = get_tag_from_id(instanceB_session, instanceB_url, instanceB_key, instanceA_tag_filter, 'B')
        logger.debug({'instanceA_tag_filter': instanceA_tag_filter, 'instanceA_profile_filter': instanceA_profile_filter, 'instanceB_tag_filter_id': instanceB_tag_filter_id, 'instanceB_tag_filter': instanceB_tag_filter})
    if is_sonarr:
        if ((not instanceA_language_id) and instanceA_language):
            instanceA_language_id = get_language_from_id(instance_session=instanceA_session, instance_url=instanceA_url, instance_key=instanceA_key, instance_language=instanceA_language, instance_name='A')
        if ((not instanceB_language_id) and instanceB_language):
            instanceB_language_id = get_language_from_id(instance_session=instanceB_session, instance_url=instanceB_url, instance_key=instanceB_key, instance_language=instanceB_language, instance_name='B')
        logger.debug({'instanceA_language_id': instanceA_language_id, 'instanceA_language': instanceA_language, 'instanceB_language_id': instanceB_language_id, 'instanceB_language': instanceB_language, 'is_sonarr': is_sonarr, 'api_version': api_version})
    (instanceA_contents, instanceA_contentIds) = get_instance_contents(instanceA_url, instanceA_key, instanceA_session, instance_name='A')
    (instanceB_contents, instanceB_contentIds) = get_instance_contents(instanceB_url, instanceB_key, instanceB_session, instance_name='B')
    logger.info('syncing content from instance A to instance B')
    sync_servers(instanceA_contents=instanceA_contents, instanceB_contents=instanceB_contents, instanceB_contentIds=instanceB_contentIds, instanceB_language_id=instanceB_language_id, instanceB_path=instanceB_path, instanceB_profile_id=instanceB_profile_id, instanceB_session=instanceB_session, instanceB_url=instanceB_url, instanceA_profile_filter_id=instanceA_profile_filter_id, instanceB_key=instanceB_key, instanceA_quality_match=instanceA_quality_match, instanceA_tag_filter_id=instanceA_tag_filter_id, instanceA_blacklist=instanceA_blacklist)
    if sync_bidirectionally:
        logger.info('syncing content from instance B to instance A')
        sync_servers(instanceA_contents=instanceB_contents, instanceB_contents=instanceA_contents, instanceB_contentIds=instanceA_contentIds, instanceB_language_id=instanceA_language_id, instanceB_path=instanceA_path, instanceB_profile_id=instanceA_profile_id, instanceB_session=instanceA_session, instanceB_url=instanceA_url, instanceA_profile_filter_id=instanceB_profile_filter_id, instanceB_key=instanceA_key, instanceA_quality_match=instanceB_quality_match, instanceA_tag_filter_id=instanceB_tag_filter_id, instanceA_blacklist=instanceB_blacklist)
def sync_content():
    global instanceA_profile_id, instanceA_profile, instanceB_profile_id, instanceB_profile, instanceA_profile_filter, instanceA_profile_filter_id, instanceB_profile_filter, instanceB_profile_filter_id, tested_api_version, instanceA_language_id, instanceA_language, instanceB_language_id, instanceB_language, instanceA_quality_match, instanceB_quality_match, is_sonarr, instanceA_tag_filter_id, instanceA_tag_filter, instanceB_tag_filter_id, instanceB_tag_filter, is_radarr, instanceA_blacklist, instanceB_blacklist
    instanceA_session = requests.Session()
    instanceA_session.trust_env = False
    instanceB_session = requests.Session()
    instanceB_session.trust_env = False
    if ((not instanceA_profile_id) and instanceA_profile):
        instanceA_profile_id = get_profile_from_id(instanceA_session, instanceA_url, instanceA_key, instanceA_profile, 'A')
    if ((not instanceB_profile_id) and instanceB_profile):
        instanceB_profile_id = get_profile_from_id(instanceB_session, instanceB_url, instanceB_key, instanceB_profile, 'B')
    logger.debug({'instanceA_profile_id': instanceA_profile_id, 'instanceA_profile': instanceA_profile, 'instanceB_profile_id': instanceB_profile_id, 'instanceB_profile': instanceB_profile})
    if ((not instanceA_profile_filter_id) and instanceA_profile_filter):
        instanceA_profile_filter_id = get_profile_from_id(instanceA_session, instanceA_url, instanceA_key, instanceA_profile_filter, 'A')
    if ((not instanceB_profile_filter_id) and instanceB_profile_filter):
        instanceB_profile_filter_id = get_profile_from_id(instanceB_session, instanceB_url, instanceB_key, instanceB_profile_filter, 'B')
    logger.debug({'instanceAprofile_filter_id': instanceA_profile_filter_id, 'instanceAprofile_filter': instanceA_profile_filter, 'instanceBprofile_filter_id': instanceB_profile_filter_id, 'instanceBprofile_filter': instanceB_profile_filter})
    if (is_sonarr or is_radarr):
        if ((not instanceA_tag_filter_id) and instanceA_tag_filter):
            instanceA_tag_filter_id = get_tag_from_id(instanceA_session, instanceA_url, instanceA_key, instanceA_tag_filter, 'A')
        if ((not instanceB_tag_filter_id) and instanceB_tag_filter):
            instanceB_tag_filter_id = get_tag_from_id(instanceB_session, instanceB_url, instanceB_key, instanceA_tag_filter, 'B')
        logger.debug({'instanceA_tag_filter': instanceA_tag_filter, 'instanceA_profile_filter': instanceA_profile_filter, 'instanceB_tag_filter_id': instanceB_tag_filter_id, 'instanceB_tag_filter': instanceB_tag_filter})
    if is_sonarr:
        if ((not instanceA_language_id) and instanceA_language):
            instanceA_language_id = get_language_from_id(instance_session=instanceA_session, instance_url=instanceA_url, instance_key=instanceA_key, instance_language=instanceA_language, instance_name='A')
        if ((not instanceB_language_id) and instanceB_language):
            instanceB_language_id = get_language_from_id(instance_session=instanceB_session, instance_url=instanceB_url, instance_key=instanceB_key, instance_language=instanceB_language, instance_name='B')
        logger.debug({'instanceA_language_id': instanceA_language_id, 'instanceA_language': instanceA_language, 'instanceB_language_id': instanceB_language_id, 'instanceB_language': instanceB_language, 'is_sonarr': is_sonarr, 'api_version': api_version})
    (instanceA_contents, instanceA_contentIds) = get_instance_contents(instanceA_url, instanceA_key, instanceA_session, instance_name='A')
    (instanceB_contents, instanceB_contentIds) = get_instance_contents(instanceB_url, instanceB_key, instanceB_session, instance_name='B')
    logger.info('syncing content from instance A to instance B')
    sync_servers(instanceA_contents=instanceA_contents, instanceB_contents=instanceB_contents, instanceB_contentIds=instanceB_contentIds, instanceB_language_id=instanceB_language_id, instanceB_path=instanceB_path, instanceB_profile_id=instanceB_profile_id, instanceB_session=instanceB_session, instanceB_url=instanceB_url, instanceA_profile_filter_id=instanceA_profile_filter_id, instanceB_key=instanceB_key, instanceA_quality_match=instanceA_quality_match, instanceA_tag_filter_id=instanceA_tag_filter_id, instanceA_blacklist=instanceA_blacklist)
    if sync_bidirectionally:
        logger.info('syncing content from instance B to instance A')
        sync_servers(instanceA_contents=instanceB_contents, instanceB_contents=instanceA_contents, instanceB_contentIds=instanceA_contentIds, instanceB_language_id=instanceA_language_id, instanceB_path=instanceA_path, instanceB_profile_id=instanceA_profile_id, instanceB_session=instanceA_session, instanceB_url=instanceA_url, instanceA_profile_filter_id=instanceB_profile_filter_id, instanceB_key=instanceA_key, instanceA_quality_match=instanceB_quality_match, instanceA_tag_filter_id=instanceB_tag_filter_id, instanceA_blacklist=instanceB_blacklist)