commit bc18b19df3465b6d8360815020927ae1ad8caa10 Author: Martin Potier Date: Sun Jun 7 19:58:26 2015 +0200 Initial commit diff --git a/createPodcastFeed.py b/createPodcastFeed.py new file mode 100755 index 0000000..2b4e431 --- /dev/null +++ b/createPodcastFeed.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# This Python file uses the following encoding: utf-8 +from __future__ import unicode_literals + +from os import listdir,chmod +from os.path import isfile,getsize +from stat import S_IXOTH,S_IRUSR,S_IWUSR,S_IXUSR,S_IRGRP +from sys import getfilesystemencoding +from feedgen.feed import FeedGenerator + +fg = FeedGenerator() +fg.load_extension('podcast') +fg.podcast.itunes_category('Technology','Podcasting') + +fg.id('http://pod.menf.in/podcast.xml') +fg.title('Radio Julia') +fg.author( name='Léo Potier', email='undisclosed@menf.in' ) +fg.link( href='http://pod.menf.in/podcast.xml', rel='self' ) +fg.logo('http://pod.menf.in/shows/podcast.jpg') +fg.description('Podcast hebdomadaire') +fg.language('fr') + +listOfPodcasts = [ p for p in listdir("./shows/") + if p.endswith(".mp3") ] + +#for p in listOfPodcasts: +# p = p.decode(getfilesystemencoding()) + +listOfPodcasts.sort() + +# For each file in 'shows' +for p in listOfPodcasts: + basename = p[:-4] + name = basename[3:] + description = "./shows/%s.txt" % basename + + fe = fg.add_entry() + fe.id(p) + fe.title(name) + if isfile(description): + with open(description, "r") as f: + s = f.read() + fe.description(s.decode('UTF-8')) + else: + fe.description("Émission " + name) + fe.enclosure("http://pod.menf.in/shows/" + p, "%s" % getsize("./shows/%s" % p), 'audio/mpeg') + +fg.rss_str(pretty=True) +fg.rss_file('podcast.xml') + +# Checking rights +chmod("./shows", S_IXOTH | S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP) + +print("That's all folks")