You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
436 B
15 lines
436 B
import re
|
|
from typing import Optional
|
|
|
|
from utils.console import print_substep
|
|
|
|
|
|
def extract_id(reddit_obj: dict, field: Optional[str] = "thread_id"):
|
|
"""
|
|
This function takes a reddit object and returns the post id
|
|
"""
|
|
if field not in reddit_obj.keys():
|
|
raise ValueError(f"Field '{field}' not found in reddit object")
|
|
reddit_id = re.sub(r"[^\w\s-]", "", reddit_obj[field])
|
|
return reddit_id
|