Skip to content

Commit

Permalink
[imagebam] set 'nsfw_inter' cookie (fixes #2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Feb 27, 2022
1 parent d71c173 commit 1c79044
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions gallery_dl/extractor/imagebam.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright 2014-2021 Mike Fährmann
# Copyright 2014-2022 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
Expand All @@ -16,27 +16,16 @@ class ImagebamExtractor(Extractor):
"""Base class for imagebam extractors"""
category = "imagebam"
root = "https://www.imagebam.com"
cookies = None

def __init__(self, match):
Extractor.__init__(self, match)
self.key = match.group(1)
if self.cookies:
self.session.cookies = self.cookies
self.session.cookies.set("nsfw_inter", "1", domain="www.imagebam.com")

def get_image_data(self, data):
page_url = "{}/image/{}".format(self.root, data["image_key"])
page = self.request(page_url).text
image_url, pos = text.extract(page, '<img src="https://images', '"')

if not image_url:
# cache cookies
ImagebamExtractor.cookies = self.session.cookies
# repeat request to get past "Continue to your image" pages
page = self.request(page_url).text
image_url, pos = text.extract(
page, '<img src="https://images', '"')

filename = text.unescape(text.extract(page, 'alt="', '"', pos)[0])
data["url"] = "https://images" + image_url
data["filename"], _, data["extension"] = filename.rpartition(".")
Expand Down

0 comments on commit 1c79044

Please sign in to comment.