Skip to content

Commit

Permalink
Revert "rajoute la description de l'épisode au flux RSS (requête web)"
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrimal committed Oct 7, 2017
1 parent ec5c817 commit fbe20c1
Showing 1 changed file with 5 additions and 37 deletions.
42 changes: 5 additions & 37 deletions darwin_create_lienrss.py
Expand Up @@ -9,7 +9,6 @@
import argparse
import datetime
from slugify import slugify
from pyquery import PyQuery

sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

Expand All @@ -22,30 +21,6 @@ def str2filename(string):
return filename


def transform2text(article):
"""Transforme un article parsé en texte pour le fichier de podcast."""
description = ""
for element in article.contents():
if hasattr(element, 'tag'):
if element.tag not in ['script']:
line_start = ""
if element.tag == 'ul':
line_start = "- "
for subelement in element.getchildren():
description += line_start + subelement.text_content() + '\n'
else:
if element.tag.startswith('h'):
line_start = '\n'
else:
line_start = ""
content = element.text_content()
description += line_start + content + '\n'
else:
line_start = ""
description += line_start + element + '\n'
return description


def get_remote_file_size(url):
try:
# in bytes
Expand Down Expand Up @@ -78,44 +53,37 @@ def create_rsslien(data, rss_template_path, rss_filename):
else:
mp3link = ''

if 'lien_emission' in emission_data:
d = PyQuery(url=emission_data['lien_emission'])
article = d('article')
description = transform2text(article)
else:
description = u"Sur les épaules de Darwin - par : Jean-Claude Ameisen - réalisé par : Christophe IMBERT"

# rss code
# print titre
rss_pdate = jj + '-' + mm + '-' + aa
rss_pubdate = datetime.datetime.strptime(rss_pdate, '%d-%m-%Y')
rss_line = u'\t<item>'
rss_line += u'''
<title>{titre}</title>
<description>{description_str}</description>
<description>
Sur les épaules de Darwin - par : Jean-Claude Ameisen - réalisé par : Christophe IMBERT
</description>
<category>Science &amp; Medicine</category>
<pubDate>{pubdate1}, {pubdate2} 19:00:00 +0100 </pubDate>
'''.format(
titre = unicode(titre),
pubdate1 = rss_pubdate.strftime('%a'),
pubdate2 = rss_pubdate.strftime('%d %b %Y'),
description_str = description
)

# itunes
# itune
rss_line += u'''
<itunes:author>Jean-Claude Ameisen</itunes:author>
<itunes:explicit>no</itunes:explicit>
<itunes:subtitle>
Émission du {mm}.{jj}.{aa} {titre}
</itunes:subtitle>
<itunes:summary>{description_str}</itunes:summary>
<itunes:summary>Jean-Claude Ameisen - réalisé par : Christophe IMBERT</itunes:summary>
'''.format(
mm = mm,
jj = jj,
aa = aa,
titre = unicode(titre),
description_str = description
)

if mp3link:
Expand Down

0 comments on commit fbe20c1

Please sign in to comment.