def process_service_response()

in source/lambda/ingestion-youtube/util/comment.py [0:0]


def process_service_response(youtube_response, search_query, tracker_date, video_title):
    record_published = True

    for item in youtube_response["items"]:
        record_published = process_comment(item["snippet"]["topLevelComment"], search_query, video_title, tracker_date)

        if item.get("replies", None) and item.get("replies").get("comments", None):
            reply_record_published = True

            comments = item.get("replies").get("comments")
            logger.debug(f"Found replies in comments: {json.dumps(comments)}")
            for item_comment in comments:
                reply_record_published = process_comment(item_comment, search_query, video_title, tracker_date)
                if not reply_record_published:
                    break

        if not record_published:
            break

    return record_published