title: How to convert YouTube API duration to seconds?
body: <p>For the sake of interest I want to convert video durations from YouTubes <code>ISO 8601</code> to seconds. To future proof my solution, I picked <a href="http://www.youtube.com/watch?v=2XwmldWC_Ls" rel="noreferrer">a really long video</a> to test it against.</p>
  
  <p>The API provides this for its duration - <code>"duration": "P1W2DT6H21M32S"</code></p>
  
  <p>I tried parsing this duration with <code>dateutil</code> as suggested in <a href="https://stackoverflow.com/questions/969285/how-do-i-translate-a-iso-8601-datetime-string-into-a-python-datetime-object">stackoverflow.com/questions/969285</a>.</p>
  
  <pre><code>import dateutil.parser
  duration = = dateutil.parser.parse('P1W2DT6H21M32S')
  </code></pre>
  
  <p>This throws an exception</p>
  
  <pre><code>TypeError: unsupported operand type(s) for +=: 'NoneType' and 'int'
  </code></pre>
  
  <p>What am I missing?</p>