changeset 76:51f0da3da721

myrss: fix Atom link parsing
author paulo
date Thu, 12 May 2016 01:04:10 -0700
parents ec48011dca1e
children 6ede61cb9d12
files myrss/myrss_app.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/myrss/myrss_app.py	Thu Feb 11 00:02:19 2016 -0800
     1.2 +++ b/myrss/myrss_app.py	Thu May 12 01:04:10 2016 -0700
     1.3 @@ -67,8 +67,9 @@
     1.4  	title = _strip_if_not_none(elementTree.find("{%s}title" % ns).text)
     1.5  	link = ''
     1.6  
     1.7 -	for i in elementTree.findall("{%s}link" % ns):
     1.8 -		if i.get("type") == "text/html" and i.get("rel") == "alternate":
     1.9 +	links = elementTree.findall("{%s}link" % ns)
    1.10 +	for i in links:
    1.11 +		if len(links) == 1 or i.get("rel") == "alternate":
    1.12  			link = i.get("href")
    1.13  			break
    1.14  
    1.15 @@ -78,8 +79,9 @@
    1.16  		it_title = _strip_if_not_none(i.find("{%s}title" % ns).text)
    1.17  		it_link = ''
    1.18  		
    1.19 -		for j in i.findall("{%s}link" % ns):
    1.20 -			if j.get("type") == "text/html" and j.get("rel") == "alternate":
    1.21 +		it_links = i.findall("{%s}link" % ns)
    1.22 +		for j in it_links:
    1.23 +			if len(it_links) == 1 or j.get("rel") == "alternate":
    1.24  				it_link = j.get("href")
    1.25  				break
    1.26