Finished m4a support.
This commit is contained in:
parent
e7dea14cdf
commit
f2ceb03d0c
2 changed files with 38 additions and 35 deletions
40
append.py
40
append.py
|
@ -4,6 +4,7 @@ import urllib2
|
|||
from urllib2 import HTTPError, URLError
|
||||
import logging
|
||||
import re
|
||||
from BeautifulSoup import BeautifulSoup
|
||||
|
||||
def __fetch_feed(url):
|
||||
try:
|
||||
|
@ -18,7 +19,7 @@ def __fetch_feed(url):
|
|||
logging.debug('Network failure reason, %s.' % e.reason)
|
||||
return None
|
||||
|
||||
def __append(entry, suffix, append_fn):
|
||||
def __append(entry, suffix, append_fn, args=None):
|
||||
latest = __fetch_feed('cmdln_%s.xml' % suffix)
|
||||
if entry.title.find(latest.title) != -1:
|
||||
logging.info('Up to date.')
|
||||
|
@ -29,14 +30,14 @@ def __append(entry, suffix, append_fn):
|
|||
try:
|
||||
for line in f:
|
||||
if line.find('<item>') != -1 and not first:
|
||||
append_fn(entry, o, suffix)
|
||||
append_fn(entry, o, suffix, args)
|
||||
first = True
|
||||
o.write(line)
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
|
||||
def __append_non_itunes(entry, output, suffix):
|
||||
def __append_non_itunes(entry, output, suffix, args):
|
||||
(url, mime_type, size) = __enclosure(entry.enclosures, 'http://cmdln.evenflow.nl/mp3', suffix)
|
||||
output.write(""" <item>
|
||||
<title>%(title)s (Comment Line 240-949-2638)</title>
|
||||
|
@ -57,6 +58,38 @@ def __append_non_itunes(entry, output, suffix):
|
|||
logging.info('Inserted new %s item.' % suffix)
|
||||
|
||||
|
||||
def __append_itunes(entry, output, suffix, args):
|
||||
description = __description(entry.content)
|
||||
soup = BeautifulSoup(description)
|
||||
summary = '\n\n'.join([''.join(p.findAll(text=True)) for p in soup.findAll('p')])
|
||||
(url, mime_type, size) = __enclosure(entry.enclosures, 'http://traffic.libsyn.com/cmdln', suffix)
|
||||
output.write(""" <item>
|
||||
<title>%(title)s (Comment Line 240-949-2638)</title>
|
||||
<link>%(link)s</link>
|
||||
<description><![CDATA[%(description)s]]></description>
|
||||
<pubDate>%(pubDate)s</pubDate>
|
||||
<enclosure url="%(url)s" length="%(size)s" type="%(mime_type)s"/>
|
||||
<guid isPermaLink="false">%(permalink)s</guid>
|
||||
<itunes:author>Thomas Gideon</itunes:author>
|
||||
<itunes:subtitle>%(subtitle)s</itunes:subtitle>
|
||||
<itunes:summary>%(summary)s</itunes:summary>
|
||||
<itunes:explicit>no</itunes:explicit>
|
||||
<itunes:duration>%(duration)s</itunes:duration>
|
||||
</item>
|
||||
""" % { 'title': entry.title,
|
||||
'link': entry.link,
|
||||
'description': description,
|
||||
'pubDate' : entry.date,
|
||||
'permalink' : __permalink(entry.title),
|
||||
'url' : url,
|
||||
'mime_type' : mime_type,
|
||||
'size' : size,
|
||||
'subtitle' : ''.join(soup.contents[0].findAll(text = True)),
|
||||
'summary' : summary,
|
||||
'duration' : args[1] })
|
||||
logging.info('Inserted new %s item.' % suffix)
|
||||
|
||||
|
||||
def __permalink(title):
|
||||
permalink = title.lower()
|
||||
permalink = re.sub('-', '', permalink)
|
||||
|
@ -97,6 +130,7 @@ def main():
|
|||
|
||||
__append(entry, 'mp3', __append_non_itunes)
|
||||
__append(entry, 'ogg', __append_non_itunes)
|
||||
__append(entry, 'm4a', __append_itunes, sys.argv)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -32,37 +32,6 @@
|
|||
<itunes:new-feed-url>http://feeds2.feedburner.com/cmdln-enhanced</itunes:new-feed-url>
|
||||
<itunes:block>no</itunes:block>
|
||||
<itunes:category text="Technology"/>
|
||||
<item>
|
||||
<title>TCLP 2010-09-15 Interview: Randy Chertkow of Beatnik Turtle (Comment Line 240-949-2638)</title>
|
||||
<link>http://thecommandline.net/2010/09/15/beatnik_turtle4/</link>
|
||||
<description><![CDATA[<p>This is a feature cast, an episode of The Command Line Podcast.</p>
|
||||
|
||||
<p>There is no new hacker word of the week this week.</p>
|
||||
|
||||
<p>The feature this week is the interview I recorded with Randy Chertkow of <a href="http://beatnikturtle.com/">Beatnik Turtle</a>. If you are interested, here are the <a href="http://thecommandline.net/2007/09/05/beatnik_turtle/">2007</a>, <a href="http://thecommandline.net/2008/09/10/beatnik_turtle_2/">2008</a>, and <a href="http://thecommandline.net/2009/09/09/beatnik_turtle3/">2009</a> interviews as well. In the interview, we mention <a href="http://www.indieguide.com/">the Indie Guide web site</a>, <a href="http://emusician.com/searchresults/?ord=d&terms=chertkow&x=0&y=0">Randy and Jason's columns at Electronic Musician</a>, and <a href="http://trackmydisc.com/">TrackMyDisc.com</a>.</p>
|
||||
|
||||
<p>More news and commentary and alternate feeds available at http://thecommandline.net/. View the <a href="http://thecommandline.net/wiki/2010_09_15">detailed show notes online</a>. You can grab the <a href="http://www.archive.org/details/Tclp2010-09-15InterviewRandyChertkowOfBeatnikTurtle">flac encoded audio</a> from the Internet Archive.</p>
|
||||
|
||||
<p><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/us/"><img style="border-width: 0px;" src="http://thecommandline.net/wp-content/uploads/cc-by-sa.png" alt="Creative Commons License" /></a></p>
|
||||
|
||||
<p>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/us/">Creative Commons Attribution-Share Alike 3.0 United States License</a>.</p>]]></description>
|
||||
<pubDate>Wed, 15 Sep 2010 21:29:57 -0400</pubDate>
|
||||
<enclosure url="http://traffic.libsyn.com/cmdln/cmdln.net_2010-09-15.m4a" length="49146170" type="audio/x-m4a"/>
|
||||
<guid isPermaLink="false">tclp-20100915-interview-randy-chertkow-of-beatn</guid>
|
||||
<itunes:author>Thomas Gideon</itunes:author>
|
||||
<itunes:subtitle>This is a feature cast, an episode of The Command Line Podcast.</itunes:subtitle>
|
||||
<itunes:summary>This is a feature cast, an episode of The Command Line Podcast.
|
||||
|
||||
There is no new hacker word of the week this week.
|
||||
|
||||
The feature this week is the interview I recorded with Randy Chertkow of Beatnik Turtle. If you are interested, here are the 2007, 2008, and 2009 interviews as well. In the interview, we mention the Indie Guide web site, Randy and Jason's columns at Electronic Musician, and TrackMyDisc.com.
|
||||
|
||||
More news and commentary and alternate feeds available at http://thecommandline.net/. View the detailed show notes online. You can grab the flac encoded audio from the Internet Archive.
|
||||
|
||||
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.</itunes:summary>
|
||||
<itunes:explicit>no</itunes:explicit>
|
||||
<itunes:duration>1:06:44</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>TCLP 2010-09-08 Creative Commons, Legal Issue Panel from Dragon*Con 2010 (Comment Line 240-949-2638)</title>
|
||||
<link>http://thecommandline.net/2010/09/08/dragoncon_cc_4/</link>
|
||||
|
@ -3600,4 +3569,4 @@ This work is licensed under a Creative Commons Attribution-Noncommercial-Share A
|
|||
<itunes:duration>20:03</itunes:duration>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
</rss>
|
||||
|
|
Loading…
Reference in a new issue