Skip to content
Translate Ideas and Comments
Choose language:
There was an error during translation

Settings and activity

2 results found

  1. 691 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    60 comments  ·  Bits » Cheering  ·  Admin →
    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    Tenosis supported this idea  · 
  2. 6 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    3 comments  ·  Developers » API  ·  Admin →
    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    An error occurred while saving the comment
    Tenosis commented  · 

    With the older v5 API I can just do the following in Python:

    duration = timedelta(seconds=int(data["length"]))

    With the Helix API endpoint, I had to set up the following function instead (ignore the dashes since spacing at the start was removed):

    hms_pattern = re.compile(r"(?:(?P<hours>\d+)h)?(?:(?P<minutes>\d+)m)?(?P<seconds>\d+)s", re.I)

    def parse_hms(hms_string: str) -> timedelta:
    ----tdict = dict()
    ----tmatch = re.search(hms_pattern, hms_string)
    ----if tmatch is None:
    --------raise ValueError
    ----for k, v in tmatch.groupdict().items():
    --------tdict[k] = 0 if v is None else int(v)
    ----return timedelta(**tdict)

    Tenosis supported this idea  ·