37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import sys
|
|
from pathlib import Path
|
|
from urllib.parse import urlparse
|
|
|
|
# Add parent workspace directory to path to import generic_downloader
|
|
sys.path.append(str(Path(__file__).resolve().parents[1]))
|
|
import generic_downloader
|
|
|
|
def is_video_link(url):
|
|
# Match watch/video URLs like: /video/slug_id, /videos/slug_id, or /watch/slug_id
|
|
return "/video" in url or "/watch" in url
|
|
|
|
if __name__ == "__main__":
|
|
uploader_eval = """() => {
|
|
const el = Array.from(document.querySelectorAll('a[href*="/user/"], a[href*="/users/"], a[href*="/profile/"], .uploader-name'))
|
|
.find(a => a.innerText.trim() !== '');
|
|
if (el) {
|
|
const h3 = el.querySelector('h3');
|
|
if (h3) {
|
|
const clone = h3.cloneNode(true);
|
|
const spans = clone.querySelectorAll('span');
|
|
spans.forEach(s => s.remove());
|
|
return clone.textContent.trim();
|
|
}
|
|
return el.innerText.replace(/uploader/gi, '').trim();
|
|
}
|
|
return 'unknown';
|
|
}"""
|
|
|
|
generic_downloader.run(
|
|
site_name="PMVHaven",
|
|
is_video_link_fn=is_video_link,
|
|
next_page_selector="a:has-text('Next'), .next, a.pagination-next",
|
|
video_selector="video",
|
|
uploader_eval_js=uploader_eval
|
|
)
|