From 83ac62ed82a38826af7f9c047922996a83fec798 Mon Sep 17 00:00:00 2001 From: Dave Johansen Date: Mon, 16 Oct 2023 11:07:11 -0600 Subject: [PATCH] Use built-in ISO 8601 parse for Python 3.11 and later --- m3u8/parser.py | 7 +++++-- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/m3u8/parser.py b/m3u8/parser.py index 3f511e3c..1416a971 100644 --- a/m3u8/parser.py +++ b/m3u8/parser.py @@ -7,8 +7,11 @@ import itertools import re from urllib.parse import urljoin as _urljoin +try: + from iso8601 import parse_date +except ImportError: + from datetime.datetime import fromisoformat as parse_date -import iso8601 from m3u8 import protocol @@ -20,7 +23,7 @@ def cast_date_time(value): - return iso8601.parse_date(value) + return parse_date(value) def format_date_time(value, **kwargs): diff --git a/requirements.txt b/requirements.txt index 57c80f08..f2d13e13 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -iso8601 +iso8601; python_version < '3.11' diff --git a/setup.py b/setup.py index d9a95375..f1c01d4a 100644 --- a/setup.py +++ b/setup.py @@ -23,5 +23,5 @@ url="https://github.com/globocom/m3u8", description="Python m3u8 parser", long_description=long_description, - python_requires=">=3.6", + python_requires=">=3.7", )