Skip to content

Commit

Permalink
[fappic] add 'image' extractor (closes #1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Sep 28, 2021
1 parent c22ff97 commit e0bdacd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ Consider all sites to be NSFW unless otherwise known.
<td>Creators, Posts</td>
<td><a href="https://github.com/mikf/gallery-dl#cookies">Cookies</a></td>
</tr>
<tr>
<td>Fappic</td>
<td>https://fappic.com/</td>
<td>individual Images</td>
<td></td>
</tr>
<tr>
<td>Flickr</td>
<td>https://www.flickr.com/</td>
Expand Down
20 changes: 20 additions & 0 deletions gallery_dl/extractor/imagehosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,23 @@ def get_info(self, page):
url , pos = text.extract(page, '<br><img src="', '"')
filename, pos = text.extract(page, 'alt="', '"', pos)
return url, filename


class FappicImageExtractor(ImagehostImageExtractor):
"""Extractor for single images from fappic.com"""
category = "fappic"
pattern = r"(?:https?://)?((?:www\.)?fappic\.com/(\w+)/[^/?#]+)"
test = ("https://www.fappic.com/98wxqcklyh8k/test.png", {
"pattern": r"https://img\d+\.fappic\.com/img/\w+/test\.png",
"keyword": "433b1d310b0ff12ad8a71ac7b9d8ba3f8cd1e898",
"content": "0c8768055e4e20e7c7259608b67799171b691140",
})

def get_info(self, page):
url , pos = text.extract(page, '<a href="/?click"><img src="', '"')
filename, pos = text.extract(page, 'alt="', '"', pos)

if filename.startswith("Porn-Picture-"):
filename = filename[13:]

return url, filename
5 changes: 3 additions & 2 deletions test/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import datetime

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from gallery_dl import extractor, util, job, config, exception # noqa E402
from gallery_dl import \
extractor, util, job, config, exception, formatter # noqa E402


# temporary issues, etc.
Expand Down Expand Up @@ -262,7 +263,7 @@ def part_size(self):
return 0


class TestFormatter(util.Formatter):
class TestFormatter(formatter.StringFormatter):

@staticmethod
def _noop(_):
Expand Down

0 comments on commit e0bdacd

Please sign in to comment.