AGENTS/CONTEXT: new sources (cogito person pages, livelib author pages), verified RU editions (Franz, Jaffé/Man&HisSymbols, Lüscher, Kandinsky, Kast, Schaverien)
This commit is contained in:
parent
7514f26fc2
commit
a6c062344f
3 changed files with 48 additions and 6 deletions
16
tools/rsl.py
16
tools/rsl.py
|
|
@ -19,18 +19,28 @@ def fetch(url, tries=3):
|
|||
|
||||
def main():
|
||||
q = sys.argv[1]
|
||||
maxpages = int(sys.argv[2]) if len(sys.argv) > 2 else 4
|
||||
maxpages = int(sys.argv[2]) if len(sys.argv) > 2 else 2
|
||||
seen = set()
|
||||
for page in range(1, maxpages + 1):
|
||||
url = "https://libgen.vg/biblioservice.php?" + urllib.parse.urlencode(
|
||||
{"value": q, "type": "rsl", "format": "json", "page": page})
|
||||
d = json.loads(fetch(url))
|
||||
try:
|
||||
d = json.loads(fetch(url))
|
||||
except SystemExit:
|
||||
print("(fetch failed)")
|
||||
break
|
||||
recs = {k: v for k, v in d.items() if k != "error"}
|
||||
if not recs:
|
||||
if page == 1:
|
||||
print("(no records)")
|
||||
break
|
||||
new = 0
|
||||
for k in sorted(recs, key=int):
|
||||
r = recs[k]
|
||||
if r["id"] in seen:
|
||||
continue
|
||||
seen.add(r["id"])
|
||||
new += 1
|
||||
title = " ".join(r.get("title", [])) + (
|
||||
(" : " + r["title_add"]) if r.get("title_add") else "")
|
||||
author = "; ".join(r.get("author", []))
|
||||
|
|
@ -43,6 +53,8 @@ def main():
|
|||
print(f"[{r['id']}] {title}")
|
||||
print(f" {author}")
|
||||
print(f" {city} : {pub}, {year} | {pages} | {isbn}" + (f" | серия: {series}" if series else ""))
|
||||
if new == 0:
|
||||
break
|
||||
time.sleep(3)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue