# Path: oembed/constants.py
# OEMBED_DEFAULT_PARSE_HTML = getattr(settings, 'OEMBED_DEFAULT_PARSE_HTML', True)
# 
# URL_RE = re.compile(URL_PATTERN)


import re
import oembed
from oembed.constants import OEMBED_DEFAULT_PARSE_HTML, URL_RE
from oembed.exceptions import OEmbedException
from oembed.parsers import text_parser, html_parser
        parser = text_parser()
        urls = parser.extract_urls(text)
        return self.handle_extracted_urls(urls, maxwidth, maxheight, resource_type)
    
    def extract_oembeds_html(self, text, maxwidth=None, maxheight=None, resource_type=None):
        parser = html_parser()
        urls = parser.extract_urls(text)
        return self.handle_extracted_urls(urls, maxwidth, maxheight, resource_type)
    
    def handle_extracted_urls(self, url_set, maxwidth=None, maxheight=None, resource_type=None):
        embeds = []
        
        for user_url in url_set:
            try:
                resource = oembed.site.embed(user_url, maxwidth=maxwidth, maxheight=maxheight)
            except OEmbedException:
                continue
            else:
                if not resource_type or resource.type == resource_type:
                    data = resource.get_data()
                    data['original_url'] = user_url
                    embeds.append(data)
        
        return embeds
    
    def strip(self, text, *args, **kwargs):
        """
        Try to maintain parity with what is extracted by extract since strip
        will most likely be used in conjunction with extract
        """

# Path: oembed/constants.py
# OEMBED_DEFAULT_PARSE_HTML = getattr(settings, 'OEMBED_DEFAULT_PARSE_HTML', True)
# 
# URL_RE = re.compile(URL_PATTERN)


# Path: oembed/consumer.py
import re
import oembed
from oembed.constants import OEMBED_DEFAULT_PARSE_HTML, URL_RE
from oembed.exceptions import OEmbedException
from oembed.parsers import text_parser, html_parser

        parser = text_parser()
        urls = parser.extract_urls(text)
        return self.handle_extracted_urls(urls, maxwidth, maxheight, resource_type)
    
    def extract_oembeds_html(self, text, maxwidth=None, maxheight=None, resource_type=None):
        parser = html_parser()
        urls = parser.extract_urls(text)
        return self.handle_extracted_urls(urls, maxwidth, maxheight, resource_type)
    
    def handle_extracted_urls(self, url_set, maxwidth=None, maxheight=None, resource_type=None):
        embeds = []
        
        for user_url in url_set:
            try:
                resource = oembed.site.embed(user_url, maxwidth=maxwidth, maxheight=maxheight)
            except OEmbedException:
                continue
            else:
                if not resource_type or resource.type == resource_type:
                    data = resource.get_data()
                    data['original_url'] = user_url
                    embeds.append(data)
        
        return embeds
    
    def strip(self, text, *args, **kwargs):
        """
        Try to maintain parity with what is extracted by extract since strip
        will most likely be used in conjunction with extract
        """

        if OEMBED_DEFAULT_PARSE_HTML: