Skip to content

Commit

Permalink
[soundgasm] add 'user' extractor (#3384)
Browse files Browse the repository at this point in the history
based on code from PR #3388 by @enduser420
  • Loading branch information
mikf committed Dec 12, 2022
1 parent 2952add commit 3c75c3b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ Consider all sites to be NSFW unless otherwise known.
<tr>
<td>Soundgasm</td>
<td>https://soundgasm.net/</td>
<td>Audio</td>
<td>Audio, User Profiles</td>
<td></td>
</tr>
<tr>
Expand Down
30 changes: 29 additions & 1 deletion gallery_dl/extractor/soundgasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
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"), {
Expand All @@ -40,6 +42,8 @@ class SoundgasmAudioExtractor(Extractor):
"user": "ClassWarAndPuppies2",
},
}),
("https://www.soundgasm.net/user/ClassWarAndPuppies2"
"/687-Otto-von-Toontown-12822"),
)

def __init__(self, match):
Expand All @@ -63,3 +67,27 @@ def items(self):

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">', "</a>"):
yield Message.Queue, text.extr(sound, '<a href="', '"'), data

0 comments on commit 3c75c3b

Please sign in to comment.