def clean(self):
        """
        Checks to make sure a feed url is valid and gets the feed title
        and domain.
        """
        feed_url = self.cleaned_data.get('url')
        if not feed_url:
            # Feed url was not validated by the field validator
            return self.cleaned_data
        feed = feedparser.parse(feed_url)
    
        # Check if the feed was not parsed correctly.
        if feed['bozo']:
            import logging
            if (isinstance(feed["bozo_exception"], feedparser.ThingsNobodyCaresAboutButMe) or
              feed["entries"]):
                # This isn't so bad. Just warnings or only some entries weren't parsed
                # properly.
                logging.warning(feed['bozo_exception'])
            else:
                # XML Error etc.
                self._errors['url'] = ErrorList(["This is not a valid feed: %s" % feed['bozo_exception']])
                logging.error(feed['bozo_exception'])
                # This field is no longer valid. Remove from cleaned_data
                del self.cleaned_data['url']
                return self.cleaned_data
        # Check if the feed has a title field
        feed_info = feed.get('feed')
        if not feed_info.get('title'):
            self._errors['url'] = ErrorList(["This is not a valid feed: The feed title is empty"])
            # This field is no longer valid. Remove from cleaned_data
            del self.cleaned_data['url']
            return self.cleaned_data
        self.cleaned_data['name'] = feed_info['title']
        self.instance.name = self.cleaned_data['name']
        self.cleaned_data['domain'] = get_url_domain(feed_url)
        self.instance.domain = self.cleaned_data['domain']
        self.instance.permalink = self.cleaned_data.get("href")
        return self.cleaned_data
dataset/ETHPy150Open IanLewis/django-lifestream/lifestream/admin.py/FeedCreationForm.clean/original