-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wallpapercave] add extractor for images
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,7 @@ | |
"vk", | ||
"vsco", | ||
"wallhaven", | ||
"wallpapercave", | ||
"warosu", | ||
"weasyl", | ||
"webtoons", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |