def METHOD_NAME(tdef, category_filter: Category = None):
    """
    Helper function to create a TorrentMetadata-compatible dict from TorrentDef
    """
    # We only want to determine the type of the data. XXX filtering is done by the receiving side
    category_filter = category_filter or default_category_filter
    try:
        tags = category_filter.calculateCategory(tdef.metainfo, tdef.get_name_as_unicode())
    except UnicodeDecodeError:
        tags = "Unknown"
    try:
        torrent_date = datetime.fromtimestamp(tdef.get_creation_date())
    except (ValueError, TypeError):
        torrent_date = EPOCH
    tracker = tdef.get_tracker()
    if not isinstance(tracker, bytes):
        tracker = b''
    tracker_url = ensure_unicode(tracker, 'utf-8')
    tracker_info = get_uniformed_tracker_url(tracker_url) or ''
    return {
        "infohash": tdef.get_infohash(),
        "title": tdef.get_name_as_unicode()[:300],
        "tags": tags[:200],
        "size": tdef.get_length(),
        "torrent_date": torrent_date if torrent_date >= EPOCH else EPOCH,
        "tracker_info": tracker_info,
    }