summaryrefslogtreecommitdiff
path: root/plugin.video.itsapixelthing/resources/lib/addonutils.py
blob: 65c82a36bda3d95c40c205423affeb448bf02b2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- coding: utf-8 -*-
import re

def return_duration_as_seconds(string):
    try:
        totalseconds = 0
        hours = re.findall('(\d+)H',string)
        minutes = re.findall('(\d+)M',string)
        seconds = re.findall('(\d+)S',string)
        if hours:
            totalseconds += 3600*int(hours[0])
        if minutes:
            totalseconds += 60*int(minutes[0])
        if seconds:
            totalseconds += int(seconds[0])
        return str(totalseconds)
    except IndexError:
        return '0'