Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3640

How to convert YouTube API duration to seconds?

$
0
0

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.parserduration = = dateutil.parser.parse('P1W2DT6H21M32S')

This throws an exception

TypeError: unsupported operand type(s) for +=: 'NoneType' and 'int'

What am I missing?


Viewing all articles
Browse latest Browse all 3640

Trending Articles