Skip to content

Commit

Permalink
[wallpapercave] add extractor for images
Browse files Browse the repository at this point in the history
  • Loading branch information
Demindiro committed Jan 18, 2022
1 parent c587b67 commit ea77108
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,12 @@ Consider all sites to be NSFW unless otherwise known.
<td>Collections, individual Images, Search Results</td>
<td><a href="configuration.rst#extractorwallhavenapi-key">API Key</a></td>
</tr>
<tr>
<td>WallpaperCave</td>
<td>https://wallpapercave.com/</td>
<td>individual Images, Search Results</td>
<td></td>
</tr>
<tr>
<td>Warosu</td>
<td>https://warosu.org/</td>
Expand Down
1 change: 1 addition & 0 deletions gallery_dl/extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"vk",
"vsco",
"wallhaven",
"wallpapercave",
"warosu",
"weasyl",
"webtoons",
Expand Down
34 changes: 34 additions & 0 deletions gallery_dl/extractor/wallpapercave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

# Copyright 2021 David Hoppenbrouwers
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""Extractor for https://wallpapercave.com/"""

import re
from .common import Extractor, Message
from .. import text


class WallpapercaveImageExtractor(Extractor):
"""Extractor for images on wallpapercave.com"""
category = "wallpapercave"
subcategory = "image"
root = "https://wallpapercave.com"
pattern = r"(?:https?://)?(?:www\.)?wallpapercave\.com"

def __init__(self, match):
super().__init__(match)
self.url = match.string

def items(self):
page = self.request(self.url).text
paths = re.compile(r'<a class="download" href="(.+?)">').findall(page)
for path in paths:
url = self.root + path
image = {}
yield Message.Directory, image
yield Message.Url, url, text.nameext_from_url(url, image)

0 comments on commit ea77108

Please sign in to comment.