← Twitch UserVoice Settings and activity 2 results found Keep Bits, do not replace with Super Cheer 743 votes Vote Vote Vote Vote We're glad you're herePlease sign in to leave feedback Signed in as (Sign out) Close Close Vote We’ll send you updates on this idea 58 comments · Bits » Cheering · Delete… · Admin → How important is this to you? Not at all You must login first! Important You must login first! Critical You must login first! Your importance score has been recorded. We're glad you're herePlease sign in to leave feedback Signed in as (Sign out) Close Close Submit Rating Tenosis supported this idea · Sep 23, 2022 Add duration in seconds to Get Videos 6 votes Vote Vote Vote Vote We're glad you're herePlease sign in to leave feedback Signed in as (Sign out) Close Close Vote We’ll send you updates on this idea 3 comments · Developers » API · Delete… · Admin → How important is this to you? Not at all You must login first! Important You must login first! Critical You must login first! Your importance score has been recorded. We're glad you're herePlease sign in to leave feedback Signed in as (Sign out) Close Close Submit Rating An error occurred while saving the comment Tenosis commented · Nov 11, 2020 · Edit… · Delete… 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) Save Submitting... Tenosis supported this idea · Sep 18, 2020
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)