def parse_get_course_contents(course_contents, courseId):
    """
    Extract used course contents for a specific course.

    Extract only needed course contents. Ignore contents of module type forum, lti, feedback, workshop, data, chat,
    survey or glossary. Return the other contents in a dictionary.

    :param course_contents: All contents of a course.
    :type course_contents: list(dict(str, int))
    :param courseId: The id of the course the contents are from.
    :type courseId: int
    :return: A list of dictionaries. Each dictionary contains a course id, module name, target, type and external id.
    :rtype: list(dict(str, int))
    """
    content_list = []
    for section in course_contents:
        for module in section['modules']:
            if module['modname'] == 'forum' or module['modname'] == 'lti' or module['modname'] == 'feedback' or \
                    module['modname'] == 'workshop' or module['modname'] == 'data' or module['modname'] == 'chat' or \
                    module['modname'] == 'survey' or module['modname'] == 'glossary':
                continue
            if module['modname'] == 'book':
                for content in module['contents'][1:]:
                    url = "{}&chapterid={}".format(module['url'], content["filepath"][1:-1])
                    content_list.append(
                        {'course_id': courseId, 'name': content["content"], 'target': url,
                         'type': "chapter", 'external_id': int(content["filepath"][1:-1])}
                    )

            content_list.append(
                {'course_id': courseId, 'name': module['name'], 'target': module['url'], 'type': module['modname'],
                 'external_id': int(module['id'])}
            )

    return content_list