0

It is easy to export an opml file from a podcast app. That provides me with information such as this.

<outline text="This Week in Google (MP3)" type="rss" xmlUrl="http://feeds.twit.tv/twig.xml"  htmlUrl="https://twit.tv/shows/this-week-in-google" />  

Is there a database or a method by which I could pull (or lookup or calculate) the average (or median) duration of each episode?

1

If you look at the XML for that podcast you'll see that it is structured like this

channel
  stream description
  item
    item description
  item
    item description
  …

where the items are the individual episodes and the item description includes a whole lot of tags containing metadata about each episode. One of the metadata is the description tag which looks like

<itunes:duration>2:03:55</itunes:duration>

So all you need to do is parse the XML (using whatever XML parsing framework works for you, for example ElementTree in python would do it like this:

import xml.etree.ElementTree as ET
root = ET.parse('thefile.xml').getroot()

Then loop through the items and get their itunes:duration. I'm a bit rubbish with ElementTree, but this worked for me:

import xml.etree.ElementTree as ET
# I downloaded the xml from my browser, but you could grab it here instead
root = ET.parse('twig.xml').getroot() 
channel = root.getchildren()[0]
d = list(channel.iter('{http://www.itunes.com/dtds/podcast-1.0.dtd}duration'))
for i in d:
  print i.text
  #doSomeParsingOfTheTimeStringsHere(i.text)
0

No. An OPML file only describes the feeds, not the individual posts in the feeds, let alone the (usually) MP3 files referenced from each post. And then again, those references are only links without size/duration information.

  • Thank you. But yes, armed with a list of feeds, where can one go to lookup the median episode duration? – Farrel Jul 16 at 2:08
  • Read the second half of my answer again. You can't, usually not until you have actually downloaded the podcasts. – Jan Doggen Jul 16 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.