|
| 1 | +import string |
| 2 | +import random |
| 3 | +import time |
| 4 | + |
| 5 | +from yt_dlp.extractor.common import InfoExtractor |
| 6 | + |
| 7 | + |
| 8 | +class DoodStreamIE(InfoExtractor): |
| 9 | + _VALID_URL = ( |
| 10 | + r"https?://(?:www\.)?dood\.(?:to|watch|so|pm|wf|sh)/[ed]/(?P<id>[a-z0-9]+)" |
| 11 | + ) |
| 12 | + _TESTS = [ |
| 13 | + { |
| 14 | + "url": "http://dood.to/e/5s1wmbdacezb", |
| 15 | + "md5": "4568b83b31e13242b3f1ff96c55f0595", |
| 16 | + "info_dict": { |
| 17 | + "id": "5s1wmbdacezb", |
| 18 | + "ext": "mp4", |
| 19 | + "title": "Kat Wonders - Monthly May 2020", |
| 20 | + "description": "Kat Wonders - Monthly May 2020 | DoodStream.com", |
| 21 | + "thumbnail": "https://img.doodcdn.com/snaps/flyus84qgl2fsk4g.jpg", |
| 22 | + }, |
| 23 | + }, |
| 24 | + { |
| 25 | + "url": "http://dood.watch/d/5s1wmbdacezb", |
| 26 | + "md5": "4568b83b31e13242b3f1ff96c55f0595", |
| 27 | + "info_dict": { |
| 28 | + "id": "5s1wmbdacezb", |
| 29 | + "ext": "mp4", |
| 30 | + "title": "Kat Wonders - Monthly May 2020", |
| 31 | + "description": "Kat Wonders - Monthly May 2020 | DoodStream.com", |
| 32 | + "thumbnail": "https://img.doodcdn.com/snaps/flyus84qgl2fsk4g.jpg", |
| 33 | + }, |
| 34 | + }, |
| 35 | + { |
| 36 | + "url": "https://dood.to/d/jzrxn12t2s7n", |
| 37 | + "md5": "3207e199426eca7c2aa23c2872e6728a", |
| 38 | + "info_dict": { |
| 39 | + "id": "jzrxn12t2s7n", |
| 40 | + "ext": "mp4", |
| 41 | + "title": "Stacy Cruz Cute ALLWAYSWELL", |
| 42 | + "description": "Stacy Cruz Cute ALLWAYSWELL | DoodStream.com", |
| 43 | + "thumbnail": "https://img.doodcdn.com/snaps/8edqd5nppkac3x8u.jpg", |
| 44 | + }, |
| 45 | + }, |
| 46 | + {"url": "https://dood.so/d/jzrxn12t2s7n", "only_matching": True}, |
| 47 | + ] |
| 48 | + |
| 49 | + def _real_extract(self, url): |
| 50 | + video_id = self._match_id(url) |
| 51 | + url = f"https://dood.to/e/{video_id}" |
| 52 | + webpage = self._download_webpage(url, video_id) |
| 53 | + |
| 54 | + title = self._html_search_meta( |
| 55 | + ("og:title", "twitter:title"), webpage, default=None |
| 56 | + ) or self._html_extract_title(webpage) |
| 57 | + thumb = self._html_search_meta( |
| 58 | + ["og:image", "twitter:image"], webpage, default=None |
| 59 | + ) |
| 60 | + token = self._html_search_regex(r"[?&]token=([a-z0-9]+)[&\']", webpage, "token") |
| 61 | + description = self._html_search_meta( |
| 62 | + ["og:description", "description", "twitter:description"], |
| 63 | + webpage, |
| 64 | + default=None, |
| 65 | + ) |
| 66 | + |
| 67 | + headers = { |
| 68 | + "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/66.0", |
| 69 | + "referer": url, |
| 70 | + } |
| 71 | + |
| 72 | + pass_md5 = self._html_search_regex(r"(/pass_md5.*?)\'", webpage, "pass_md5") |
| 73 | + final_url = "".join( |
| 74 | + ( |
| 75 | + self._download_webpage( |
| 76 | + f"https://dood.to{pass_md5}", video_id, headers=headers |
| 77 | + ), |
| 78 | + *( |
| 79 | + random.choice(string.ascii_letters + string.digits) |
| 80 | + for _ in range(10) |
| 81 | + ), |
| 82 | + f"?token={token}&expiry={int(time.time() * 1000)}", |
| 83 | + ) |
| 84 | + ) |
| 85 | + |
| 86 | + return { |
| 87 | + "id": video_id, |
| 88 | + "title": title, |
| 89 | + "url": final_url, |
| 90 | + "http_headers": headers, |
| 91 | + "ext": "mp4", |
| 92 | + "description": description, |
| 93 | + "thumbnail": thumb, |
| 94 | + } |
0 commit comments