diff --git a/gallery_dl/extractor/booru.py b/gallery_dl/extractor/booru.py index b5e29873..31173c59 100644 --- a/gallery_dl/extractor/booru.py +++ b/gallery_dl/extractor/booru.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2015 Mike Fährmann +# Copyright 2015-2017 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 @@ -19,7 +19,8 @@ class BooruExtractor(Extractor): """Base class for all booru extractors""" info = {} headers = {} - page = "page" + pagestart = 1 + pagekey = "page" api_url = "" category = "" @@ -40,6 +41,12 @@ class BooruExtractor(Extractor): except KeyError: continue + def skip(self, num): + limit = self.params["limit"] + pages = num // limit + self.pagestart += pages + return pages * limit + def items_impl(self): pass @@ -51,9 +58,9 @@ class BooruExtractor(Extractor): # Override this method in derived classes if necessary. # It is usually enough to just adjust the 'page' attribute if reset is False: - self.params[self.page] += 1 + self.params[self.pagekey] += 1 else: - self.params[self.page] = 1 + self.params[self.pagekey] = self.pagestart def get_job_metadata(self): """Collect metadata for extractor-job""" diff --git a/gallery_dl/extractor/gelbooru.py b/gallery_dl/extractor/gelbooru.py index 4e1b3e8b..b83b2023 100644 --- a/gallery_dl/extractor/gelbooru.py +++ b/gallery_dl/extractor/gelbooru.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014, 2015 Mike Fährmann +# Copyright 2014-2017 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 @@ -16,6 +16,8 @@ class GelbooruExtractor(booru.XMLBooruExtractor): """Base class for gelbooru extractors""" category = "gelbooru" api_url = "http://gelbooru.com/" + pagestart = 0 + pagekey = "pid" def setup(self): self.params.update({"page": "dapi", "s": "post", "q": "index"}) @@ -27,12 +29,6 @@ class GelbooruExtractor(booru.XMLBooruExtractor): except AttributeError: pass - def update_page(self, reset=False): - if not reset: - self.params["pid"] += 1 - else: - self.params["pid"] = 0 - class GelbooruTagExtractor(GelbooruExtractor, booru.BooruTagExtractor): """Extractor for images from gelbooru.com based on search-tags""" diff --git a/gallery_dl/extractor/rule34.py b/gallery_dl/extractor/rule34.py index ec109c28..158bc04b 100644 --- a/gallery_dl/extractor/rule34.py +++ b/gallery_dl/extractor/rule34.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Mike Fährmann +# Copyright 2016-2017 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 @@ -15,16 +15,12 @@ class Rule34Extractor(booru.XMLBooruExtractor): """Base class for rule34 extractors""" category = "rule34" api_url = "https://rule34.xxx/index.php" + pagestart = 0 + pagekey = "pid" def setup(self): self.params.update({"page": "dapi", "s": "post", "q": "index"}) - def update_page(self, reset=False): - if reset is False: - self.params["pid"] += 1 - else: - self.params["pid"] = 0 - class Rule34TagExtractor(Rule34Extractor, booru.BooruTagExtractor): """Extractor for images from rule34.xxx based on search-tags""" diff --git a/gallery_dl/extractor/safebooru.py b/gallery_dl/extractor/safebooru.py index 23a049c1..f8553ccd 100644 --- a/gallery_dl/extractor/safebooru.py +++ b/gallery_dl/extractor/safebooru.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2015 Mike Fährmann +# Copyright 2015-2017 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 @@ -15,16 +15,12 @@ class SafebooruExtractor(booru.XMLBooruExtractor): """Base class for safebooru extractors""" category = "safebooru" api_url = "http://safebooru.org/index.php" + pagestart = 0 + pagekey = "pid" def setup(self): self.params.update({"page": "dapi", "s": "post", "q": "index"}) - def update_page(self, reset=False): - if reset is False: - self.params["pid"] += 1 - else: - self.params["pid"] = 0 - class SafebooruTagExtractor(SafebooruExtractor, booru.BooruTagExtractor): """Extractor for images from safebooru.org based on search-tags"""