jung/tools/en_sweep_0106.py
Dmitry Kokorin 99e889d206 sec03 EN sweep 01-06: +7 files (15,19,31,32,33,36,47) + Eliade canonical move (sec05#07 -> sec03#25)
libgen re-sweep of EN gaps in sections 01-06 (user request; improved sweep:
file-level objects[]=f + full 100-row dumps) — 75 candidates, 7 rescues verified:
- sec03 #15 Witches Ogres (Shambhala 1992, 236pp, cover OK)
- sec03 #19 Hermes and His Children (Daimon 2020 2nd ed., epub ISBN in file)
- sec03 #31 European Folktale (Indiana 1986, 204pp, cover OK)
- sec03 #32 Fairytale as Art Form (Indiana 1987, 232pp, title OK)
- sec03 #33 Once Upon a Time (Ungar 1976 1st ed., 204pp, title OK; RAW 'Indiana 1970' = ISAP typo)
- sec03 #36 Irresistible Fairy Tale (Princeton 2012, epub OK)
- sec03 #47 Heart of the Hunter (Vintage 2010, mobi)
+ sec02 #16 A Little Course in Dreams (Shambhala 1986, 137pp, verified)

Canonical location fix: Eliade 'Myths, Dreams and Mysteries' files moved
sec05 -> sec03 (first appearance); sec03 #25 card ❌ -> ✅ (RU was found in sec05
rescue 2026-09-21, card was stale).

Still downloading (queue tools/lgdl-en0106-queue.sh): sec03 #50 (Atlas x4), #55, #57,
sec04 #04 (Art of C.G. Jung 2018, 298MB), #17, sec01 #42 (Freud Unconscious Penguin).
Rejected: 04#23 Encyclopedia (JSTOR article 467KB), 05#16 Singer 2023 (different book).
2026-09-29 08:54:31 +03:00

138 lines
6.7 KiB
Python

