add datestr generator

This commit is contained in:
simon 2022-03-29 16:47:21 +07:00
parent f1fb504874
commit cdc617c382
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -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"""