2015-06-28 22:53:52 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-10-12 21:56:44 +02:00
|
|
|
|
2023-01-30 20:07:18 +01:00
|
|
|
# Copyright 2015-2023 Mike Fährmann
|
2015-06-28 22:53:52 +02:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2023-01-30 20:07:18 +01:00
|
|
|
import sys
|
2015-06-28 22:53:52 +02:00
|
|
|
import re
|
|
|
|
|
|
|
|
modules = [
|
2023-08-17 23:23:22 +02:00
|
|
|
"2ch",
|
2017-07-14 08:44:31 +02:00
|
|
|
"2chan",
|
2022-10-04 22:18:13 +02:00
|
|
|
"2chen",
|
2019-03-18 01:11:30 +01:00
|
|
|
"35photo",
|
2015-06-28 22:53:52 +02:00
|
|
|
"3dbooru",
|
|
|
|
"4chan",
|
2023-10-24 19:35:28 +02:00
|
|
|
"4archive",
|
2023-05-06 20:41:43 +02:00
|
|
|
"4chanarchives",
|
2019-03-19 23:40:46 +01:00
|
|
|
"500px",
|
2022-10-09 14:58:13 +02:00
|
|
|
"8chan",
|
2019-06-10 22:17:46 +02:00
|
|
|
"8muses",
|
2019-07-21 22:29:57 +02:00
|
|
|
"adultempire",
|
2021-03-16 03:24:29 +01:00
|
|
|
"architizer",
|
2018-03-14 14:03:53 +01:00
|
|
|
"artstation",
|
2020-04-08 21:38:02 +02:00
|
|
|
"aryion",
|
2024-01-06 01:49:34 +01:00
|
|
|
"batoto",
|
2021-07-22 20:37:05 +02:00
|
|
|
"bbc",
|
2018-08-01 21:46:55 +02:00
|
|
|
"behance",
|
2019-10-26 14:13:20 +02:00
|
|
|
"blogger",
|
2022-07-15 12:38:30 +02:00
|
|
|
"bunkr",
|
2022-08-18 11:41:09 +02:00
|
|
|
"catbox",
|
2023-10-15 23:50:36 +02:00
|
|
|
"chevereto",
|
2021-07-23 02:01:51 +02:00
|
|
|
"comicvine",
|
2021-02-21 20:42:45 +01:00
|
|
|
"cyberdrop",
|
2015-06-28 22:53:52 +02:00
|
|
|
"danbooru",
|
2021-09-17 20:09:24 +02:00
|
|
|
"desktopography",
|
2015-10-05 20:29:48 +02:00
|
|
|
"deviantart",
|
2016-09-22 17:20:57 +02:00
|
|
|
"dynastyscans",
|
2023-02-03 19:11:54 +01:00
|
|
|
"e621",
|
2021-02-07 22:58:19 +01:00
|
|
|
"erome",
|
2016-08-04 18:08:48 +02:00
|
|
|
"exhentai",
|
2017-02-06 20:05:58 +01:00
|
|
|
"fallenangels",
|
2021-04-25 19:39:13 +02:00
|
|
|
"fanbox",
|
2022-12-30 14:54:05 +01:00
|
|
|
"fanleaks",
|
2021-04-25 19:39:13 +02:00
|
|
|
"fantia",
|
2022-12-13 17:03:09 +01:00
|
|
|
"fapello",
|
2022-12-02 13:54:29 +01:00
|
|
|
"fapachi",
|
2017-05-30 17:43:02 +02:00
|
|
|
"flickr",
|
2020-02-11 19:51:24 +01:00
|
|
|
"furaffinity",
|
2019-09-02 21:20:02 +02:00
|
|
|
"fuskator",
|
2016-08-04 18:08:48 +02:00
|
|
|
"gelbooru",
|
2021-02-17 00:52:57 +01:00
|
|
|
"gelbooru_v01",
|
2021-02-17 00:12:51 +01:00
|
|
|
"gelbooru_v02",
|
2022-03-29 17:31:57 +02:00
|
|
|
"gofile",
|
2024-01-08 15:29:47 +01:00
|
|
|
"hatenablog",
|
2015-11-15 01:30:26 +01:00
|
|
|
"hbrowse",
|
2016-02-19 15:24:49 +01:00
|
|
|
"hentai2read",
|
2021-04-18 20:28:00 +02:00
|
|
|
"hentaicosplays",
|
2015-11-14 03:19:44 +01:00
|
|
|
"hentaifoundry",
|
2019-01-28 18:00:32 +01:00
|
|
|
"hentaifox",
|
2020-02-18 23:49:59 +01:00
|
|
|
"hentaihand",
|
2016-10-05 09:20:03 +02:00
|
|
|
"hentaihere",
|
2020-02-21 23:40:32 +01:00
|
|
|
"hiperdex",
|
2015-10-28 16:24:35 +01:00
|
|
|
"hitomi",
|
2022-09-18 13:37:16 +02:00
|
|
|
"hotleak",
|
2018-01-09 17:52:12 +01:00
|
|
|
"idolcomplex",
|
2015-06-28 22:53:52 +02:00
|
|
|
"imagebam",
|
2020-05-18 19:02:56 +02:00
|
|
|
"imagechest",
|
2016-08-09 14:05:12 +02:00
|
|
|
"imagefap",
|
2019-07-30 23:02:21 +02:00
|
|
|
"imgbb",
|
2015-06-28 22:53:52 +02:00
|
|
|
"imgbox",
|
2015-10-28 23:26:47 +01:00
|
|
|
"imgth",
|
2015-10-12 22:34:45 +02:00
|
|
|
"imgur",
|
2020-07-22 22:19:53 +02:00
|
|
|
"inkbunny",
|
2018-12-09 12:52:14 +01:00
|
|
|
"instagram",
|
2019-10-30 22:16:10 +01:00
|
|
|
"issuu",
|
2022-06-15 22:51:40 +02:00
|
|
|
"itaku",
|
2023-04-26 18:50:09 +02:00
|
|
|
"itchio",
|
2022-12-22 23:50:56 +01:00
|
|
|
"jschan",
|
2020-03-13 16:45:42 +01:00
|
|
|
"kabeuchi",
|
2019-05-28 21:34:38 +02:00
|
|
|
"keenspot",
|
2021-01-11 22:17:08 +01:00
|
|
|
"kemonoparty",
|
2016-04-20 08:34:44 +02:00
|
|
|
"khinsider",
|
2018-02-04 16:27:44 +01:00
|
|
|
"komikcast",
|
2023-05-26 09:22:23 +02:00
|
|
|
"lensdump",
|
2023-01-28 15:13:35 +01:00
|
|
|
"lexica",
|
2022-02-11 21:30:59 +01:00
|
|
|
"lightroom",
|
2019-04-06 16:10:29 +02:00
|
|
|
"livedoor",
|
2016-08-01 15:36:56 +02:00
|
|
|
"luscious",
|
2022-12-12 13:13:39 +01:00
|
|
|
"lynxchan",
|
2018-03-05 18:37:21 +01:00
|
|
|
"mangadex",
|
2017-01-14 19:39:21 +01:00
|
|
|
"mangafox",
|
2015-11-26 03:06:08 +01:00
|
|
|
"mangahere",
|
2020-07-13 21:20:09 +02:00
|
|
|
"mangakakalot",
|
2021-04-02 21:01:31 +02:00
|
|
|
"manganelo",
|
2015-12-08 22:29:34 +01:00
|
|
|
"mangapark",
|
2022-11-13 11:30:29 +01:00
|
|
|
"mangaread",
|
2021-06-26 23:38:58 +02:00
|
|
|
"mangasee",
|
2019-04-03 07:53:26 +02:00
|
|
|
"mangoxo",
|
2023-03-01 12:30:56 +01:00
|
|
|
"misskey",
|
2020-09-17 17:32:54 +02:00
|
|
|
"myhentaigallery",
|
2018-07-19 18:56:45 +02:00
|
|
|
"myportfolio",
|
2019-10-20 22:50:29 +02:00
|
|
|
"naver",
|
2021-03-03 15:21:13 +01:00
|
|
|
"naverwebtoon",
|
2018-11-27 15:44:53 +01:00
|
|
|
"newgrounds",
|
2015-10-28 12:08:27 +01:00
|
|
|
"nhentai",
|
2015-06-28 22:53:52 +02:00
|
|
|
"nijie",
|
2022-11-15 11:44:16 +01:00
|
|
|
"nitter",
|
2019-10-13 22:10:32 +02:00
|
|
|
"nozomi",
|
2019-06-22 22:43:09 +02:00
|
|
|
"nsfwalbum",
|
2018-01-15 16:39:05 +01:00
|
|
|
"paheal",
|
2019-05-16 23:56:48 +02:00
|
|
|
"patreon",
|
2021-03-14 16:31:33 +01:00
|
|
|
"philomena",
|
2019-01-20 16:19:13 +01:00
|
|
|
"photobucket",
|
2021-01-22 19:36:13 +01:00
|
|
|
"photovogue",
|
2021-10-13 01:22:10 +02:00
|
|
|
"picarto",
|
2018-08-08 10:53:01 +02:00
|
|
|
"piczel",
|
2021-01-24 23:44:03 +01:00
|
|
|
"pillowfort",
|
2016-09-02 19:11:16 +02:00
|
|
|
"pinterest",
|
2023-11-22 19:01:19 +01:00
|
|
|
"pixeldrain",
|
2017-10-17 16:49:42 +02:00
|
|
|
"pixiv",
|
2019-04-11 19:27:02 +02:00
|
|
|
"pixnet",
|
2019-04-14 18:03:34 +02:00
|
|
|
"plurk",
|
2022-06-20 11:25:42 +02:00
|
|
|
"poipiku",
|
2023-12-21 19:50:54 +01:00
|
|
|
"poringa",
|
2019-06-07 16:31:20 +02:00
|
|
|
"pornhub",
|
2023-02-17 14:53:12 +01:00
|
|
|
"pornpics",
|
2023-12-12 10:54:34 +01:00
|
|
|
"postmill",
|
2019-02-25 12:37:20 +01:00
|
|
|
"pururin",
|
2019-01-07 16:59:26 +01:00
|
|
|
"reactor",
|
2016-11-14 18:29:45 +01:00
|
|
|
"readcomiconline",
|
2017-05-23 09:38:50 +02:00
|
|
|
"reddit",
|
2020-05-10 00:31:42 +02:00
|
|
|
"redgifs",
|
2021-12-12 23:36:16 +01:00
|
|
|
"rule34us",
|
2015-11-09 02:29:33 +01:00
|
|
|
"sankaku",
|
2019-05-27 23:49:23 +02:00
|
|
|
"sankakucomplex",
|
2016-08-09 16:36:30 +02:00
|
|
|
"seiga",
|
2016-08-02 17:42:22 +02:00
|
|
|
"senmanga",
|
2019-04-23 22:10:39 +02:00
|
|
|
"sexcom",
|
2023-04-26 18:01:07 +02:00
|
|
|
"shimmie2",
|
2018-05-27 15:25:04 +02:00
|
|
|
"simplyhentai",
|
2021-10-26 20:00:41 +02:00
|
|
|
"skeb",
|
2019-06-09 21:59:22 +02:00
|
|
|
"slickpic",
|
2017-12-13 17:38:29 +01:00
|
|
|
"slideshare",
|
2018-04-29 21:27:25 +02:00
|
|
|
"smugmug",
|
2022-12-09 23:19:07 +01:00
|
|
|
"soundgasm",
|
2020-05-01 22:32:22 +02:00
|
|
|
"speakerdeck",
|
2024-01-09 07:12:56 +01:00
|
|
|
"steamgriddb",
|
2020-07-03 21:08:47 +02:00
|
|
|
"subscribestar",
|
2023-03-01 18:20:37 +01:00
|
|
|
"szurubooru",
|
2021-03-27 18:28:16 +01:00
|
|
|
"tapas",
|
2023-01-06 11:33:41 +01:00
|
|
|
"tcbscans",
|
2022-03-28 19:18:13 +02:00
|
|
|
"telegraph",
|
2023-11-18 01:34:34 +01:00
|
|
|
"tmohentai",
|
2022-02-27 16:22:50 +01:00
|
|
|
"toyhouse",
|
2019-01-29 17:23:01 +01:00
|
|
|
"tsumino",
|
2016-02-20 11:29:10 +01:00
|
|
|
"tumblr",
|
2021-03-03 15:20:47 +01:00
|
|
|
"tumblrgallery",
|
2022-02-18 00:40:22 +01:00
|
|
|
"twibooru",
|
2016-10-06 19:12:07 +02:00
|
|
|
"twitter",
|
2023-12-05 13:07:06 +01:00
|
|
|
"urlgalleries",
|
2021-01-19 02:23:39 +01:00
|
|
|
"unsplash",
|
2022-11-05 14:25:09 +01:00
|
|
|
"uploadir",
|
2023-03-28 18:06:41 +02:00
|
|
|
"urlshortener",
|
2019-06-23 22:02:54 +02:00
|
|
|
"vanillarock",
|
2022-10-21 14:40:45 +02:00
|
|
|
"vichan",
|
2023-04-19 15:28:26 +02:00
|
|
|
"vipergirls",
|
2021-03-23 18:48:01 +01:00
|
|
|
"vk",
|
2019-07-22 22:15:36 +02:00
|
|
|
"vsco",
|
2018-09-17 21:19:25 +02:00
|
|
|
"wallhaven",
|
2022-02-11 23:44:51 +01:00
|
|
|
"wallpapercave",
|
2017-08-18 19:52:58 +02:00
|
|
|
"warosu",
|
2020-09-25 15:18:21 +02:00
|
|
|
"weasyl",
|
2022-12-14 19:59:07 +01:00
|
|
|
"webmshare",
|
2020-05-18 19:04:20 +02:00
|
|
|
"webtoons",
|
2019-02-16 22:56:04 +01:00
|
|
|
"weibo",
|
2019-04-02 17:34:57 +02:00
|
|
|
"wikiart",
|
2023-01-16 16:38:45 +01:00
|
|
|
"wikifeet",
|
2019-06-04 22:23:32 +02:00
|
|
|
"xhamster",
|
2017-11-02 15:36:53 +01:00
|
|
|
"xvideos",
|
2022-07-27 22:58:23 +02:00
|
|
|
"zerochan",
|
2024-01-04 17:08:59 +01:00
|
|
|
"zzup",
|
2020-12-08 18:31:59 +01:00
|
|
|
"booru",
|
2020-12-01 15:31:28 +01:00
|
|
|
"moebooru",
|
2019-02-03 00:40:12 +01:00
|
|
|
"foolfuuka",
|
2019-02-03 23:54:17 +01:00
|
|
|
"foolslide",
|
2019-01-19 14:28:59 +01:00
|
|
|
"mastodon",
|
2019-03-05 22:33:37 +01:00
|
|
|
"shopify",
|
2021-12-21 19:24:17 +01:00
|
|
|
"lolisafe",
|
2016-11-03 15:46:04 +01:00
|
|
|
"imagehosts",
|
2017-05-24 12:51:18 +02:00
|
|
|
"directlink",
|
2016-10-01 15:54:27 +02:00
|
|
|
"recursive",
|
2017-06-20 16:06:14 +02:00
|
|
|
"oauth",
|
2016-12-10 00:01:00 +01:00
|
|
|
"test",
|
2021-07-10 20:47:33 +02:00
|
|
|
"ytdl",
|
2021-12-29 22:39:29 +01:00
|
|
|
"generic",
|
2015-06-28 22:53:52 +02:00
|
|
|
]
|
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2015-10-05 17:52:50 +02:00
|
|
|
def find(url):
|
2019-02-08 20:08:16 +01:00
|
|
|
"""Find a suitable extractor for the given URL"""
|
|
|
|
for cls in _list_classes():
|
|
|
|
match = cls.pattern.match(url)
|
2020-09-11 13:11:46 +02:00
|
|
|
if match:
|
2019-02-08 20:08:16 +01:00
|
|
|
return cls(match)
|
2015-11-21 00:30:31 +01:00
|
|
|
return None
|
2015-06-28 22:53:52 +02:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2019-02-08 20:08:16 +01:00
|
|
|
def add(cls):
|
|
|
|
"""Add 'cls' to the list of available extractors"""
|
|
|
|
cls.pattern = re.compile(cls.pattern)
|
|
|
|
_cache.append(cls)
|
|
|
|
return cls
|
2018-02-02 00:01:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
def add_module(module):
|
|
|
|
"""Add all extractors in 'module' to the list of available extractors"""
|
2019-02-08 20:08:16 +01:00
|
|
|
classes = _get_classes(module)
|
|
|
|
for cls in classes:
|
|
|
|
cls.pattern = re.compile(cls.pattern)
|
|
|
|
_cache.extend(classes)
|
|
|
|
return classes
|
2018-02-02 00:01:41 +01:00
|
|
|
|
|
|
|
|
2015-12-12 15:58:07 +01:00
|
|
|
def extractors():
|
|
|
|
"""Yield all available extractor classes"""
|
2015-12-13 04:34:15 +01:00
|
|
|
return sorted(
|
2019-02-08 20:08:16 +01:00
|
|
|
_list_classes(),
|
2015-12-13 04:34:15 +01:00
|
|
|
key=lambda x: x.__name__
|
|
|
|
)
|
2015-12-12 15:58:07 +01:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2015-06-28 22:53:52 +02:00
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# internals
|
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2019-02-08 20:08:16 +01:00
|
|
|
def _list_classes():
|
2023-01-30 20:07:18 +01:00
|
|
|
"""Yield available extractor classes"""
|
2016-08-23 16:36:39 +02:00
|
|
|
yield from _cache
|
2015-10-05 18:10:18 +02:00
|
|
|
|
2023-01-30 20:07:18 +01:00
|
|
|
for module in _module_iter:
|
2019-02-08 20:08:16 +01:00
|
|
|
yield from add_module(module)
|
2015-11-20 19:54:07 +01:00
|
|
|
|
2023-01-30 20:07:18 +01:00
|
|
|
globals()["_list_classes"] = lambda : _cache
|
|
|
|
|
|
|
|
|
|
|
|
def _modules_internal():
|
|
|
|
globals_ = globals()
|
|
|
|
for module_name in modules:
|
|
|
|
yield __import__(module_name, globals_, None, (), 1)
|
|
|
|
|
|
|
|
|
|
|
|
def _modules_path(path, files):
|
|
|
|
sys.path.insert(0, path)
|
|
|
|
try:
|
|
|
|
return [
|
|
|
|
__import__(name[:-3])
|
|
|
|
for name in files
|
|
|
|
if name.endswith(".py")
|
|
|
|
]
|
|
|
|
finally:
|
|
|
|
del sys.path[0]
|
2020-10-25 15:39:52 +01:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2015-11-20 19:54:07 +01:00
|
|
|
def _get_classes(module):
|
|
|
|
"""Return a list of all extractor classes in a module"""
|
|
|
|
return [
|
2019-02-08 20:08:16 +01:00
|
|
|
cls for cls in module.__dict__.values() if (
|
|
|
|
hasattr(cls, "pattern") and cls.__module__ == module.__name__
|
2015-11-20 19:54:07 +01:00
|
|
|
)
|
|
|
|
]
|
2023-01-30 20:07:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
_cache = []
|
|
|
|
_module_iter = _modules_internal()
|