Enhanced URL input with validation
(self)
| 364 | return file_path |
| 365 | |
| 366 | def get_url_input(self) -> str: |
| 367 | """Enhanced URL input with validation""" |
| 368 | self.print_separator("─", 79, Colors.GREEN) |
| 369 | print(f"{Colors.BOLD}{Colors.GREEN}🌐 URL Input Interface{Colors.ENDC}") |
| 370 | print( |
| 371 | f"{Colors.CYAN}Enter a research paper URL from supported platforms:{Colors.ENDC}" |
| 372 | ) |
| 373 | print( |
| 374 | f"{Colors.CYAN}• arXiv (arxiv.org) • IEEE Xplore (ieeexplore.ieee.org){Colors.ENDC}" |
| 375 | ) |
| 376 | print( |
| 377 | f"{Colors.CYAN}• ACM Digital Library • SpringerLink • Nature • Science{Colors.ENDC}" |
| 378 | ) |
| 379 | print( |
| 380 | f"{Colors.CYAN}• Direct PDF links • Academic publisher websites{Colors.ENDC}" |
| 381 | ) |
| 382 | self.print_separator("─", 79, Colors.GREEN) |
| 383 | |
| 384 | while True: |
| 385 | print(f"\n{Colors.BOLD}{Colors.OKCYAN}🔗 URL: {Colors.ENDC}", end="") |
| 386 | url = input().strip() |
| 387 | |
| 388 | if not url: |
| 389 | self.print_status( |
| 390 | "Empty URL entered. Please try again or press Ctrl+C to cancel.", |
| 391 | "warning", |
| 392 | ) |
| 393 | continue |
| 394 | |
| 395 | if not url.startswith(("http://", "https://")): |
| 396 | self.print_status("URL must start with http:// or https://", "error") |
| 397 | retry = ( |
| 398 | input(f"{Colors.YELLOW}Try again? (y/n): {Colors.ENDC}") |
| 399 | .strip() |
| 400 | .lower() |
| 401 | ) |
| 402 | if retry != "y": |
| 403 | return "" |
| 404 | continue |
| 405 | |
| 406 | academic_domains = [ |
| 407 | "arxiv.org", |
| 408 | "ieeexplore.ieee.org", |
| 409 | "dl.acm.org", |
| 410 | "link.springer.com", |
| 411 | "nature.com", |
| 412 | "science.org", |
| 413 | "scholar.google.com", |
| 414 | "researchgate.net", |
| 415 | "semanticscholar.org", |
| 416 | ] |
| 417 | |
| 418 | is_academic = any(domain in url.lower() for domain in academic_domains) |
| 419 | if not is_academic and not url.lower().endswith(".pdf"): |
| 420 | self.print_status( |
| 421 | "URL doesn't appear to be from a known academic platform", "warning" |
| 422 | ) |
| 423 | proceed = ( |
no test coverage detected