tv-anarchy/search/collect_gaps.py

53 lines
2 KiB
Python

import asyncio
from torrent_search.wrapper import TorrentSearchApi
async def main():
api = TorrentSearchApi()
out = []
# Psych missing seasons (i_c uploader, avoid 'psycho' collisions)
for s in (1, 2, 3, 7, 8):
best = None
for q in (f"psych 2006 season {s} complete 720p", f"psych 2006 season {s}"):
ts = await api.search_torrents(q, max_items=25)
for t in ts:
fn = t.filename.lower()
if "psych 2006" in fn and "psycho" not in fn and (
f"season {s} " in fn or f"season {s}c" in fn or f"season {s}." in fn
):
if t.magnet_link and "btih:" in t.magnet_link:
best = t
break
if best:
break
if best:
ih = best.magnet_link.split("btih:", 1)[1][:40]
out.append(f"P{s:02d}|{ih}|{best.size}|{best.seeders}|{best.filename[:50]}")
else:
out.append(f"P{s:02d}|MISSING")
# South Park S25/S26
for s in (25, 26):
best = None
for q in (f"south park season {s} 1080p", f"south park s{s} 1080p", f"south park season {s}"):
ts = await api.search_torrents(q, max_items=25)
for t in ts:
fn = t.filename.lower()
if "south park" in fn and (
f"season {s}" in fn or f"s{s} " in fn or f"s{s}." in fn or f"s{s}c" in fn
) and " to " not in fn and "-s" not in fn:
if t.magnet_link and "btih:" in t.magnet_link:
best = t
break
if best:
break
if best:
ih = best.magnet_link.split("btih:", 1)[1][:40]
out.append(f"SP{s}|{ih}|{best.size}|{best.seeders}|{best.filename[:50]}")
else:
out.append(f"SP{s}|MISSING")
with open("/tmp/gaps_picks.txt", "w") as fh:
fh.write("\n".join(out) + "\n")
print("\n".join(out))
asyncio.run(main())