KennyOlympia.php 2.43 KB
Newer Older
Freddy's avatar
Freddy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#!/usr/bin/php
<?php
require 'Core/BotCore.php';
/** KennyOlympia.php
* Check missing links in Category:Olympische Spiele
* @Author Freddy2001 <freddy2001@wikipedia.de>
* @Version 0.1
* @Status Alpha
* @Runs Manually, on request
*/
class KennyOlympia extends Core {
	public function KennyOlympia ($Account, $Job, $pUseHTTPS = true) {
		$this->initcurl ($Account, $Job, $pUseHTTPS = true);
		echo "---" . $Job . "---\nDurchlauf: " . date ('l jS F Y H:i:s') . "\n---\n";
		$members = file_get_contents("https://petscan.wmflabs.org/?language=de&project=wikipedia&depth=15&categories=Olympische%20Spiele&combination=subset&negcats=&larger=&smaller=&minlinks=&maxlinks=&before=&after=&max_age=&show_redirects=both&edits%5Bbots%5D=both&edits%5Banons%5D=both&edits%5Bflagged%5D=both&templates_yes=&templates_any=&templates_no=&outlinks_yes=&outlinks_any=&outlinks_no=&links_to_all=&links_to_any=&links_to_no=&sparql=&manual_list=&manual_list_wiki=&pagepile=&wikidata_source_sites=&subpage_filter=either&common_wiki=auto&source_combination=&wikidata_item=no&wikidata_label_language=&wikidata_prop_item_use=&wpiu=any&sitelinks_yes=&sitelinks_any=&sitelinks_no=&min_sitelink_count=&max_sitelink_count=&labels_yes=&cb_labels_yes_l=1&langs_labels_yes=&labels_any=&cb_labels_any_l=1&langs_labels_any=&labels_no=&cb_labels_no_l=1&langs_labels_no=&format=json&output_compatability=catscan&sortby=none&sortorder=ascending&regexp_filter=&min_redlink_count=1&doit=Do%20it%21&interface_language=en&active_tab=tab_output");
		$members = json_decode($members, true);
		$members = $members['*'][0]['a']['*'];
		$titles = array();
		for($i = 0; $i < count($members); $i++) {
			$titles[] = str_replace("_", " ", $members[$i]['title']);
		}
		$members = $titles;
		sort($members, SORT_STRING);
		for($i = 0; $i < count($members); $i++) {
			echo "Checking Article ";
			echo $i+1 . " of " . count($members) . ": " . $members[$i] ;
			$links = $this->getLinks($members[$i]);
			echo " (" . count($links) . " links)\n";
			$missinglinks = $this->getMissingLinks($members[$i]);
			if($missinglinks !== false) {
				for($j = 0; $j < count($missinglinks); $j++) {
					$rotlinks[] = $missinglinks[$j];
				}
			}
		}
		$result = array_unique($rotlinks);
		sort($result, SORT_STRING);
		$textfile = "";
		for($i = 0; $i < count($result); $i++) {
			$textfile .= "* [[" . $result[$i] . "]]\n";
		}
		file_put_contents("wikitext.txt", $textfile);
	}
}
Freddy's avatar
Freddy committed
45
$Bot = new KennyOlympia ('LarusBot@dewiki', 'KennyOlympia');
Freddy's avatar
Freddy committed
46
?>