add datestr generator

pull/207/head
simon 2 years ago
parent f1fb504874
commit cdc617c382
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

@ -8,6 +8,7 @@ import re
import string
import subprocess
import unicodedata
from datetime import datetime
from urllib.parse import parse_qs, urlparse
import yt_dlp
@ -88,6 +89,16 @@ def requests_headers():
return {"User-Agent": template}
def date_praser(timestamp):
"""return formatted date string"""
if isinstance(timestamp, int):
date_obj = datetime.fromtimestamp(timestamp)
elif isinstance(timestamp, str):
date_obj = datetime.strptime(timestamp, "%Y-%m-%d")
return datetime.strftime(date_obj, "%d %b, %Y")
class UrlListParser:
"""take a multi line string and detect valid youtube ids"""

Loading…
Cancel
Save