parent
d0360e5285
commit
53c9b07d19
27
morss.py
27
morss.py
|
@ -242,14 +242,17 @@ def decodeHTML(data, con=None):
|
||||||
log(enc)
|
log(enc)
|
||||||
return data.decode(enc, 'replace')
|
return data.decode(enc, 'replace')
|
||||||
|
|
||||||
def Fill(item, cache, feedurl='/', fast=False):
|
def Fix(item, feedurl='/'):
|
||||||
""" Returns True when it has done its best """
|
""" Improves feed items (absolute links, resolve feedburner links, etc) """
|
||||||
|
|
||||||
|
# check unwanted uppercase title
|
||||||
|
if len(item.title) > 20 and item.title.isupper():
|
||||||
|
item.title = item.title.title()
|
||||||
|
|
||||||
|
# check if it includes link
|
||||||
if not item.link:
|
if not item.link:
|
||||||
log('no link')
|
log('no link')
|
||||||
return True
|
return item
|
||||||
|
|
||||||
log(item.link)
|
|
||||||
|
|
||||||
# check relative urls
|
# check relative urls
|
||||||
item.link = urlparse.urljoin(feedurl, item.link)
|
item.link = urlparse.urljoin(feedurl, item.link)
|
||||||
|
@ -285,9 +288,16 @@ def Fill(item, cache, feedurl='/', fast=False):
|
||||||
item.link = match[0]
|
item.link = match[0]
|
||||||
log(item.link)
|
log(item.link)
|
||||||
|
|
||||||
# check unwanted uppercase title
|
return item
|
||||||
if len(item.title) > 20 and item.title.isupper():
|
|
||||||
item.title = item.title.title()
|
def Fill(item, cache, feedurl='/', fast=False):
|
||||||
|
""" Returns True when it has done its best """
|
||||||
|
|
||||||
|
if not item.link:
|
||||||
|
log('no link')
|
||||||
|
return item
|
||||||
|
|
||||||
|
log(item.link)
|
||||||
|
|
||||||
# content already provided?
|
# content already provided?
|
||||||
count_content = countWord(item.content)
|
count_content = countWord(item.content)
|
||||||
|
@ -433,6 +443,7 @@ def Gather(url, cachePath, options):
|
||||||
# set
|
# set
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
for i, item in enumerate(rss.items):
|
for i, item in enumerate(rss.items):
|
||||||
|
item = Fix(item, url)
|
||||||
if 'progress' in options:
|
if 'progress' in options:
|
||||||
if MAX_ITEM == 0:
|
if MAX_ITEM == 0:
|
||||||
print '%s/%s' % (i+1, size)
|
print '%s/%s' % (i+1, size)
|
||||||
|
|
Loading…
Reference in New Issue