Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to MAPLEAD. Format follows [Keep a Changelog](https://keepac
## [Unreleased]

### Fixed
- The *No website* filter now includes leads whose website is only a social
profile or link-in-bio page (Instagram, Facebook, Linktree and similar), and
*Has website* leaves them out. Those cards drop the *Website* chip and label
their link button *Social*. *Only leads with a website*, `--require-website`
and the *with website* count follow the same rule.
- **Bulk send** no longer crashes the AppImage on newer distros (e.g. Debian 13).
The image shipped the build machine's older `libstdc++`, which stopped the
system GPU driver from loading, so WhatsApp Web had no OpenGL. The C++ runtime
Expand Down
5 changes: 4 additions & 1 deletion docs/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ reading rather than for a spreadsheet:
disappearing. The template is remembered between launches.
- **Chips filter the list**: *Has WhatsApp*, *Has phone*, *Has website*,
*No website*, *Has e-mail*, *Not contacted*. The search box matches every visible field, and
the sort menu orders by rating, reviews or name.
the sort menu orders by rating, reviews or name. A lead whose website is only a
social profile or link-in-bio page (Instagram, Facebook, Linktree...) counts as
*No website*. The *Only leads with a website* search option and the *with website*
tile use the same rule.
- **Copy** on a card puts the whole row (TSV) on the clipboard.
- **Right-click a grid row** also has *Send WhatsApp message* and *Open in leads
panel*. The panel stays open while you work and refreshes after the next run.
Expand Down
41 changes: 40 additions & 1 deletion maplead/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import datetime
import re
from typing import Any, Dict, Mapping, Optional, Tuple
from urllib.parse import quote
from urllib.parse import quote, urlsplit

from .data import countries as CO

Expand All @@ -35,6 +35,45 @@
# The demo/outscraper providers may return this sentinel for a nameless place.
_UNNAMED = "(unnamed business)"

# Hosts that are a profile page, not a site of the business's own. Many owners
# paste their Instagram or link-in-bio page into Google's "website" field.
# Subdomains (www., m., pt-br.) count as the same host.
_SOCIAL_HOSTS = frozenset({
"facebook.com", "fb.com", "fb.me", "m.me",
"instagram.com", "instagr.am", "threads.net", "threads.com",
"linkedin.com", "lnkd.in",
"twitter.com", "x.com", "t.co",
"tiktok.com", "kwai.com", "snapchat.com",
"youtube.com", "youtu.be",
"pinterest.com", "pinterest.com.br", "pin.it",
"whatsapp.com", "wa.me", "wa.link", "t.me", "telegram.me", "telegram.org",
# link-in-bio pages
"linktr.ee", "linktree.com", "linkin.bio", "bio.link", "bio.site", "lnk.bio",
"linkr.bio", "tap.bio", "zaap.bio", "campsite.bio", "taplink.cc", "taplink.at",
"taplink.ws", "beacons.ai", "beacons.page", "solo.to", "linkfly.to",
"milkshake.app", "msha.ke", "allmylinks.com", "about.me", "flow.page",
"linkpop.com", "hoo.be", "shor.by", "biolinky.co",
})


def is_social_url(url: Any) -> bool:
"""True when ``url`` points at a social network or link-in-bio page."""
text = str(url or "").strip()
if not text:
return False
try:
host = urlsplit(text if "://" in text else f"https://{text}").hostname
except ValueError:
return False
labels = (host or "").lower().rstrip(".").split(".")
return any(".".join(labels[i:]) in _SOCIAL_HOSTS for i in range(len(labels)))


def has_real_website(lead: Mapping[str, Any]) -> bool:
"""True when the lead has a website that is not just a social profile."""
url = str(lead.get("website") or "").strip()
return bool(url) and not is_social_url(url)

DEFAULT_TEMPLATE = (
"Olá {nome}! Tudo bem? Encontrei vocês no Google Maps e gostaria de saber "
"mais sobre os serviços de vocês."
Expand Down
5 changes: 3 additions & 2 deletions maplead/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple

from .contacts import has_real_website
from .providers import Provider, SearchRequest, SearchResult

# --------------------------------------------------------------------------- #
Expand Down Expand Up @@ -265,7 +266,7 @@ def apply_filters(leads: Sequence[Dict[str, Any]], min_rating: float | None = No
if not phone or phone_type(phone, country_code, dial) == "landline":
stats["skip_landlines"] += 1
continue
if require_website and not lead.get("website"):
if require_website and not has_real_website(lead):
stats["require_website"] += 1
continue
if skip_closed and str(lead.get("status", "")).upper().startswith("CLOSED"):
Expand Down Expand Up @@ -454,7 +455,7 @@ def avg(vals: List[float]) -> float:
return {
"total": len(leads),
"with_phone": sum(1 for l in leads if l.get("phone")),
"with_website": sum(1 for l in leads if l.get("website")),
"with_website": sum(1 for l in leads if has_real_website(l)),
"with_email": sum(1 for l in leads if l.get("email")),
"avg_rating": avg(ratings),
"avg_reviews": avg([float(x) for x in review_totals]),
Expand Down
2 changes: 2 additions & 0 deletions maplead/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ def _selftest_widgets(window) -> bool:
ok &= wa_url.startswith("https://wa.me/5511912345678?text=Ol%C3%A1")
ok &= contacts.render_template("Olá {nome}!", {}) == "Olá!"
ok &= contacts.unknown_placeholders("Oi {bairro}") == ("bairro",)
ok &= not contacts.has_real_website({"website": "https://www.instagram.com/padaria"})
ok &= contacts.has_real_website({"website": "https://padaria.com.br"})

# --- leads panel: every selected field, filters, paging ---------------- #
total = len(window.model.leads)
Expand Down
8 changes: 4 additions & 4 deletions maplead/gui/lead_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,7 @@ def _precompute(self) -> None:
for lead in self._leads]
self._has_wa = [bool(contacts.whatsapp_number(lead, dial, iso))
for lead in self._leads]
self._has_site = [bool(str(lead.get("website") or "").strip())
for lead in self._leads]
self._has_site = [contacts.has_real_website(lead) for lead in self._leads]
self._has_email = [bool(str(lead.get("email") or "").strip())
for lead in self._leads]
self._contacted = [self._history.was_contacted(
Expand Down Expand Up @@ -632,7 +631,7 @@ def _url_and_text(self, key: str, text: str,

def _presence_chips(self, lead: Dict[str, Any]) -> List[QLabel]:
chips: List[QLabel] = []
if self._has("website") and str(lead.get("website") or "").strip():
if self._has("website") and contacts.has_real_website(lead):
chips.append(chip("Website", "ok"))
if self._has("phone") and str(lead.get("phone") or "").strip():
chips.append(chip("Phone", "ok"))
Expand Down Expand Up @@ -753,7 +752,8 @@ def _card(self, lead: Dict[str, Any], index: int) -> QWidget:
shown.add("maps_url")
website = str(lead.get("website") or "").strip()
if website and self._has("website"):
site_btn = QPushButton("Website")
site_btn = QPushButton(
"Social" if contacts.is_social_url(website) else "Website")
site_btn.setProperty("flat", True)
site_btn.setIcon(icons.icon("globe", self.p.text_dim, 13))
site_btn.clicked.connect(lambda u=website: self._open_url(u))
Expand Down
2 changes: 1 addition & 1 deletion maplead/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def pct(part: int) -> str:

self.stat_leads.set(str(leads), f"target {self.limit_spin.value()}")
self.stat_phone.set(pct(phone), f"{phone} with a number")
self.stat_site.set(pct(site), f"{site} with a URL")
self.stat_site.set(pct(site), f"{site} with a site")
self.stat_rating.set(f"{rating:.2f} ★" if rating else "–",
"average" if rating else "")
self.stat_reviews.set(f"{reviews:,}", "total reviews")
Expand Down
Loading