1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 03:02:50 +01:00

[booru] simple skip functionality

(#6)
This commit is contained in:
Mike Fährmann 2017-03-04 23:21:55 +01:00
parent 7a9d66fbce
commit ff92674379
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
4 changed files with 20 additions and 25 deletions

View File

@ -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"""

View File

@ -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"""

View File

@ -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"""

View File

@ -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"""