@@ -0,0 +1,1362 @@
+# -*- coding: utf-8 -*-%0Aimport argparse%0Aimport os%0A%0Aos.environ%5B'PYWIKIBOT_DIR'%5D = os.path.dirname(os.path.realpath(__file__))%0Aimport pywikibot%0A%0A%0Asite = pywikibot.Site()%0Asite.login()%0Adatasite = site.data_repository()%0A%0Awdsite = pywikibot.Site('wikidata', 'wikidata')%0Awdsite.login()%0A%0A%0Adef importSitelinks(title):%0A    print(title)%0A%0A    myitem = pywikibot.ItemPage(datasite, title)%0A    mysitelinks = myitem.get()%5B'sitelinks'%5D%0A    if 'wikidatawiki' in mysitelinks:%0A        wditem = pywikibot.ItemPage(wdsite, mysitelinks%5B'wikidatawiki'%5D)%0A        wdsitelinks = wditem.get()%5B'sitelinks'%5D%0A        data = %7B%0A            'sitelinks': %5B%5D%0A        %7D%0A        for sitelink in wdsitelinks:%0A            data%5B'sitelinks'%5D.append(%7B%0A                'site': sitelink,%0A                'title': wdsitelinks%5Bsitelink%5D%0A            %7D)%0A        summary = '%E5%8C%AF%E5%85%A5%E7%B6%B2%E7%AB%99%E9%80%A3%E7%B5%90%EF%BC%8C%E4%BE%86%E8%87%AA%5B%5Bwikidata:%7B%7D%5D%5D'.format(mysitelinks%5B'wikidatawiki'%5D)%0A        print(data)%0A        print(summary)%0A        myitem.editEntity(data, summary=summary)%0A%0A%0Adef main():%0A    animeitem = pywikibot.ItemPage(datasite, 'Q53')%0A%0A    for backlink in animeitem.backlinks():%0A        importSitelinks(backlink.title())%0A%0A%0Aif __name__ == %22__main__%22:%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument('title', nargs='?')%0A    args = parser.parse_args()%0A    if args.title is None:%0A        main()%0A    else:%0A        importSitelinks(args.title)%0A

Create my-ACG/import-sitelinks