def clean_title(self, title):
        """Clean title with the use of og:site_name
        in this case try to get rid of site name
        and use TITLE_SPLITTERS to reformat title
        """
        # check if we have the site name in opengraph data
        if "site_name" in self.article.opengraph.keys():
            site_name = self.article.opengraph['site_name']
            # remove the site name from title
            title = title.replace(site_name, '').strip()

        # try to remove the domain from url
        if self.article.domain:
            pattern = re.compile(self.article.domain, re.IGNORECASE)
            title = pattern.sub("", title).strip()

        # split the title in words
        # TechCrunch | my wonderfull article
        # my wonderfull article | TechCrunch
        title_words = title.split()

        # check for an empty title
        # so that we don't get an IndexError below
        if len(title_words) == 0:
            return u""

        # check if first letter is in TITLE_SPLITTERS
        # if so remove it
        if title_words[0] in TITLE_SPLITTERS:
            title_words.pop(0)

        # check if last letter is in TITLE_SPLITTERS
        # if so remove it
        if title_words[-1] in TITLE_SPLITTERS:
            title_words.pop(-1)

        # rebuild the title
        title = u" ".join(title_words).strip()

        return title
def clean_title ( self , title ) : if "site_name" in self . article . opengraph . keys ( ) : site_name = self . article . opengraph [ 'site_name' ] title = title . replace ( site_name , '' ) . strip ( ) if self . article . domain : pattern = re . compile ( self . article . domain , re . IGNORECASE ) title = pattern . sub ( "" , title ) . strip ( ) title_words = title . split ( ) if len ( title_words ) == 0 : return u"" if title_words [ 0 ] in TITLE_SPLITTERS : title_words . pop ( 0 ) if title_words [ - 1 ] in TITLE_SPLITTERS : title_words . pop ( - 1 ) title = u" " . join ( title_words ) . strip ( ) return title
Clean title with the use of og:site_name
        in this case try to get rid of site name
        and use TITLE_SPLITTERS to reformat title