(self, doc_id)
| 11599 | } |
| 11600 | |
| 11601 | def _drive_probe_variant(self, doc_id): |
| 11602 | headers = { |
| 11603 | "User-Agent": "Mozilla/5.0", |
| 11604 | "Accept-Language": "en-US,en;q=0.9" |
| 11605 | } |
| 11606 | for label, v_url in self._drive_variant_urls(doc_id).items(): |
| 11607 | try: |
| 11608 | r = requests.get(v_url, headers=headers, timeout=10, allow_redirects=True) |
| 11609 | if r.status_code not in (200, 301, 302, 307, 308): |
| 11610 | continue |
| 11611 | text = (r.text or "").strip() |
| 11612 | if not text or "404" in text[:220].upper(): |
| 11613 | continue |
| 11614 | soup = BeautifulSoup(text, "html.parser") |
| 11615 | title = "" |
| 11616 | og_title = soup.find("meta", attrs={"property": "og:title"}) |
| 11617 | if og_title and og_title.get("content"): |
| 11618 | title = og_title.get("content").strip() |
| 11619 | if not title and soup.title and soup.title.text: |
| 11620 | title = soup.title.text.strip() |
| 11621 | if title: |
| 11622 | author_data = self._drive_extract_author_from_html(text) |
| 11623 | return { |
| 11624 | "status": r.status_code, |
| 11625 | "title": title, |
| 11626 | "url": r.url or v_url, |
| 11627 | "author": author_data, |
| 11628 | "source": label, |
| 11629 | } |
| 11630 | except Exception: |
| 11631 | continue |
| 11632 | return {} |
| 11633 | |
| 11634 | def _ghunt_enrich_gdrive_owner(self, owner_name, owner_email): |
| 11635 | email = (owner_email or "").strip() |
no test coverage detected