From d4ce8be1f5cfdb5a805bc57e11832b25b8f7bd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 27 Mar 2025 21:56:06 +0100 Subject: [PATCH] [sexcom] support new-style '/videos' URLs (#7239) --- gallery_dl/extractor/sexcom.py | 31 +++++++++++++++++-- test/results/sexcom.py | 55 +++++++++++++++++++++++++++++++++- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/gallery_dl/extractor/sexcom.py b/gallery_dl/extractor/sexcom.py index 47f5489e..f49c0b79 100644 --- a/gallery_dl/extractor/sexcom.py +++ b/gallery_dl/extractor/sexcom.py @@ -58,7 +58,9 @@ class SexcomExtractor(Extractor): if "/pin/" in response.url: return self._parse_pin_legacy(response) - return self._parse_pin_new(response) + if "/videos/" in response.url: + return self._parse_pin_video(response) + return self._parse_pin_gifs(response) def _parse_pin_legacy(self, response): extr = text.extract_from(response.text) @@ -109,8 +111,9 @@ class SexcomExtractor(Extractor): return data - def _parse_pin_new(self, response): + def _parse_pin_gifs(self, response): extr = text.extract_from(response.text) + data = { "_http_headers": {"Referer": response.url}, "type": "gif", @@ -123,12 +126,34 @@ class SexcomExtractor(Extractor): return text.nameext_from_url(data["url"], data) + def _parse_pin_video(self, response): + extr = text.extract_from(response.text) + + if not self.cookies.get("CloudFront-Key-Pair-Id", domain=".sex.com"): + self.log.warning("CloudFront cookies required for video downloads") + + data = { + "_ytdl_manifest": "hls", + "extension": "mp4", + "type": "video", + "title": text.unescape(extr("", " | Sex.com<")), + "pin_id": text.parse_int(extr( + 'rel="canonical" href="', '"').rpartition("/")[2]), + "tags": text.split_html(extr( + 'event_name="video_tags_click"', "<div data-testid=") + .partition(">")[2]), + "url": "ytdl:" + extr('<source src="', '"'), + } + + return data + class SexcomPinExtractor(SexcomExtractor): """Extractor for a pinned image or video on www.sex.com""" subcategory = "pin" directory_fmt = ("{category}",) - pattern = BASE_PATTERN + r"(/(?:pin|\w\w/gifs)/\d+/?)(?!.*#related$)" + pattern = (BASE_PATTERN + + r"(/(?:pin|\w\w/(?:gif|video)s)/\d+/?)(?!.*#related$)") example = "https://www.sex.com/pin/12345-TITLE/" def pins(self): diff --git a/test/results/sexcom.py b/test/results/sexcom.py index a3818850..d47dc0e2 100644 --- a/test/results/sexcom.py +++ b/test/results/sexcom.py @@ -78,11 +78,64 @@ __tests__ = ( { "#url" : "https://www.sex.com/pin/55748341/", - "#comment" : "video", + "#comment" : "video legacy URL", "#category": ("", "sexcom", "pin"), "#class" : sexcom.SexcomPinExtractor, "#urls" : "https://video1.sx.cdn.live/videos/pinporn/2018/02/10/776229_hd.mp4", "#sha1_content": "e1a5834869163e2c4d1ca2677f5b7b367cf8cfff", + + "comments" : range(0, 5), + "date" : "2018-02-10 14:58:55", + "extension": "mp4", + "filename" : "776229_hd", + "likes" : range(30, 50), + "pin_id" : 55748341, + "repins" : range(10, 20), + "thumbnail": "https://imagex1.sx.cdn.live/images/pinporn/2018/02/10/19082009.jpg?width=300", + "title" : "Pin #55748341", + "type" : "video", + "uploader" : "Vinsein", + "url" : "https://video1.sx.cdn.live/videos/pinporn/2018/02/10/776229_hd.mp4", + "tags": [ + "Hentai", + ], +}, + +{ + "#url" : "https://www.sex.com/en/videos/680933", + "#comment" : "video", + "#category": ("", "sexcom", "pin"), + "#class" : sexcom.SexcomPinExtractor, + "#urls" : "ytdl:https://videos.sex.com/680933/video.m3u8", + + "extension": "mp4", + "pin_id" : 680933, + "title" : "Underwater Big Boobs Kristy with Small Boobs Petra", + "type" : "video", + "url" : "ytdl:https://videos.sex.com/680933/video.m3u8", + "tags" : [ + "#Babe", + "#Beach", + "#Big Boobs", + "#Bikini", + "#Brunette", + "#Brunette Babe", + "#Girlfriend", + "#Natural Tits", + "#Nude", + "#Pool", + "#Poolside", + "#Public Sex", + "#Russian", + "#Shower", + "#Small Boobs", + "#Swimming", + "#Swimming Pool", + "#Tight Pussy", + "#Underwater", + "#With", + "#Young", + ], }, {