fix sitemap generation

This commit is contained in:
j 2017-02-17 15:49:25 +01:00
parent fb74fcc5a7
commit 49c024e87d

View file

@ -198,7 +198,7 @@ def update_sitemap(base_url):
el = ET.SubElement(video, "video:family_friendly") el = ET.SubElement(video, "video:family_friendly")
el.text = 'Yes' el.text = 'Yes'
duration = i.sort.duration duration = i.sort.duration
if duration > 0: if duration and duration > 0:
el = ET.SubElement(video, "video:duration") el = ET.SubElement(video, "video:duration")
el.text = "%s" % int(duration) el.text = "%s" % int(duration)
el = ET.SubElement(video, "video:live") el = ET.SubElement(video, "video:live")
@ -275,7 +275,7 @@ def update_sitemap(base_url):
if d.collections.filter(Q(status='featured') | Q(status='public')).count(): if d.collections.filter(Q(status='featured') | Q(status='public')).count():
priority.text = '1.0' priority.text = '1.0'
data = '<?xml version="1.0" encoding="UTF-8"?>\n' + ET.tostring(urlset).decode() data = b'<?xml version="1.0" encoding="UTF-8"?>\n' + ET.tostring(urlset)
with open(sitemap[:-3], 'wb') as f: with open(sitemap[:-3], 'wb') as f:
f.write(data) f.write(data)
with gzip.open(sitemap, 'wb') as f: with gzip.open(sitemap, 'wb') as f: