From 64ad8e7bd15df71ab1116eede414558631bcad32 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sun, 4 Aug 2019 17:52:59 -0400 Subject: New upstream version 1.10.1 --- gallery_dl/cache.py | 19 +++- gallery_dl/downloader/ytdl.py | 7 +- gallery_dl/extractor/__init__.py | 3 + gallery_dl/extractor/adultempire.py | 58 +++++++++++ gallery_dl/extractor/behance.py | 22 ++-- gallery_dl/extractor/dynastyscans.py | 2 +- gallery_dl/extractor/exhentai.py | 102 +++++++++++++------ gallery_dl/extractor/gelbooru.py | 1 + gallery_dl/extractor/imgbb.py | 179 +++++++++++++++++++++++++++++++++ gallery_dl/extractor/luscious.py | 2 +- gallery_dl/extractor/ngomik.py | 2 +- gallery_dl/extractor/sankaku.py | 4 +- gallery_dl/extractor/sankakucomplex.py | 4 +- gallery_dl/extractor/tsumino.py | 2 +- gallery_dl/extractor/vsco.py | 176 ++++++++++++++++++++++++++++++++ gallery_dl/job.py | 3 +- gallery_dl/postprocessor/zip.py | 38 +++++-- gallery_dl/text.py | 22 ---- gallery_dl/util.py | 25 ++++- gallery_dl/version.py | 2 +- 20 files changed, 581 insertions(+), 92 deletions(-) create mode 100644 gallery_dl/extractor/adultempire.py create mode 100644 gallery_dl/extractor/imgbb.py create mode 100644 gallery_dl/extractor/vsco.py (limited to 'gallery_dl') diff --git a/gallery_dl/cache.py b/gallery_dl/cache.py index e6ba61a..3ceef75 100644 --- a/gallery_dl/cache.py +++ b/gallery_dl/cache.py @@ -11,6 +11,7 @@ import sqlite3 import pickle import time +import os import functools from . import config, util @@ -188,17 +189,25 @@ def clear(): def _path(): path = config.get(("cache", "file"), -1) + if path != -1: + return util.expand_path(path) - if path == -1: + if os.name == "nt": import tempfile - import os.path return os.path.join(tempfile.gettempdir(), ".gallery-dl.cache") - return util.expand_path(path) + cachedir = util.expand_path(os.path.join( + os.environ.get("XDG_CACHE_HOME", "~/.cache"), "gallery-dl")) + os.makedirs(cachedir, exist_ok=True) + return os.path.join(cachedir, "cache.sqlite3") try: + dbfile = _path() + if os.name != "nt": + # restrict access permissions for new db files + os.close(os.open(dbfile, os.O_CREAT | os.O_RDONLY, 0o600)) DatabaseCacheDecorator.db = sqlite3.connect( - _path(), timeout=30, check_same_thread=False) -except (TypeError, sqlite3.OperationalError): + dbfile, timeout=30, check_same_thread=False) +except (OSError, TypeError, sqlite3.OperationalError): cache = memcache # noqa: F811 diff --git a/gallery_dl/downloader/ytdl.py b/gallery_dl/downloader/ytdl.py index da57935..a233487 100644 --- a/gallery_dl/downloader/ytdl.py +++ b/gallery_dl/downloader/ytdl.py @@ -34,12 +34,15 @@ class YoutubeDLDownloader(DownloaderBase): if self.config("logging", True): options["logger"] = self.log + self.forward_cookies = self.config("forward-cookies", True) self.ytdl = YoutubeDL(options) def download(self, url, pathfmt): - for cookie in self.session.cookies: - self.ytdl.cookiejar.set_cookie(cookie) + if self.forward_cookies: + set_cookie = self.ytdl.cookiejar.set_cookie + for cookie in self.session.cookies: + set_cookie(cookie) try: info_dict = self.ytdl.extract_info(url[5:], download=False) diff --git a/gallery_dl/extractor/__init__.py b/gallery_dl/extractor/__init__.py index 189c163..0b24111 100644 --- a/gallery_dl/extractor/__init__.py +++ b/gallery_dl/extractor/__init__.py @@ -17,6 +17,7 @@ modules = [ "500px", "8chan", "8muses", + "adultempire", "artstation", "behance", "bobx", @@ -42,6 +43,7 @@ modules = [ "idolcomplex", "imagebam", "imagefap", + "imgbb", "imgbox", "imgth", "imgur", @@ -95,6 +97,7 @@ modules = [ "tumblr", "twitter", "vanillarock", + "vsco", "wallhaven", "warosu", "weibo", diff --git a/gallery_dl/extractor/adultempire.py b/gallery_dl/extractor/adultempire.py new file mode 100644 index 0000000..5ea835f --- /dev/null +++ b/gallery_dl/extractor/adultempire.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +# Copyright 2019 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 +# published by the Free Software Foundation. + +"""Extractors for https://www.adultempire.com/""" + +from .common import GalleryExtractor +from .. import text + + +class AdultempireGalleryExtractor(GalleryExtractor): + """Extractor for image galleries from www.adultempire.com""" + category = "adultempire" + root = "https://www.adultempire.com" + pattern = (r"(?:https?://)?(?:www\.)?adult(?:dvd)?empire\.com" + r"(/(\d+)/gallery\.html)") + test = ( + ("https://www.adultempire.com/5998/gallery.html", { + "range": "1", + "keyword": "0533ef1184892be8ac02b17286797c95f389ba63", + "content": "5c6beb31e5e3cdc90ee5910d5c30f9aaec977b9e", + }), + ("https://www.adultdvdempire.com/5683/gallery.html", { + "url": "b12cd1a65cae8019d837505adb4d6a2c1ed4d70d", + "keyword": "59fe5d95929efc5040a819a5f77aba7a022bb85a", + }), + ) + + def __init__(self, match): + GalleryExtractor.__init__(self, match) + self.gallery_id = match.group(2) + + def metadata(self, page): + extr = text.extract_from(page, page.index('
')) + return { + "gallery_id": text.parse_int(self.gallery_id), + "title" : text.unescape(extr('title="', '"')), + "studio" : extr(">studio", "<").strip(), + "date" : text.parse_datetime(extr( + ">released", "<").strip(), "%m/%d/%Y"), + "actors" : text.split_html(extr( + '