From 3c75c3bbc42b76afd09c0e01b6237936bd70f67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 12 Dec 2022 12:23:59 +0100 Subject: [PATCH] [soundgasm] add 'user' extractor (#3384) based on code from PR #3388 by @enduser420 --- docs/supportedsites.md | 2 +- gallery_dl/extractor/soundgasm.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index 919e679d..bca3e424 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -772,7 +772,7 @@ Consider all sites to be NSFW unless otherwise known. Soundgasm https://soundgasm.net/ - Audio + Audio, User Profiles diff --git a/gallery_dl/extractor/soundgasm.py b/gallery_dl/extractor/soundgasm.py index e0c1c361..4bd2bcbd 100644 --- a/gallery_dl/extractor/soundgasm.py +++ b/gallery_dl/extractor/soundgasm.py @@ -15,11 +15,13 @@ from .. import text class SoundgasmAudioExtractor(Extractor): """Extractor for audio clips from soundgasm.net""" category = "soundgasm" + subcategory = "audio" root = "https://soundgasm.net" directory_fmt = ("{category}", "{user}") filename_fmt = "{title}.{extension}" archive_fmt = "{user}_{filename}" - pattern = r"(?:https?://)?(?:www\.)?soundgasm\.net/u/([^/?#]+)/([^/?#]+)" + pattern = (r"(?:https?://)?(?:www\.)?soundgasm\.net" + r"/u(?:ser)?/([^/?#]+)/([^/?#]+)") test = ( (("https://soundgasm.net/u/ClassWarAndPuppies2" "/687-Otto-von-Toontown-12822"), { @@ -40,6 +42,8 @@ class SoundgasmAudioExtractor(Extractor): "user": "ClassWarAndPuppies2", }, }), + ("https://www.soundgasm.net/user/ClassWarAndPuppies2" + "/687-Otto-von-Toontown-12822"), ) def __init__(self, match): @@ -63,3 +67,27 @@ class SoundgasmAudioExtractor(Extractor): yield Message.Directory, data yield Message.Url, url, text.nameext_from_url(url, data) + + +class SoundgasmUserExtractor(Extractor): + """Extractor for all sounds from a soundgasm user""" + category = "soundgasm" + subcategory = "user" + root = "https://soundgasm.net" + pattern = (r"(?:https?://)?(?:www\.)?soundgasm\.net" + r"/u(?:ser)?/([^/?#]+)/?$") + test = ("https://soundgasm.net/u/fierce-aphrodite", { + "pattern": SoundgasmAudioExtractor.pattern, + "count" : ">= 15", + }) + + def __init__(self, match): + Extractor.__init__(self, match) + self.user = match.group(1) + + def items(self): + page = self.request(self.root + "/user/" + self.user).text + data = {"_extractor": SoundgasmAudioExtractor} + for sound in text.extract_iter( + page, 'class="sound-details">', ""): + yield Message.Queue, text.extr(sound, '