User:GalliumBot/minos/minos.py

"""
Copyright (c) 2023 theleekycauldron

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"""
import pywikibot as pwb
site = pwb.Site()

cat = pwb.Category(site,"Category:Pending DYK nominations")
pages = [pwb.Page(site,"Template talk:Did you know"),pwb.Page(site,"Template talk:Did you know/Approved")]
content = pages[0].text+"\n"+pages[1].text
res = []

for page in cat.articles():
    if page.title()[9:]+"}}" not in content and page.title()[:14] != "Template talk:":
        res.append(page.title())

output = "{{flatlist|"
for page in res:
    output += f"* {{{{dykn|page}}}}\n"
output = output[:-1]+"}}\n'''Total''': "+str(len(res))

target = pwb.Page(site,"User:GalliumBot/minos/list")
target.text = output
target.save(summary="updating :)")