2019-04-16 18:16:48 +02:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
"""Generate a reStructuredText document with all supported sites"""
|
2017-01-15 21:31:21 +01:00
|
|
|
|
|
2021-01-22 21:02:12 +01:00
|
|
|
|
import os
|
2017-01-15 21:31:21 +01:00
|
|
|
|
import sys
|
2019-02-20 19:25:41 +01:00
|
|
|
|
import collections
|
2017-01-15 21:31:21 +01:00
|
|
|
|
|
2019-04-16 18:16:48 +02:00
|
|
|
|
import util
|
|
|
|
|
from gallery_dl import extractor
|
2017-01-15 21:31:21 +01:00
|
|
|
|
|
|
|
|
|
|
2017-04-20 16:56:50 +02:00
|
|
|
|
CATEGORY_MAP = {
|
2017-07-15 15:01:30 +02:00
|
|
|
|
"2chan" : "Futaba Channel",
|
2019-03-18 01:11:30 +01:00
|
|
|
|
"35photo" : "35PHOTO",
|
2019-07-21 22:29:57 +02:00
|
|
|
|
"adultempire" : "Adult Empire",
|
2017-07-15 15:01:30 +02:00
|
|
|
|
"archivedmoe" : "Archived.Moe",
|
|
|
|
|
"archiveofsins" : "Archive of Sins",
|
2018-03-17 15:35:38 +01:00
|
|
|
|
"artstation" : "ArtStation",
|
2020-04-08 21:38:02 +02:00
|
|
|
|
"aryion" : "Eka's Portal",
|
2017-09-16 21:11:44 +02:00
|
|
|
|
"b4k" : "arch.b4k.co",
|
2020-04-02 22:34:32 +02:00
|
|
|
|
"baraag" : "baraag",
|
2020-02-08 23:25:53 +01:00
|
|
|
|
"bcy" : "半次元",
|
2018-09-13 20:13:12 +02:00
|
|
|
|
"bobx" : "BobX",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"deviantart" : "DeviantArt",
|
|
|
|
|
"dokireader" : "Doki Reader",
|
|
|
|
|
"dynastyscans" : "Dynasty Reader",
|
|
|
|
|
"e621" : "e621",
|
2021-02-07 22:58:19 +01:00
|
|
|
|
"erome" : "EroMe",
|
2019-08-03 11:42:28 +02:00
|
|
|
|
"e-hentai" : "E-Hentai",
|
|
|
|
|
"exhentai" : "ExHentai",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"fallenangels" : "Fallen Angels Scans",
|
2019-03-05 22:33:37 +01:00
|
|
|
|
"fashionnova" : "Fashion Nova",
|
2020-02-11 19:51:24 +01:00
|
|
|
|
"furaffinity" : "Fur Affinity",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"hbrowse" : "HBrowse",
|
|
|
|
|
"hentai2read" : "Hentai2Read",
|
2018-09-05 21:08:40 +02:00
|
|
|
|
"hentaicafe" : "Hentai Cafe",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"hentaifoundry" : "Hentai Foundry",
|
2019-01-28 18:00:32 +01:00
|
|
|
|
"hentaifox" : "HentaiFox",
|
2020-02-18 23:49:59 +01:00
|
|
|
|
"hentaihand" : "HentaiHand",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"hentaihere" : "HentaiHere",
|
|
|
|
|
"hitomi" : "Hitomi.la",
|
2018-01-09 17:52:12 +01:00
|
|
|
|
"idolcomplex" : "Idol Complex",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"imagebam" : "ImageBam",
|
|
|
|
|
"imagefap" : "ImageFap",
|
2019-07-30 23:02:21 +02:00
|
|
|
|
"imgbb" : "ImgBB",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"imgbox" : "imgbox",
|
2020-05-18 19:02:56 +02:00
|
|
|
|
"imagechest" : "ImageChest",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"imgth" : "imgth",
|
|
|
|
|
"imgur" : "imgur",
|
|
|
|
|
"jaiminisbox" : "Jaimini's Box",
|
2020-03-13 16:45:42 +01:00
|
|
|
|
"kabeuchi" : "かべうち",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"kireicake" : "Kirei Cake",
|
|
|
|
|
"kissmanga" : "KissManga",
|
2019-09-06 21:58:13 +02:00
|
|
|
|
"lineblog" : "LINE BLOG",
|
2019-04-06 16:10:29 +02:00
|
|
|
|
"livedoor" : "livedoor Blog",
|
2018-03-06 14:15:15 +01:00
|
|
|
|
"mangadex" : "MangaDex",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"mangafox" : "Manga Fox",
|
|
|
|
|
"mangahere" : "Manga Here",
|
2020-07-13 21:20:09 +02:00
|
|
|
|
"mangakakalot" : "MangaKakalot",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"mangapark" : "MangaPark",
|
|
|
|
|
"mangastream" : "Manga Stream",
|
2020-04-02 22:34:32 +02:00
|
|
|
|
"mastodon.social": "mastodon.social",
|
2020-09-17 18:06:12 +02:00
|
|
|
|
"myhentaigallery": "My Hentai Gallery",
|
2018-07-19 18:56:45 +02:00
|
|
|
|
"myportfolio" : "Adobe Portfolio",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"nhentai" : "nhentai",
|
|
|
|
|
"nijie" : "nijie",
|
2019-10-13 22:10:32 +02:00
|
|
|
|
"nozomi" : "Nozomi.la",
|
2019-06-22 22:43:09 +02:00
|
|
|
|
"nsfwalbum" : "NSFWalbum.com",
|
2017-07-15 15:01:30 +02:00
|
|
|
|
"nyafuu" : "Nyafuu Archive",
|
2018-01-15 16:39:05 +01:00
|
|
|
|
"paheal" : "rule #34",
|
2021-01-22 19:41:50 +01:00
|
|
|
|
"photovogue" : "PhotoVogue",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"powermanga" : "PowerManga",
|
|
|
|
|
"readcomiconline": "Read Comic Online",
|
2017-07-24 10:50:40 +02:00
|
|
|
|
"rbt" : "RebeccaBlackTech",
|
2020-05-10 00:31:42 +02:00
|
|
|
|
"redgifs" : "RedGIFs",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"rule34" : "Rule 34",
|
|
|
|
|
"sankaku" : "Sankaku Channel",
|
2019-05-27 23:49:23 +02:00
|
|
|
|
"sankakucomplex" : "Sankaku Complex",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"seaotterscans" : "Sea Otter Scans",
|
|
|
|
|
"seiga" : "Niconico Seiga",
|
|
|
|
|
"senmanga" : "Sen Manga",
|
|
|
|
|
"sensescans" : "Sense-Scans",
|
2019-04-23 22:10:39 +02:00
|
|
|
|
"sexcom" : "Sex.com",
|
2018-05-27 15:25:04 +02:00
|
|
|
|
"simplyhentai" : "Simply Hentai",
|
2019-06-09 21:59:22 +02:00
|
|
|
|
"slickpic" : "SlickPic",
|
2017-12-13 21:15:05 +01:00
|
|
|
|
"slideshare" : "SlideShare",
|
2018-04-29 21:27:25 +02:00
|
|
|
|
"smugmug" : "SmugMug",
|
2020-05-01 22:32:22 +02:00
|
|
|
|
"speakerdeck" : "Speaker Deck",
|
2020-07-14 16:18:21 +02:00
|
|
|
|
"subscribestar" : "SubscribeStar",
|
2017-07-24 10:50:40 +02:00
|
|
|
|
"thebarchive" : "The /b/ Archive",
|
2019-06-23 22:02:54 +02:00
|
|
|
|
"vanillarock" : "もえぴりあ",
|
2019-07-22 22:15:36 +02:00
|
|
|
|
"vsco" : "VSCO",
|
2020-05-18 19:04:20 +02:00
|
|
|
|
"webtoons" : "Webtoon",
|
2019-04-02 17:34:57 +02:00
|
|
|
|
"wikiart" : "WikiArt.org",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"worldthree" : "World Three",
|
2019-06-04 22:23:32 +02:00
|
|
|
|
"xhamster" : "xHamster",
|
2017-11-02 17:28:35 +01:00
|
|
|
|
"xvideos" : "XVideos",
|
2018-09-28 12:46:39 +02:00
|
|
|
|
"yuki" : "yuki.la 4chan archive",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SUBCATEGORY_MAP = {
|
2018-03-31 18:54:25 +02:00
|
|
|
|
"doujin" : "Doujin",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"gallery": "Galleries",
|
|
|
|
|
"image" : "individual Images",
|
2020-03-24 02:00:50 +01:00
|
|
|
|
"issue" : "Comic Issues",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"manga" : "Manga",
|
2017-08-24 21:24:51 +02:00
|
|
|
|
"popular": "Popular Images",
|
2018-09-22 21:28:16 +02:00
|
|
|
|
"recent" : "Recent Images",
|
2017-06-15 21:06:20 +02:00
|
|
|
|
"search" : "Search Results",
|
2017-04-20 16:56:50 +02:00
|
|
|
|
"status" : "Images from Statuses",
|
2020-03-24 02:00:50 +01:00
|
|
|
|
"tag" : "Tag Searches",
|
2019-09-22 22:21:48 +02:00
|
|
|
|
"user" : "User Profiles",
|
2020-01-13 22:29:42 +01:00
|
|
|
|
"following" : "",
|
2018-08-15 21:28:27 +02:00
|
|
|
|
"related-pin" : "related Pins",
|
|
|
|
|
"related-board": "",
|
2020-01-13 22:29:42 +01:00
|
|
|
|
|
|
|
|
|
"artstation": {
|
|
|
|
|
"artwork": "Artwork Listings",
|
|
|
|
|
},
|
|
|
|
|
"deviantart": {
|
|
|
|
|
"stash": "Sta.sh",
|
|
|
|
|
},
|
2020-09-27 02:22:23 +02:00
|
|
|
|
"hentaifoundry": {
|
|
|
|
|
"story": "",
|
|
|
|
|
},
|
2020-03-16 22:57:30 +01:00
|
|
|
|
"instagram": {
|
2020-12-20 23:20:32 +01:00
|
|
|
|
"posts": "",
|
2020-03-16 22:57:30 +01:00
|
|
|
|
"saved": "Saved Posts",
|
|
|
|
|
},
|
2020-01-13 22:29:42 +01:00
|
|
|
|
"newgrounds": {
|
|
|
|
|
"art" : "Art",
|
|
|
|
|
"audio": "Audio",
|
|
|
|
|
"media": "Media Files",
|
|
|
|
|
},
|
|
|
|
|
"pinterest": {
|
2020-12-29 16:57:03 +01:00
|
|
|
|
"board": "",
|
2020-01-13 22:29:42 +01:00
|
|
|
|
"pinit": "pin.it Links",
|
|
|
|
|
},
|
|
|
|
|
"pixiv": {
|
|
|
|
|
"me" : "pixiv.me Links",
|
|
|
|
|
"work": "individual Images",
|
|
|
|
|
},
|
2020-12-29 17:36:37 +01:00
|
|
|
|
"sankaku": {
|
|
|
|
|
"books": "Book Searches",
|
|
|
|
|
},
|
2020-01-13 22:29:42 +01:00
|
|
|
|
"smugmug": {
|
|
|
|
|
"path": "Images from Users and Folders",
|
|
|
|
|
},
|
|
|
|
|
"twitter": {
|
|
|
|
|
"media": "Media Timelines",
|
2020-11-13 06:47:45 +01:00
|
|
|
|
"list-members": "List Members",
|
2020-01-13 22:29:42 +01:00
|
|
|
|
},
|
|
|
|
|
"wikiart": {
|
|
|
|
|
"artists": "Artist Listings",
|
|
|
|
|
},
|
2020-09-25 23:43:11 +02:00
|
|
|
|
"weasyl": {
|
|
|
|
|
"journals" : "",
|
|
|
|
|
"submissions": "",
|
|
|
|
|
},
|
2017-04-20 16:56:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-18 22:18:27 +02:00
|
|
|
|
_OAUTH = "`OAuth <https://github.com/mikf/gallery-dl#oauth>`__"
|
|
|
|
|
_COOKIES = "`Cookies <https://github.com/mikf/gallery-dl#cookies>`__"
|
2021-01-07 18:05:32 +01:00
|
|
|
|
_APIKEY_DB = "`API Key <configuration.rst#extractorderpibooruapi-key>`__"
|
2020-10-18 22:18:27 +02:00
|
|
|
|
_APIKEY_WH = "`API Key <configuration.rst#extractorwallhavenapi-key>`__"
|
|
|
|
|
_APIKEY_WY = "`API Key <configuration.rst#extractorweasylapi-key>`__"
|
2020-07-14 16:18:21 +02:00
|
|
|
|
|
2017-06-15 21:06:20 +02:00
|
|
|
|
AUTH_MAP = {
|
2020-10-18 22:18:27 +02:00
|
|
|
|
"aryion" : "Supported",
|
|
|
|
|
"baraag" : _OAUTH,
|
|
|
|
|
"danbooru" : "Supported",
|
2021-01-07 18:05:32 +01:00
|
|
|
|
"derpibooru" : _APIKEY_DB,
|
2020-10-18 22:18:27 +02:00
|
|
|
|
"deviantart" : _OAUTH,
|
|
|
|
|
"e621" : "Supported",
|
|
|
|
|
"e-hentai" : "Supported",
|
|
|
|
|
"exhentai" : "Supported",
|
|
|
|
|
"flickr" : _OAUTH,
|
|
|
|
|
"furaffinity" : _COOKIES,
|
|
|
|
|
"idolcomplex" : "Supported",
|
|
|
|
|
"imgbb" : "Supported",
|
|
|
|
|
"inkbunny" : "Supported",
|
|
|
|
|
"instagram" : "Supported",
|
|
|
|
|
"mangoxo" : "Supported",
|
|
|
|
|
"mastodon.social": _OAUTH,
|
|
|
|
|
"newgrounds" : "Supported",
|
2020-07-14 16:18:21 +02:00
|
|
|
|
"nijie" : "Required",
|
2020-10-18 22:18:27 +02:00
|
|
|
|
"patreon" : _COOKIES,
|
|
|
|
|
"pawoo" : _OAUTH,
|
|
|
|
|
"pinterest" : "Supported",
|
2021-02-12 18:03:06 +01:00
|
|
|
|
"pixiv" : _OAUTH,
|
2020-10-18 22:18:27 +02:00
|
|
|
|
"reddit" : _OAUTH,
|
2020-12-17 16:12:59 +01:00
|
|
|
|
"sankaku" : "Supported",
|
2020-07-14 16:18:21 +02:00
|
|
|
|
"seiga" : "Required",
|
2020-10-18 22:18:27 +02:00
|
|
|
|
"smugmug" : _OAUTH,
|
|
|
|
|
"subscribestar" : "Supported",
|
|
|
|
|
"tsumino" : "Supported",
|
|
|
|
|
"tumblr" : _OAUTH,
|
|
|
|
|
"twitter" : "Supported",
|
|
|
|
|
"wallhaven" : _APIKEY_WH,
|
|
|
|
|
"weasyl" : _APIKEY_WY,
|
2017-06-15 21:06:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IGNORE_LIST = (
|
2019-02-20 19:25:41 +01:00
|
|
|
|
"directlink",
|
2017-06-15 21:06:20 +02:00
|
|
|
|
"oauth",
|
2019-02-20 19:25:41 +01:00
|
|
|
|
"recursive",
|
|
|
|
|
"test",
|
2017-06-15 21:06:20 +02:00
|
|
|
|
)
|
|
|
|
|
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
def domain(cls):
|
|
|
|
|
"""Return the web-domain related to an extractor class"""
|
2021-02-21 22:57:37 +01:00
|
|
|
|
try:
|
|
|
|
|
url = sys.modules[cls.__module__].__doc__.split()[-1]
|
|
|
|
|
if url.startswith("http"):
|
|
|
|
|
return url
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
if hasattr(cls, "root") and cls.root:
|
|
|
|
|
return cls.root + "/"
|
2018-09-28 12:39:05 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
if hasattr(cls, "https"):
|
|
|
|
|
scheme = "https" if cls.https else "http"
|
|
|
|
|
netloc = cls.__doc__.split()[-1]
|
|
|
|
|
return "{}://{}/".format(scheme, netloc)
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
test = next(cls._get_tests(), None)
|
|
|
|
|
if test:
|
|
|
|
|
url = test[0]
|
|
|
|
|
return url[:url.find("/", 8)+1]
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
return ""
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
def category_text(c):
|
2019-02-20 19:25:41 +01:00
|
|
|
|
"""Return a human-readable representation of a category"""
|
|
|
|
|
return CATEGORY_MAP.get(c) or c.capitalize()
|
2018-09-28 12:39:05 +02:00
|
|
|
|
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
def subcategory_text(c, sc):
|
2019-02-20 19:25:41 +01:00
|
|
|
|
"""Return a human-readable representation of a subcategory"""
|
2020-01-13 22:29:42 +01:00
|
|
|
|
if c in SUBCATEGORY_MAP:
|
|
|
|
|
scm = SUBCATEGORY_MAP[c]
|
|
|
|
|
if sc in scm:
|
|
|
|
|
return scm[sc]
|
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
if sc in SUBCATEGORY_MAP:
|
|
|
|
|
return SUBCATEGORY_MAP[sc]
|
2020-01-13 22:29:42 +01:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
sc = sc.capitalize()
|
|
|
|
|
return sc if sc.endswith("s") else sc + "s"
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
def category_key(c):
|
2019-02-20 19:25:41 +01:00
|
|
|
|
"""Generate sorting keys by category"""
|
2021-02-20 22:31:21 +01:00
|
|
|
|
return category_text(c[0]).lower()
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
def subcategory_key(sc):
|
2019-02-20 19:25:41 +01:00
|
|
|
|
"""Generate sorting keys by subcategory"""
|
2021-02-20 22:31:21 +01:00
|
|
|
|
return "A" if sc == "issue" else sc
|
2017-07-15 15:01:30 +02:00
|
|
|
|
|
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
def build_extractor_list():
|
|
|
|
|
"""Generate a sorted list of lists of extractor classes"""
|
2021-02-20 22:31:21 +01:00
|
|
|
|
categories = collections.defaultdict(list)
|
|
|
|
|
domains = {}
|
2017-04-23 17:08:45 +02:00
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
for extr in extractor._list_classes():
|
|
|
|
|
category = extr.category
|
|
|
|
|
if category in IGNORE_LIST:
|
2017-06-15 21:06:20 +02:00
|
|
|
|
continue
|
2021-02-20 22:31:21 +01:00
|
|
|
|
if category:
|
|
|
|
|
categories[category].append(extr.subcategory)
|
|
|
|
|
if category not in domains:
|
|
|
|
|
domains[category] = domain(extr)
|
|
|
|
|
else:
|
|
|
|
|
for category, root in extr.instances:
|
|
|
|
|
categories[category].append(extr.subcategory)
|
|
|
|
|
if category not in domains:
|
|
|
|
|
domains[category] = root + "/"
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
# sort subcategory lists
|
|
|
|
|
for subcategories in categories.values():
|
|
|
|
|
subcategories.sort(key=subcategory_key)
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
# add e-hentai.org
|
|
|
|
|
categories["e-hentai"] = categories["exhentai"]
|
|
|
|
|
domains["e-hentai"] = domains["exhentai"].replace("x", "-")
|
2019-08-03 11:42:28 +02:00
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
return categories, domains
|
2019-02-20 19:25:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# define table columns
|
|
|
|
|
COLUMNS = (
|
|
|
|
|
("Site", 20,
|
2021-02-20 22:31:21 +01:00
|
|
|
|
lambda c, scs, d: category_text(c)),
|
2019-02-20 19:25:41 +01:00
|
|
|
|
("URL" , 35,
|
2021-02-20 22:31:21 +01:00
|
|
|
|
lambda c, scs, d: d),
|
2019-02-20 19:25:41 +01:00
|
|
|
|
("Capabilities", 50,
|
2021-02-20 22:31:21 +01:00
|
|
|
|
lambda c, scs, d: ", ".join(subcategory_text(c, sc) for sc in scs
|
|
|
|
|
if subcategory_text(c, sc))),
|
2019-02-20 19:25:41 +01:00
|
|
|
|
("Authentication", 16,
|
2021-02-20 22:31:21 +01:00
|
|
|
|
lambda c, scs, d: AUTH_MAP.get(c, "")),
|
2019-02-20 19:25:41 +01:00
|
|
|
|
)
|
2019-01-09 14:21:19 +01:00
|
|
|
|
|
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
def write_output(fp, columns, categories, domains):
|
2019-02-05 16:17:25 +01:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
def pad(output, col, category=None):
|
|
|
|
|
size = col[1]
|
|
|
|
|
output = output if isinstance(output, str) else col[2](output)
|
2019-02-08 20:08:16 +01:00
|
|
|
|
|
2020-07-14 16:18:21 +02:00
|
|
|
|
if len(output) > size and col[0][0] != "A":
|
2019-02-20 19:25:41 +01:00
|
|
|
|
sub = "|{}-{}|".format(category, col[0][0])
|
|
|
|
|
subs.append((sub, output))
|
|
|
|
|
output = sub
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
return output + " " * (size - len(output))
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
w = fp.write
|
2019-02-20 19:25:41 +01:00
|
|
|
|
subs = []
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
# caption
|
|
|
|
|
w("Supported Sites\n")
|
|
|
|
|
w("===============\n")
|
2021-01-22 21:02:12 +01:00
|
|
|
|
w("..\n generated by {}\n\n".format(
|
|
|
|
|
"/".join(os.path.normpath(__file__).split(os.sep)[-2:])))
|
|
|
|
|
w("Consider all sites to be NSFW, unless otherwise known.\n\n")
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
# table head
|
|
|
|
|
sep = " ".join("=" * c[1] for c in columns) + "\n"
|
|
|
|
|
w(sep)
|
|
|
|
|
w(" ".join(pad(c[0], c) for c in columns).strip() + "\n")
|
|
|
|
|
w(sep)
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
# table body
|
2021-02-20 22:31:21 +01:00
|
|
|
|
clist = sorted(categories.items(), key=category_key)
|
|
|
|
|
for category, subcategories in clist:
|
|
|
|
|
domain = domains[category]
|
2019-02-20 19:25:41 +01:00
|
|
|
|
w(" ".join(
|
2021-02-20 22:31:21 +01:00
|
|
|
|
pad(col[2](category, subcategories, domain), col, category)
|
2019-02-20 19:25:41 +01:00
|
|
|
|
for col in columns
|
|
|
|
|
).strip())
|
|
|
|
|
w("\n")
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
# table bottom
|
|
|
|
|
w(sep)
|
|
|
|
|
w("\n")
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2019-02-20 19:25:41 +01:00
|
|
|
|
# substitutions
|
|
|
|
|
for sub, value in subs:
|
|
|
|
|
w(".. {} replace:: {}\n".format(sub, value))
|
2017-04-20 16:56:50 +02:00
|
|
|
|
|
2017-01-15 21:31:21 +01:00
|
|
|
|
|
2021-02-20 22:31:21 +01:00
|
|
|
|
categories, domains = build_extractor_list()
|
2017-01-15 21:31:21 +01:00
|
|
|
|
outfile = sys.argv[1] if len(sys.argv) > 1 else "supportedsites.rst"
|
2019-04-16 18:16:48 +02:00
|
|
|
|
with open(util.path("docs", outfile), "w") as file:
|
2021-02-20 22:31:21 +01:00
|
|
|
|
write_output(file, COLUMNS, categories, domains)
|