Add Scribd PDF Downloader under Scribd/
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
5d2933ea95
28 files changed
+2159
No files matched your search
@@ -0,0 +1,3 @@
|
||||
"""Scribd PDF downloader — save documents and ebooks as PDF."""
|
||||
|
||||
__version__ = "1.0.0"
|
||||
@@ -0,0 +1,74 @@
|
||||
"""Optional Scribd login for subscription or private content."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from playwright.sync_api import Browser, BrowserContext, Playwright
|
||||
|
||||
SESSION_FILE = Path("session.json")
|
||||
LOGIN_URL = "https://www.scribd.com/login"
|
||||
|
||||
_LOGGED_IN_SELECTORS = (
|
||||
"motion.header",
|
||||
"header[data-e2e='header']",
|
||||
".header__user-menu",
|
||||
"div.user_row",
|
||||
"[data-e2e='user-avatar']",
|
||||
)
|
||||
|
||||
|
||||
def session_exists() -> bool:
|
||||
return SESSION_FILE.is_file()
|
||||
|
||||
|
||||
def ensure_logged_in(playwright: Playwright, *, force_login: bool = False) -> None:
|
||||
"""Open a visible browser for login and persist cookies to session.json."""
|
||||
if session_exists() and not force_login:
|
||||
return
|
||||
|
||||
print("Opening browser for Scribd login…")
|
||||
print("Sign in, then wait until your account menu appears in the header.")
|
||||
|
||||
browser = playwright.chromium.launch(headless=False)
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
page.goto(LOGIN_URL, wait_until="domcontentloaded")
|
||||
|
||||
for selector in _LOGGED_IN_SELECTORS:
|
||||
try:
|
||||
page.locator(selector).first.wait_for(state="visible", timeout=300_000)
|
||||
break
|
||||
except Exception:
|
||||
continue
|
||||
else:
|
||||
raise RuntimeError("Login timed out. Complete sign-in in the browser window.")
|
||||
|
||||
context.storage_state(path=str(SESSION_FILE))
|
||||
print(f"Session saved to {SESSION_FILE.resolve()}")
|
||||
context.close()
|
||||
browser.close()
|
||||
|
||||
|
||||
def open_browser(
|
||||
playwright: Playwright,
|
||||
*,
|
||||
headless: bool = True,
|
||||
use_session: bool = True,
|
||||
viewport: dict | None = None,
|
||||
device_scale_factor: float = 1.0,
|
||||
) -> tuple[Browser, BrowserContext]:
|
||||
storage = str(SESSION_FILE) if use_session and session_exists() else None
|
||||
browser = playwright.chromium.launch(headless=headless)
|
||||
context = browser.new_context(
|
||||
storage_state=storage,
|
||||
viewport=viewport or {"width": 1400, "height": 2000},
|
||||
device_scale_factor=device_scale_factor,
|
||||
ignore_https_errors=True,
|
||||
user_agent=(
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"Chrome/120.0.0.0 Safari/537.36"
|
||||
),
|
||||
)
|
||||
return browser, context
|
||||
@@ -0,0 +1,151 @@
|
||||
"""Download Scribd ebooks (reflowable text) chapter by chapter."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from pypdf import PdfWriter
|
||||
from playwright.sync_api import sync_playwright
|
||||
from rich.console import Console
|
||||
from rich.progress import Progress, SpinnerColumn, TextColumn
|
||||
|
||||
from scribd_downloader.auth import ensure_logged_in, open_browser
|
||||
from scribd_downloader.url import ScribdTarget, sanitize_filename
|
||||
|
||||
console = Console()
|
||||
ZOOM = 0.625
|
||||
|
||||
|
||||
def download_book(
|
||||
target: ScribdTarget,
|
||||
*,
|
||||
output: str | None = None,
|
||||
headless: bool = True,
|
||||
) -> Path:
|
||||
"""Render ebook pages to PDF. Requires an active Scribd subscription (login)."""
|
||||
read_url = target.read_url or target.original_url.replace("/book/", "/read/")
|
||||
|
||||
with sync_playwright() as playwright:
|
||||
ensure_logged_in(playwright)
|
||||
|
||||
browser, context = open_browser(playwright, headless=headless, use_session=True)
|
||||
page = context.new_page()
|
||||
|
||||
console.print("[cyan]Opening book reader…[/cyan]")
|
||||
page.goto(read_url, wait_until="domcontentloaded", timeout=120_000)
|
||||
|
||||
if "Browser limit exceeded" in page.content():
|
||||
context.close()
|
||||
browser.close()
|
||||
raise RuntimeError(
|
||||
"Scribd blocked this book (too many browsers). Wait up to 24 hours."
|
||||
)
|
||||
|
||||
font_style = page.locator("#fontfaces").inner_html()
|
||||
|
||||
page.locator(".icon-ic_displaysettings").wait_for(state="visible", timeout=60_000)
|
||||
page.evaluate("() => document.querySelector('.icon-ic_displaysettings').click()")
|
||||
page.locator(".vertical_mode_btn").wait_for(state="visible")
|
||||
page.evaluate("() => document.querySelector('.vertical_mode_btn').click()")
|
||||
|
||||
page.locator('div.vertical_page[data-page="0"], motion.div.vertical_page[data-page="0"]').first.wait_for(
|
||||
state="visible", timeout=60_000
|
||||
)
|
||||
page.evaluate("() => document.querySelector('.icon-ic_toc_list').click()")
|
||||
chapter_selector = page.locator('li.text_btn[role="none"]')
|
||||
chapter_selector.nth(0).wait_for(state="visible")
|
||||
num_chapters = chapter_selector.count()
|
||||
|
||||
page.evaluate('() => document.querySelector(\'li.text_btn[data-idx="0"]\').click()')
|
||||
|
||||
book_title = sanitize_filename(target.title_slug or f"book_{target.content_id}")
|
||||
cache_dir = Path(f".cache_{target.content_id}")
|
||||
cache_dir.mkdir(exist_ok=True)
|
||||
|
||||
render_page = context.new_page()
|
||||
render_page.set_viewport_size({"width": 1200, "height": 1600})
|
||||
|
||||
chapter_no = 1
|
||||
with Progress(
|
||||
SpinnerColumn(),
|
||||
TextColumn("[progress.description]{task.description}"),
|
||||
console=console,
|
||||
) as progress:
|
||||
while True:
|
||||
task = progress.add_task(
|
||||
f"Chapter {chapter_no}/{num_chapters}…", total=None
|
||||
)
|
||||
page.locator(
|
||||
'motion.div.vertical_page[data-page="0"], div.vertical_page[data-page="0"]'
|
||||
).first.wait_for()
|
||||
chapter_pages = page.locator("motion.div.vertical_page, div.vertical_page")
|
||||
page_count = chapter_pages.count()
|
||||
|
||||
chapter_writer = PdfWriter()
|
||||
for page_no in range(1, page_count + 1):
|
||||
page_elem = chapter_pages.nth(page_no - 1)
|
||||
html = page_elem.inner_html()
|
||||
html = html.replace('src="/', 'src="https://www.scribd.com/')
|
||||
|
||||
match = re.findall(
|
||||
r"width: ([0-9.]+)px; height: ([0-9.]+)px;", html
|
||||
)
|
||||
if not match:
|
||||
continue
|
||||
width, height = float(match[0]), float(match[1])
|
||||
style = (
|
||||
f"@page {{ size: {width * ZOOM}px {height * ZOOM}px; margin: 0; }} "
|
||||
f"@media print {{ html, body {{ height: {height * ZOOM}px; "
|
||||
f"width: {width * ZOOM}px;}}}}"
|
||||
)
|
||||
html = re.sub(
|
||||
'data-colindex="0" style="',
|
||||
'data-colindex="0" x="',
|
||||
html,
|
||||
)
|
||||
html = re.sub(
|
||||
r'position: absolute.*?"',
|
||||
f'overflow: hidden; height: {height}px; width: {width}px; '
|
||||
f'white-space: nowrap; zoom: {ZOOM};"',
|
||||
html,
|
||||
)
|
||||
|
||||
content = f"<html><head>{style}{font_style}</head><body>{html}</body></html>"
|
||||
render_page.set_content(content)
|
||||
part_pdf = cache_dir / f"{chapter_no}_{page_no}.pdf"
|
||||
render_page.pdf(path=str(part_pdf), prefer_css_page_size=True)
|
||||
chapter_writer.append(str(part_pdf))
|
||||
part_pdf.unlink(missing_ok=True)
|
||||
|
||||
chapter_pdf = cache_dir / f"{chapter_no}.pdf"
|
||||
with open(chapter_pdf, "wb") as f:
|
||||
chapter_writer.write(f)
|
||||
progress.remove_task(task)
|
||||
|
||||
if chapter_no >= num_chapters:
|
||||
break
|
||||
page.evaluate(
|
||||
"() => document.querySelectorAll('button.load_next_btn')[0].click()"
|
||||
)
|
||||
time.sleep(1)
|
||||
chapter_no += 1
|
||||
|
||||
output_path = Path(output or f"{book_title}.pdf")
|
||||
if output_path.suffix.lower() != ".pdf":
|
||||
output_path = output_path.with_suffix(".pdf")
|
||||
|
||||
final_writer = PdfWriter()
|
||||
for ch in range(1, num_chapters + 1):
|
||||
final_writer.append(str(cache_dir / f"{ch}.pdf"))
|
||||
with open(output_path, "wb") as f:
|
||||
final_writer.write(f)
|
||||
|
||||
shutil.rmtree(cache_dir, ignore_errors=True)
|
||||
context.close()
|
||||
browser.close()
|
||||
|
||||
console.print(f"[bold green]Saved:[/bold green] {output_path.resolve()}")
|
||||
return output_path
|
||||
@@ -0,0 +1,157 @@
|
||||
"""Download Scribd documents (PDF uploads, presentations) as a single PDF."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
import img2pdf
|
||||
from playwright.sync_api import BrowserContext, Page, sync_playwright
|
||||
from rich.console import Console
|
||||
from rich.progress import BarColumn, Progress, SpinnerColumn, TaskProgressColumn, TextColumn
|
||||
|
||||
from scribd_downloader.auth import open_browser
|
||||
from scribd_downloader.pages import parse_page_selection
|
||||
from scribd_downloader.url import ScribdTarget, sanitize_filename
|
||||
|
||||
console = Console()
|
||||
TEMP_DIR = Path("temp_capture")
|
||||
|
||||
ProgressCallback = Callable[[int, int, str], None]
|
||||
PageCallback = Callable[[Path, int, int], None]
|
||||
|
||||
|
||||
def _block_noise(context: BrowserContext) -> None:
|
||||
for pattern in ("**/*osano*/**", "**/*analytics*/**", "**/*doubleclick*/**"):
|
||||
context.route(pattern, lambda route: route.abort())
|
||||
|
||||
|
||||
def _document_title(page: Page, target: ScribdTarget) -> str:
|
||||
title = page.evaluate(
|
||||
"""() => {
|
||||
const og = document.querySelector('meta[property="og:title"]')?.content;
|
||||
if (og && og.toLowerCase() !== 'scribd') return og.trim();
|
||||
const inner = document.querySelector('.title_text, .doc_title')?.innerText;
|
||||
return inner ? inner.trim() : '';
|
||||
}"""
|
||||
)
|
||||
if title:
|
||||
return sanitize_filename(title)
|
||||
if target.title_slug:
|
||||
return sanitize_filename(target.title_slug)
|
||||
return "scribd_document"
|
||||
|
||||
|
||||
def download_document(
|
||||
target: ScribdTarget,
|
||||
*,
|
||||
output: str | None = None,
|
||||
pages: str = "all",
|
||||
delay: float = 2.0,
|
||||
scale: int = 2,
|
||||
headless: bool = True,
|
||||
use_session: bool = True,
|
||||
on_progress: ProgressCallback | None = None,
|
||||
on_page: PageCallback | None = None,
|
||||
) -> Path:
|
||||
"""Capture document pages via the embed viewer and merge into one PDF."""
|
||||
TEMP_DIR.mkdir(exist_ok=True)
|
||||
|
||||
with sync_playwright() as playwright:
|
||||
browser, context = open_browser(
|
||||
playwright,
|
||||
headless=headless,
|
||||
use_session=use_session,
|
||||
device_scale_factor=float(scale),
|
||||
)
|
||||
_block_noise(context)
|
||||
page = context.new_page()
|
||||
|
||||
if on_progress:
|
||||
on_progress(0, 1, "Loading document from Scribd…")
|
||||
else:
|
||||
console.print("[cyan]Loading document from Scribd…[/cyan]")
|
||||
page.goto(target.embed_url, wait_until="domcontentloaded", timeout=90_000)
|
||||
|
||||
try:
|
||||
page.wait_for_selector(".outer_page", timeout=20_000)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
total = page.locator(".outer_page").count()
|
||||
if total == 0:
|
||||
context.close()
|
||||
browser.close()
|
||||
raise RuntimeError(
|
||||
"No pages found. The document may be private, removed, or blocked. "
|
||||
"Try: scribd-dl login"
|
||||
)
|
||||
|
||||
doc_title = _document_title(page, target)
|
||||
if not on_progress:
|
||||
console.print(f"[dim]Title:[/dim] [bold]{doc_title}[/bold]")
|
||||
console.print(f"[dim]Pages:[/dim] [bold cyan]{total}[/bold cyan]")
|
||||
|
||||
indices = parse_page_selection(pages, total)
|
||||
image_paths: list[Path] = []
|
||||
locators = page.locator(".outer_page")
|
||||
total_capture = len(indices)
|
||||
|
||||
def capture_pages() -> None:
|
||||
for n, idx in enumerate(indices, start=1):
|
||||
if on_progress:
|
||||
on_progress(n - 1, total_capture, f"Capturing page {idx + 1}…")
|
||||
element = locators.nth(idx)
|
||||
element.scroll_into_view_if_needed()
|
||||
time.sleep(delay)
|
||||
img_path = TEMP_DIR / f"page_{idx + 1:04d}.png"
|
||||
element.screenshot(path=str(img_path))
|
||||
image_paths.append(img_path)
|
||||
if on_page:
|
||||
on_page(img_path, idx + 1, total)
|
||||
|
||||
if on_progress:
|
||||
capture_pages()
|
||||
on_progress(total_capture, total_capture, "Building PDF…")
|
||||
else:
|
||||
with Progress(
|
||||
SpinnerColumn(),
|
||||
TextColumn("[progress.description]{task.description}"),
|
||||
BarColumn(),
|
||||
TaskProgressColumn(),
|
||||
console=console,
|
||||
) as progress:
|
||||
task = progress.add_task("Capturing pages…", total=total_capture)
|
||||
for n, idx in enumerate(indices, start=1):
|
||||
element = locators.nth(idx)
|
||||
element.scroll_into_view_if_needed()
|
||||
time.sleep(delay)
|
||||
img_path = TEMP_DIR / f"page_{idx + 1:04d}.png"
|
||||
element.screenshot(path=str(img_path))
|
||||
image_paths.append(img_path)
|
||||
progress.advance(task)
|
||||
progress.update(task, description="Building PDF…")
|
||||
|
||||
output_path = Path(output) if output else Path(f"{doc_title}.pdf")
|
||||
if not output_path.suffix.lower() == ".pdf":
|
||||
output_path = output_path.with_suffix(".pdf")
|
||||
if pages.strip().lower() != "all":
|
||||
stem = output_path.stem
|
||||
safe_range = pages.replace(" ", "")
|
||||
output_path = output_path.with_name(f"{stem}_[{safe_range}].pdf")
|
||||
|
||||
with open(output_path, "wb") as pdf_file:
|
||||
pdf_file.write(img2pdf.convert([str(p) for p in image_paths]))
|
||||
|
||||
context.close()
|
||||
browser.close()
|
||||
|
||||
for img in image_paths:
|
||||
img.unlink(missing_ok=True)
|
||||
if TEMP_DIR.exists() and not any(TEMP_DIR.iterdir()):
|
||||
TEMP_DIR.rmdir()
|
||||
|
||||
if not on_progress:
|
||||
console.print(f"[bold green]Saved:[/bold green] {output_path.resolve()}")
|
||||
return output_path
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Page range parsing for partial downloads."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def parse_page_selection(selection: str, total_pages: int) -> list[int]:
|
||||
"""Return zero-based page indices from strings like 'all', '3', or '1-10'."""
|
||||
selection = selection.strip().lower()
|
||||
if not selection or selection == "all":
|
||||
return list(range(total_pages))
|
||||
|
||||
indices: set[int] = set()
|
||||
for part in selection.split(","):
|
||||
part = part.strip()
|
||||
if not part:
|
||||
continue
|
||||
if "-" in part:
|
||||
start_s, end_s = part.split("-", 1)
|
||||
start, end = int(start_s), int(end_s)
|
||||
if start < 1 or end > total_pages or start > end:
|
||||
raise ValueError(
|
||||
f"Range {start}-{end} is outside document bounds (1-{total_pages})."
|
||||
)
|
||||
indices.update(range(start - 1, end))
|
||||
else:
|
||||
page_num = int(part)
|
||||
if page_num < 1 or page_num > total_pages:
|
||||
raise ValueError(
|
||||
f"Page {page_num} is outside document bounds (1-{total_pages})."
|
||||
)
|
||||
indices.add(page_num - 1)
|
||||
|
||||
return sorted(indices)
|
||||
@@ -0,0 +1,80 @@
|
||||
"""Load Scribd documents and capture preview screenshots."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from playwright.sync_api import Page, sync_playwright
|
||||
|
||||
from scribd_downloader.auth import open_browser
|
||||
from scribd_downloader.document import TEMP_DIR, _block_noise, _document_title
|
||||
from scribd_downloader.url import ScribdTarget
|
||||
|
||||
PREVIEW_DIR = Path("temp_preview")
|
||||
|
||||
|
||||
@dataclass
|
||||
class DocumentInfo:
|
||||
title: str
|
||||
total_pages: int
|
||||
preview_path: Path
|
||||
|
||||
|
||||
def load_document_preview(
|
||||
target: ScribdTarget,
|
||||
*,
|
||||
page_index: int = 0,
|
||||
scale: int = 2,
|
||||
use_session: bool = True,
|
||||
) -> DocumentInfo:
|
||||
"""Open the embed viewer and screenshot one page for preview."""
|
||||
PREVIEW_DIR.mkdir(exist_ok=True)
|
||||
page_index = max(0, page_index)
|
||||
|
||||
with sync_playwright() as playwright:
|
||||
browser, context = open_browser(
|
||||
playwright,
|
||||
headless=True,
|
||||
use_session=use_session,
|
||||
device_scale_factor=float(scale),
|
||||
)
|
||||
_block_noise(context)
|
||||
page = context.new_page()
|
||||
title, total, preview_path = _load_page(
|
||||
page, target, page_index=page_index
|
||||
)
|
||||
context.close()
|
||||
browser.close()
|
||||
|
||||
return DocumentInfo(title=title, total_pages=total, preview_path=preview_path)
|
||||
|
||||
|
||||
def _load_page(
|
||||
page: Page,
|
||||
target: ScribdTarget,
|
||||
*,
|
||||
page_index: int,
|
||||
) -> tuple[str, int, Path]:
|
||||
page.goto(target.embed_url, wait_until="domcontentloaded", timeout=90_000)
|
||||
try:
|
||||
page.wait_for_selector(".outer_page", timeout=20_000)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
total = page.locator(".outer_page").count()
|
||||
if total == 0:
|
||||
raise RuntimeError(
|
||||
"No pages found. The document may be private or unavailable."
|
||||
)
|
||||
|
||||
title = _document_title(page, target)
|
||||
index = min(page_index, total - 1)
|
||||
element = page.locator(".outer_page").nth(index)
|
||||
element.scroll_into_view_if_needed()
|
||||
time.sleep(0.5)
|
||||
|
||||
preview_path = PREVIEW_DIR / f"preview_{index + 1}.png"
|
||||
element.screenshot(path=str(preview_path))
|
||||
return title, total, preview_path
|
||||
@@ -0,0 +1,102 @@
|
||||
"""Parse Scribd URLs and build viewer URLs."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from urllib.parse import unquote
|
||||
|
||||
|
||||
class ContentType(str, Enum):
|
||||
DOCUMENT = "document"
|
||||
BOOK = "book"
|
||||
UNKNOWN = "unknown"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ScribdTarget:
|
||||
content_id: str
|
||||
content_type: ContentType
|
||||
original_url: str
|
||||
title_slug: str | None = None
|
||||
|
||||
@property
|
||||
def embed_url(self) -> str:
|
||||
return (
|
||||
f"https://www.scribd.com/embeds/{self.content_id}/content"
|
||||
f"?start_page=1&view_mode=scroll"
|
||||
)
|
||||
|
||||
@property
|
||||
def read_url(self) -> str | None:
|
||||
if self.content_type != ContentType.BOOK:
|
||||
return None
|
||||
return self.original_url.replace("/book/", "/read/").replace(
|
||||
"scribd.com/book", "scribd.com/read"
|
||||
)
|
||||
|
||||
|
||||
_ID_PATTERN = re.compile(
|
||||
r"/(?:document|presentation|doc|book|article|listen)/(\d+)",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
|
||||
def parse_scribd_url(url: str) -> ScribdTarget:
|
||||
"""Extract document/book id and type from a Scribd URL."""
|
||||
url = url.strip()
|
||||
if url.isdigit():
|
||||
return ScribdTarget(
|
||||
content_id=url,
|
||||
content_type=ContentType.DOCUMENT,
|
||||
original_url=f"https://www.scribd.com/document/{url}",
|
||||
)
|
||||
|
||||
match = _ID_PATTERN.search(url)
|
||||
if not match:
|
||||
raise ValueError(
|
||||
"Invalid Scribd URL. Expected formats like:\n"
|
||||
" https://www.scribd.com/document/123456/Title\n"
|
||||
" https://www.scribd.com/book/123456/Title"
|
||||
)
|
||||
|
||||
content_id = match.group(1)
|
||||
path_lower = url.lower()
|
||||
if "/book/" in path_lower:
|
||||
content_type = ContentType.BOOK
|
||||
elif any(
|
||||
segment in path_lower
|
||||
for segment in ("/document/", "/doc/", "/presentation/", "/article/")
|
||||
):
|
||||
content_type = ContentType.DOCUMENT
|
||||
else:
|
||||
content_type = ContentType.DOCUMENT
|
||||
|
||||
slug = _title_slug_from_url(url)
|
||||
return ScribdTarget(
|
||||
content_id=content_id,
|
||||
content_type=content_type,
|
||||
original_url=url.split("#")[0].split("?")[0],
|
||||
title_slug=slug,
|
||||
)
|
||||
|
||||
|
||||
def _title_slug_from_url(url: str) -> str | None:
|
||||
clean = url.split("#")[0].split("?")[0].rstrip("/")
|
||||
parts = clean.split("/")
|
||||
if len(parts) < 2:
|
||||
return None
|
||||
last = parts[-1]
|
||||
if last.isdigit():
|
||||
return None
|
||||
return unquote(last).replace("-", " ").replace("_", " ")
|
||||
|
||||
|
||||
def sanitize_filename(name: str, max_length: int = 120) -> str:
|
||||
cleaned = "".join(c for c in name if c.isalnum() or c in (" ", "-", "_")).strip()
|
||||
if not cleaned:
|
||||
cleaned = "scribd_download"
|
||||
if len(cleaned) > max_length:
|
||||
cleaned = cleaned[:max_length].rstrip()
|
||||
return cleaned
|
||||
Reference in new issue
Block a user