| 23 | return len([l for l in f]) |
| 24 | |
| 25 | def get_duration(json_video): |
| 26 | hours = 0 |
| 27 | minutes = 0 |
| 28 | seconds = 0 |
| 29 | s = json_video['items'][0]['contentDetails']['duration'] |
| 30 | match = re.match(r'PT([0-5]?[\d])M([0-5]?[\d]?)S?', s) |
| 31 | if match: |
| 32 | items = match.groups() |
| 33 | minutes = items[0] |
| 34 | seconds = items[1] |
| 35 | else: |
| 36 | match_with_hours = re.match(r'PT([\d]?[\d])H([0-5]?[\d]?)M?([0-5]?[\d]?)S?', s) |
| 37 | if match_with_hours: |
| 38 | items = match_with_hours.groups() |
| 39 | hours = items[0] |
| 40 | minutes = items[1] |
| 41 | seconds = items[2] |
| 42 | |
| 43 | return hours, minutes, seconds |
| 44 | |
| 45 | def print_duration(duration): |
| 46 | hours = duration[0] or 0 |