+2








902ff00cb0
Co-authored-by: Jason Cameron <git@jasoncameron.dev> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: RequieMa <57754488+RequieMa@users.noreply.github.com> Co-authored-by: prafful <praffulsharma1230@gmail.com> Co-authored-by: M. Sanaullah <thebolly@gmail.com> Co-authored-by: embee <emilien.bev.com@gmail.com> Co-authored-by: Rodrigo <55567123+rodrigodasilv@users.noreply.github.com> Co-authored-by: Emilien Bevierre <44171454+emilienbev@users.noreply.github.com> Co-authored-by: tkhmielnitzky <tkhmielnitzky@gmail.com> Co-authored-by: bnfone <89687390+bnfone@users.noreply.github.com> Co-authored-by: Cyteon <129582290+Cyteon@users.noreply.github.com>
15 lines
436 B
Python
15 lines
436 B
Python
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
|