Changeset 492


Ignore:
Timestamp:
02/17/09 10:28:37 (16 years ago)
Author:
Nicholas Riley
Message:

Handle BRs and use short/long descriptions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Update Podcasts/update_podcasts.py

    r491 r492  
    3434RE_TOO_MANY_CR = re.compile(r'\s*\n\s*\n\s*\n+', re.U)
    3535RE_TAG = re.compile(r'<[^>]*>')
     36RE_BR = re.compile(r'<[Bb][Rr][^>]*>\s*', re.U)
    3637RE_WHITESPACE = re.compile(r'\s+', re.U)
    3738RE_LEADING_WHITESPACE = re.compile(r'^\s+(.*)', re.U)
     
    4647        s = RE_MATCHED_P.sub(r'\1\n\n', s)
    4748        s = RE_OPEN_P.sub(r'\n\n', s)
     49        s = RE_BR.sub(r'\n', s)
    4850        s = RE_TAG.sub('', s)
    4951        s = RE_TOO_MANY_CR.sub(r'\n\n', s)
     
    5153    s = RE_TRAILING_WHITESPACE.sub(r'\1', s)
    5254    return s
     55
     56def words(s):
     57    return set(RE_WHITESPACE.split(s))
    5358
    5459def podcasts_to_lyrics(iTunes):
     
    7075        else:
    7176            longdesc = html_to_text(longdesc)
     77            if desc != k.missing_value:
     78                desc = html_to_text(desc)
     79                if (desc not in longdesc and
     80                    len(words(desc) - words(longdesc)) > 1):
     81                    longdesc = '%s\n\n%s' % (desc, longdesc)
    7282
    7383        if lyrics == longdesc:
Note: See TracChangeset for help on using the changeset viewer.