#!/usr/bin/env python3
"""tools/en_sweep_0106.py — re-sweep EN gaps of sections 01-06 (2026-09-28, user request).
Round 1: soft libgen queries (author + 1-2 title words), whole-word semantics.
Saves data/en-sweep-0106.tsv: sec,item,query,n,top3 (first lines).
Polite: 4s between queries. Resume-safe (skips items already in TSV).
"""
import os, re, sys, time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from lg import fetch, UA
OUT = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "data", "en-sweep-0106.tsv")
CANDIDATES = [
# (sec, item, query, note)
("01","13","Franz inferior function","Shambhala 1993"),
("01","16","Henderson shadow self","Chiron 1990"),
("01","38","Douglas woman mirror","Sigo 1989"),
("01","42","Freud unconscious","SE 14"),
("01","48","Meier consciousness","Sigo 1989"),
("01","50","Molton eternal women","Fisher King 2011"),
("01","52","Stevens on jung","Princeton 1990"),
("01","54","Ulanov transforming sexuality","Shambhala 1994"),
("02","16","little course dreams","Shambhala 1988"),
("02","20","way of dream","Windrose 1988"),
("02","23","clinical uses dreams","Hall 1977"),
("02","42","dream tending","2009"),
("03","06","Dieckmann twice told tales","Chiron"),
("03","12","archetypal symbols profane","Franz vol1 2021"),
("03","13","archetypal symbols hero","Franz vol2 2021"),
("03","14","archetypal symbols maiden","Franz vol3 2021"),
("03","15","witches ogres","Jacoby/Kast/Riedel 1992"),
("03","17","kast emotions maturity","Fromm 1993"),
("03","19","Lopez-Pedraza hermes","Daimon 1989"),
("03","21","psyche stories","Stein/Corbett Chiron"),
("03","31","Luthi european folktale","Indiana 1986"),
("03","32","Luthi art form","Indiana"),
("03","33","Luthi once upon","Indiana"),
("03","36","Zipes irresistible","Princeton 2012"),
("03","47","Post heart hunter","Van der Post 1961"),
("03","49","animal life myth dreams","Caspari/Robbins Chiron 2003"),
("03","50","historical atlas mythology","Caspari/Robbins"),
("03","53","folklore mythology legend","Leach/Fried"),
("03","54","herder dictionary symbols","Chiron 1993"),
("03","55","teutonic myth legend","MacKenzie 2008"),
("03","57","primal myths","Sproul 1979"),
("03","58","ariadne clue","Stevens 1998"),
("03","59","motif index folklore","Thompson"),
("03","61","american indian mythology","Burland 1996"),
("03","63","animal within","Federer 2002"),
("03","64","hill fairy tale drama","Jung and Moreno 2014"),
("03","65","gilgamesh significance","Kluger 1991"),
("03","67","celtic heritage","Rees 1998"),
("04","04","art of jung","Norton 2018"),
("04","06","acton paintings","Routledge 2008"),
("04","07","acton modern art","Routledge 2004"),
("04","08","patterns creative imagination","Brutsche Chiron 2018"),
("04","09","creative fingerprint","Carter/Staples 2017"),
("04","11","dynamics of symbols","Schaverien 1992"),
("04","12","sandplay vulnerable","Pattis Zoja 2011"),
("04","13","soul meets matter","Pattis Zoja 2018"),
("04","14","painting therapy","Riedel/Henzler Daimon 2022"),
("04","15","psyche and the arts","Rowland 2008"),
("04","16","revealing image","Schaverien 1999"),
("04","17","art psychotherapy psychosis","Routledge 1997"),
("04","18","healing transformation sandplay","Ammann 1991"),
("04","19","spontaneous paintings","Geigy 1969"),
("04","20","life paints span","Bach Daimon 1990"),
("04","21","personality tree drawings","Bolander 1977"),
("04","23","encyclopedia archetypal symbolism","Shambhala (v1 Moon 1997 / v2 Elder 1996)"),
("04","26","secret world drawings","Peiry Sigo 2002"),
("04","27","images meanings connection","Goldstein Daimon 1999"),
("04","29","horizons sandplay","Kalff T&F 2021"),
("04","31","tree test","Huber 1952"),
("04","33","imagination in action","McNiff Shambhala 2015"),
("04","34","depth psychology of art","C.C. Thomas 1999"),
("04","35","integrating arts therapy","C.C. Thomas 2004"),
("05","04","buhrmann","Chiron 1993"),
("05","05","burleson","1981"),
("05","14","thresholds of initiation","Henderson (ia RESTRICTED)"),
("05","15","kirsch","SUNY 1997"),
("05","16","cultural complex","Singer"),
("05","23","lewis-williams dowson","1988"),
("06","04","idea of the numinous","Chiron 2006"),
("06","07","passion of perpetua","von Franz"),
("06","08","niklaus von flue","2022 EN"),
("06","10","jung white letters",""),
("06","15","jung treatment christianity","Stein (ia CDL)"),
("06","21","satan old testament","(ia CDL)"),
("06","22","religion greeks romans","(ia CDL)"),
]
def parse_rows(html):
rows = re.findall(r"<tr[^>]*>\s*<td[^>]*>.*?</tr>", html, re.S)
out = []
for r in rows:
tds = re.findall(r"<td[^>]*>(.*?)</td>", r, re.S)
tds = [re.sub(r"<[^>]+>", "", t).replace("&amp;", "&").strip() for t in tds]
tds = [re.sub(r"\s+", " ", t) for t in tds]
if len(tds) >= 6:
md5s = re.findall(r"ads\.php\?md5=([0-9a-f]{32})", r)
ids = re.findall(r"edition\.php\?id=(\d+)", r)
out.append((len(tds), tds, md5s[0] if md5s else "", ids[0] if ids else ""))
return out
def main():
done = set()
if os.path.exists(OUT):
for ln in open(OUT):
p = ln.split("\t")
if len(p) > 1:
done.add((p[0], p[1]))
new = [c for c in CANDIDATES if (c[0], c[1]) not in done]
print(f"{len(new)} candidates to sweep ({len(done)} already done)", flush=True)
fh = open(OUT, "a", encoding="utf-8")
for i, (sec, item, q, note) in enumerate(new, 1):
url = ("https://libgen.vg/index.php?req=" + urllib.parse.quote(q) +
"&res=100&columns%5B%5D=t&columns%5B%5D=a&columns%5B%5D=s&columns%5B%5D=y&columns%5B%5D=p&columns%5B%5D=i"
"&objects%5B%5D=f&objects%5B%5D=e&objects%5B%5D=s&objects%5B%5D=a&objects%5B%5D=p&objects%5B%5D=w"
"&topics%5B%5D=l&topics%5B%5D=c&topics%5B%5D=f&topics%5B%5D=a&topics%5B%5D=m&topics%5B%5D=r&topics%5B%5D=s")
try:
html = fetch(url, tries=2)
rows = parse_rows(html)
top = " || ".join(" / ".join(r[1][:6]) + (f" [md5={r[2]}]" if r[2] else "") for r in rows[:4])
status = f"HITS={len(rows)}"
except Exception as e:
status, top = f"ERR {e}", ""
fh.write(f"{sec}\t{item}\t{q}\t{status}\t{top[:600]}\n{note}\n")
fh.flush()
print(f"[{i}/{len(new)}] {sec}#{item} '{q}' -> {status}", flush=True)
time.sleep(4)
fh.close()
print("SWEEP DONE", flush=True)
import urllib.parse
if __name__ == "__main__":
main()