From 30d3a5f9b25e8449e89ab2338328baecf787caef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 14 Jul 2017 13:24:09 +0200 Subject: [PATCH] support redirects on 4chan archives --- gallery_dl/extractor/2chan.py | 12 ++++++------ gallery_dl/extractor/chan.py | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gallery_dl/extractor/2chan.py b/gallery_dl/extractor/2chan.py index c1a1be8d..d1158c93 100644 --- a/gallery_dl/extractor/2chan.py +++ b/gallery_dl/extractor/2chan.py @@ -75,12 +75,12 @@ class FutabaThreadExtractor(Extractor): @staticmethod def _extract_post(post): return text.extract_all(post, ( - ("no" , 'name="', '"'), - ("post" , '', ''), - ("name" , '', ' '), - ("now" , ' ', ' '), - (None , '', ''), + ("no" , 'name="', '"'), + ("post", '', ''), + ("name", '', ' '), + ("now" , ' ', ' '), + (None , '', ''), ))[0] @staticmethod diff --git a/gallery_dl/extractor/chan.py b/gallery_dl/extractor/chan.py index f2307404..e58cdc3f 100644 --- a/gallery_dl/extractor/chan.py +++ b/gallery_dl/extractor/chan.py @@ -10,6 +10,7 @@ from .common import Extractor, Message from .. import text +import itertools class ChanThreadExtractor(Extractor): @@ -76,13 +77,22 @@ class FoolfuukaThreadExtractor(Extractor): def items(self): op = True yield Message.Version, 1 + yield Message.Headers, self.session.headers for post in self.posts(): if op: yield Message.Directory, post op = False if not post["media"]: continue - url = post["media"]["media_link"] + + media = post["media"] + url = media["media_link"] + + if not url and "remote_media_link" in media: + needle = '