How to convert YouTube API duration to seconds?
问题 For the sake of interest I want to convert video durations from YouTubes ISO 8601 to seconds. To future proof my solution, I picked a really long video to test it against. The API provides this for its duration - "duration": "P1W2DT6H21M32S" I tried parsing this duration with dateutil as suggested in stackoverflow.com/questions/969285. import dateutil.parser duration = = dateutil.parser.parse('P1W2DT6H21M32S') This throws an exception TypeError: unsupported operand type(s) for +=: 'NoneType'