"""RedTube.com — direct HTML scrape search results.

Search: `https://www.redtube.com/?search=<q>&page=<n>`
Scene URL: `https://www.redtube.com/<id>` (slug nie ma w URL — viewkey-only).
"""
from __future__ import annotations

import re

from app.connectors.direct_scrapers._search_base import BaseSearchScraper


class RedTubeScraper(BaseSearchScraper):
    sitetag = "redtubecom"
    _search_url_template = "https://www.redtube.com/?search={query}&page={page}"
    _scene_url_re = re.compile(
        r'href="(?P<url>https://www\.redtube\.com/(?P<slug>\d+))"',
    )

    def _title_from_slug(self, slug):
        # Numeric ID jako tytuł nie ma sensu — placeholder, title backfill przy resolve.
        return f"redtube:{slug}"
