<commit_before>from urllib.parse import urlparse

from django.conf import settings

from wagtail.wagtailembeds.embeds import embedly, oembed


# work around Embedly missing embedding HTML for Twitter and Instagram URLs
def finder(url, max_width=None):
    domain = urlparse(url).netloc
    if (domain.endswith(('instagram.com', 'twitter.com')) or
            not hasattr(settings, 'WAGTAILEMBEDS_EMBEDLY_KEY')):
        return oembed(url, max_width)

    return embedly(url, max_width)
<commit_msg>Fix embeds (broken by Wagtail upgrade).<commit_after>from urllib.parse import urlparse

from django.conf import settings

from wagtail.wagtailembeds.finders.embedly import embedly
from wagtail.wagtailembeds.finders.oembed import oembed


# work around Embedly missing embedding HTML for Twitter and Instagram URLs
def finder(url, max_width=None):
    domain = urlparse(url).netloc
    if (domain.endswith(('instagram.com', 'twitter.com')) or
            not hasattr(settings, 'WAGTAILEMBEDS_EMBEDLY_KEY')):
        return oembed(url, max_width)

    return embedly(url, max_width)

{'fraction_non_alphanumeric': 0.0871177015755329, 'fraction_numerical': 0.0, 'mean_word_length': 4.625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1976368', 'n_tokens_mistral': 355, 'n_tokens_neox': 343, 'n_words': 92}