Initial commit
This commit is contained in:
commit
bc18b19df3
1 changed files with 54 additions and 0 deletions
54
createPodcastFeed.py
Executable file
54
createPodcastFeed.py
Executable file
|
@ -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")
|
Loading…
Reference in a new issue