Skip to content

Commit

Permalink
[pornreactor] add tag-, user-, post-extractors (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Nov 23, 2018
1 parent bacbc2e commit a0ae156
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 8 deletions.
1 change: 1 addition & 0 deletions gallery_dl/extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"piczel",
"pinterest",
"pixiv",
"pornreactor",
"powermanga",
"readcomiconline",
"rebeccablacktech",
Expand Down
19 changes: 11 additions & 8 deletions gallery_dl/extractor/joyreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""Extractors for http://joyreactor.com/"""
"""Extractors for http://joyreactor.cc/"""

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


BASE_PATTERN = r"(?:https?://)?(?:www\.)?(joyreactor\.c(?:c|om))"


class JoyreactorExtractor(Extractor):
"""Base class for joyreactor extractors"""
category = "joyreactor"
Expand All @@ -23,7 +26,7 @@ class JoyreactorExtractor(Extractor):
def __init__(self, match):
Extractor.__init__(self)
self.url = match.group(0)
self.root = "http://joyreactor." + match.group(1)
self.root = "http://" + match.group(1)
self.session.headers["Referer"] = self.root

def items(self):
Expand Down Expand Up @@ -112,11 +115,11 @@ def _parse_post(post):


class JoyreactorTagExtractor(JoyreactorExtractor):
"""Extractor for tag searches on joyreactor.com"""
"""Extractor for tag searches on joyreactor.cc"""
subcategory = "tag"
directory_fmt = ["{category}", "{search_tags}"]
archive_fmt = "{search_tags}_{post_id}_{num}"
pattern = [r"(?:https?://)?(?:www\.)?joyreactor\.(com|cc)/tag/([^/?&#]+)"]
pattern = [BASE_PATTERN + r"/tag/([^/?&#]+)"]
test = [
("http://joyreactor.com/tag/Cirno", {
"url": "a81382a3146da50b647c475f87427a6ca1d737df",
Expand All @@ -137,10 +140,10 @@ def metadata(self):


class JoyreactorUserExtractor(JoyreactorExtractor):
"""Extractor for all posts of a user on joyreactor.com"""
"""Extractor for all posts of a user on joyreactor.cc"""
subcategory = "user"
directory_fmt = ["{category}", "user", "{user}"]
pattern = [r"(?:https?://)?(?:www\.)?joyreactor\.(com|cc)/user/([^/?&#]+)"]
pattern = [BASE_PATTERN + r"/user/([^/?&#]+)"]
test = [
("http://joyreactor.com/user/Tacoman123", {
"url": "0444158f17c22f08515ad4e7abf69ad2f3a63b35",
Expand All @@ -161,9 +164,9 @@ def metadata(self):


class JoyreactorPostExtractor(JoyreactorExtractor):
"""Extractor for single posts on joyreactor.com"""
"""Extractor for single posts on joyreactor.cc"""
subcategory = "post"
pattern = [r"(?:https?://)?(?:www\.)?joyreactor\.(com|cc)/post/(\d+)"]
pattern = [BASE_PATTERN + r"/post/(\d+)"]
test = [
("http://joyreactor.com/post/3721876", { # single image
"url": "904779f6571436f3d5adbce30c2c272f6401e14a",
Expand Down
61 changes: 61 additions & 0 deletions gallery_dl/extractor/pornreactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-

# Copyright 2018 Mike Fährmann
#
# 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.

"""Extractors for http://pornreactor.cc/"""

from .joyreactor import (
JoyreactorTagExtractor,
JoyreactorUserExtractor,
JoyreactorPostExtractor,
)


BASE_PATTERN = r"(?:https?://)?(?:www\.)?(pornreactor\.cc|fapreactor.com)"


class PornreactorTagExtractor(JoyreactorTagExtractor):
"""Extractor for tag searches on pornreactor.cc"""
category = "pornreactor"
pattern = [BASE_PATTERN + r"/tag/([^/?&#]+)"]
test = [
("http://pornreactor.cc/tag/RiceGnat", {
"count": ">= 120",
}),
("http://fapreactor.com/tag/RiceGnat", None),
]


class PornreactorUserExtractor(JoyreactorUserExtractor):
"""Extractor for all posts of a user on pornreactor.cc"""
category = "pornreactor"
pattern = [BASE_PATTERN + r"/user/([^/?&#]+)"]
test = [
("http://pornreactor.cc/user/Disillusion", {
"url": "7e06f87f8dcce3fc7851b6d13aa55712ab45fb04",
"keyword": "edfefb54ea4863e3731c508ae6caeb4140be0d31",
}),
("http://fapreactor.com/user/Disillusion", None),
]


class PornreactorPostExtractor(JoyreactorPostExtractor):
"""Extractor for single posts on pornreactor.cc"""
category = "pornreactor"
subcategory = "post"
pattern = [BASE_PATTERN + r"/post/(\d+)"]
test = [
("http://pornreactor.cc/post/863166", {
"url": "9e5f7b374605cbbd413f4f4babb9d1af6f95b843",
"keyword": "6e9e4bd4e2d4f3f2c7936340ec71f8693129f809",
"content": "3e2a09f8b5e5ed7722f51c5f423ff4c9260fb23e",
}),
("http://fapreactor.com/post/863166", {
"url": "83ff7c87741c05bcf1de6825e2b4739afeb87ed5",
"keyword": "cf8159224fde59c1dab86677514b4aedeb533d66",
}),
]

0 comments on commit a0ae156

Please sign in to comment.