Skip to content

pastebin.py BUG FIX #23

@rhmvvCYB3R

Description

@rhmvvCYB3R

Commits... Exception in thread Thread-3 (search): Traceback (most recent call last): File "/home/.local/share/mise/installs/python/3.14.2/lib/python3.14/threading.py", line 1082, in _bootstrap_inner self._context.run(self.run) ~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "/home/.local/share/mise/installs/python/3.14.2/lib/python3.14/threading.py", line 1024, in run self._target(*self._args, **self._kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/
/slash/api/pastebin.py", line 27, in search cnt = db["count"] ~~^^^^^^^^^ TypeError: list indices must be integers or slices, not str


FIXED CODE !!

import requests
import json

from core import (
color,
symbol
)

from api.extract import extract

class gathered:
links = []
includes = []

def search(value):
print(f"{symbol.log} Searching {color.bold}{color.orange}{value}{color.reset} on {color.bold}Pastebin{color.reset}...")

try:
    req = requests.get(
        f"https://psbdmp.cc/api/search/domain/{value}",
        timeout=25
    )
    req.raise_for_status()
except requests.RequestException:
    return

try:
    db = req.json()
except json.JSONDecodeError:
    return

#  HERE API must return LIST 
if not isinstance(db, list) or len(db) == 0:
    print(
        f"{symbol.log} Pastebin search finished! "
        f"{color.red}0{color.reset} results found for "
        f"{color.bold}{color.orange}{value}{color.reset}."
    )
    return

out = f"{symbol.paste_found}:\n"

for paste in db:
    paste_id = paste.get("id")
    text = paste.get("text", "")

    if not paste_id:
        continue

    include = " ".join(text.split())

    extract.phone("pastebin", include)

    out += (
        f"     [{color.whitebg}{paste_id}{color.reset}] "
        f"{color.bold}Paste{color.reset} : "
        f"[{color.red}{color.underline}https://pastebin.com/{paste_id}{color.reset}] "
        f"{color.bold}Include{color.reset} : "
        f"[{color.include}{include}{color.reset}]\n"
    )

    gathered.includes.append({paste_id: text})
    gathered.links.append({paste_id: f"https://pastebin.com/{paste_id}"})

print(out)
print(
    f"{symbol.log} Pastebin search finished! "
    f"{color.red}{len(gathered.links)}{color.reset} results found for "
    f"{color.bold}{color.orange}{value}{color.reset}."
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions