diff options
Diffstat (limited to 'gallery_dl/extractor/bobx.py')
| -rw-r--r-- | gallery_dl/extractor/bobx.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gallery_dl/extractor/bobx.py b/gallery_dl/extractor/bobx.py index dba5fe7..94a2840 100644 --- a/gallery_dl/extractor/bobx.py +++ b/gallery_dl/extractor/bobx.py @@ -10,18 +10,38 @@ from .common import Extractor, Message from .. import text +from ..cache import memcache +import random +import time class BobxExtractor(Extractor): """Base class for bobx extractors""" category = "bobx" root = "http://www.bobx.com" + cookiedomain = ".bobx.com" per_page = 80 def __init__(self, match): Extractor.__init__(self, match) self.path = match.group(1) + def login(self): + if not self._check_cookies(("BobXUser",)): + self._update_cookies(self._login_impl()) + + @memcache() + def _login_impl(self): + """Generate a randomized 'BobXUser' cookie""" + rand = random.randrange + tnow = time.time() - rand(60, 3600) + + return {"BobXUser": "{}.{}.{}.{}.{}.{}".format( + int(tnow), + rand(128, 192), rand(0, 256), rand(0, 256), rand(0, 256), + tnow + 622080000, # timestamp in 7200 days + )} + class BobxGalleryExtractor(BobxExtractor): """Extractor for individual image galleries on bobx.com""" @@ -46,6 +66,8 @@ class BobxGalleryExtractor(BobxExtractor): ) def items(self): + self.login() + num = 0 while True: url = "{}/{}-{}-10-8.html".format(self.root, self.path, num) @@ -99,6 +121,7 @@ class BobxIdolExtractor(BobxExtractor): }) def items(self): + self.login() url = "{}/{}/".format(self.root, self.path) data = {"_extractor": BobxGalleryExtractor} page = self.request(url).text |
