def get_tag_from_id(instance_session, instance_url, instance_key, instance_tag, instance_name=''):
    instance_tag_url = get_tag_path(instance_url, instance_key)
    tag_response = instance_session.get(instance_tag_url)
    if (tag_response.status_code != 200):
        logger.error(f'Could not get tag id from (instance{instance_name}) {instance_tag_url} - only works on Sonarr')
        exit_system()
    instance_tags = None
    try:
        instance_tags = tag_response.json()
    except:
        logger.error(f'Could not decode tag id from {instance_tag_url}')
        exit_system()
    tag_ids = []
    for item in instance_tags:
        for instance_item in instance_tag:
            if (item.get('label').lower() == instance_item.lower()):
                tag_ids.append(item)
    if (not tag_ids):
        logger.error(f'Could not find tag_id for instance {instance_name} and tag {instance_tags}')
        exit_system()
    instance_tag_ids = [tag.get('id') for tag in tag_ids]
    logger.debug(f'found id "{instance_tag_ids}" from tag "{instance_tag}" for instance {instance_name}')
    if (instance_tag_ids is None):
        logger.error(f'tag_id is None for instance {instance_name} and tag {instance_tag}')
        exit_system()
    return instance_tag_ids
def get_tag_from_id(instance_session, instance_url, instance_key, instance_tag, instance_name=):
    instance_tag_url = get_tag_path(instance_url, instance_key)
    tag_response = instance_session.get(instance_tag_url)
    if (tag_response.status_code != 200):
        logger.error(f'Could not get tag id from (instance{instance_name}) {instance_tag_url} - only works on Sonarr')
        exit_system()
    instance_tags = None
    try:
        instance_tags = tag_response.json()
    except:
        logger.error(f'Could not decode tag id from {instance_tag_url}')
        exit_system()
    tag_ids = []
    for item in instance_tags:
        for instance_item in instance_tag:
            if (item.get('label').lower() == instance_item.lower()):
                tag_ids.append(item)
    if (not tag_ids):
        logger.error(f'Could not find tag_id for instance {instance_name} and tag {instance_tags}')
        exit_system()
    instance_tag_ids = [tag.get('id') for tag in tag_ids]
    logger.debug(f'found id "{instance_tag_ids}" from tag "{instance_tag}" for instance {instance_name}')
    if (instance_tag_ids is None):
        logger.error(f'tag_id is None for instance {instance_name} and tag {instance_tag}')
        exit_system()
    return instance_tag_ids