diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f4773f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.php diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..60cae7d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "includes/boz-mw"] + path = includes/boz-mw + url = https://github.com/valerio-bozzolan/boz-mw.git diff --git a/2017-11-wikidata-volleyball-players/commons-volleyball-nationalities.csv b/2017-11-wikidata-volleyball-players/commons-volleyball-nationalities.csv new file mode 100644 index 0000000..95aaea5 --- /dev/null +++ b/2017-11-wikidata-volleyball-players/commons-volleyball-nationalities.csv @@ -0,0 +1,35 @@ +ARG;Q414;argentino;argentina;Argentinean;Volleyball players from Argentina;Men's volleyball players from Argentina +AUS;Q408;australiano;australiana;Australian;Volleyball players from Australia;Men's volleyball players from Australia +AUT;Q40;austriaco;austriaca;Austrian;Volleyball players from Austria +BEL;Q31;belga;belga;Belgian;Volleyball players from Belgium +BRA;Q155;brasiliano;brasiliana;Brazilian;Volleyball players from Brazil +BUL;Q219;bulgaro;bulgara;Bulgarian;Volleyball players from Bulgaria +CAN;Q16;canadese;canadese;Canadian;Volleyball players from Canada;Men's volleyball players from Canada +CHI;Q298;cileno;cilena;Chilean;Volleyball players from Chile +CMR;Q1009;camerunense;camerunense;Cameroonian;Volleyball players from Cameroon +CRO;Q224;croato;croata;Croatian;Volleyball players from Croatia +CUB;Q241;cubano;cubana;Cuban;Volleyball players from Cuba;Men's volleyball players from Cuba +CZE;Q213;ceco;ceca;Czech;Volleyball players from the Czech Republic;Men's volleyball players from the Czech Republic +DEN;Q35;danese;danese;Danish;Volleyball players from Denmark +ESP;Q29;spagnolo;spagnola;Spanish;Men's volleyball players from Spain +EST;Q191;estone;estone;Estonian;Volleyball players from Estonia +FIN;Q33;finlandese;finlandese;Finnish;Volleyball players from Finland +FRA;Q142;francese;francese;French;Volleyball players from France;Men's volleyball players from France +GER;Q183;tedesco;tedesca;German;Volleyball players from Germany +GRE;Q41;greco;greca;Greek;Volleyball players from Greece +IRI;Q794;iraniano;iraniana;Iranian;Volleyball players from Iran +ISR;Q801;israeliano;israeliana;Israeli;Volleyball players from Israel +ITA;Q38;italiano;italiana;Italian;Volleyball players from Italy;Men's volleyball players from Italy +JPN;Q17;giapponese;giapponese;Japanese;Volleyball players from Japan +LAT;Q211;lettone;lettone;Latvian;Volleyball players from Latvia +MNE;Q236;montenegrino;montenegrina;Montenegrin;Volleyball players from Montenegro +NED;Q55;olandese;olandese;Dutch;Volleyball players from the Netherlands +POL;Q36;polacco;polacca;Polish;Volleyball players from Poland +PUR;Q1183;portoricano;portoricana;Puerto Rican;Volleyball players from Puerto Rico +SLO;Q215;sloveno;slovena;Slovenian;Volleyball players from Slovenia;Men's volleyball players from Slovenia +SRB;Q403;serbo;serba;Serbian;Volleyball players from Serbia +SVK;Q214;slovacco;slovacca;Slovakian;Volleyball players from Slovakia +SWE;Q9027;svedese;svedese;Swedish;Volleyball players from Sweden +UKR;Q212;ucraino;ucraina;Ukranian;Volleyball players from Ukraine;Men's volleyball players from Ukraine +USA;Q30;statunitense;statunitense;American;Volleyball players from the United States;Men's volleyball players from the United States +VEN;Q717;venezuelano;venezuelana;Venezuelan;Volleyball players from Venezuela diff --git a/2017-11-wikidata-volleyball-players/commons-volleyball-players.csv b/2017-11-wikidata-volleyball-players/commons-volleyball-players.csv new file mode 100644 index 0000000..c881d19 --- /dev/null +++ b/2017-11-wikidata-volleyball-players/commons-volleyball-players.csv @@ -0,0 +1,360 @@ +Cognome,Nome,nazionalita,File name +Carminati,Ludovico,ITA,Ludovico Carminati (Legavolley 2017) +Casadei,Alberto,ITA,Alberto Casadei (Legavolley 2017) +Casulli,Cesare,ITA,Cesare Casulli (Legavolley 2017) +Catena,Stefano,ITA,Stefano Catena (Legavolley 2017) +Cattaneo,Claudio,ITA,Claudio Cattaneo (Legavolley 2017) +Cavaccini,Domenico,ITA,Domenico Cavaccini (Legavolley 2017) +Cavuto,Oreste,ITA,Oreste Cavuto (Legavolley 2017) +Cazzaniga,Roberto,ITA,Roberto Cazzaniga (Legavolley 2017) +Cecato,Nicola,ITA,Nicola Cecato (Legavolley 2017) +Cernic,Matej,ITA,Matej Cernic (Legavolley 2017) +Cesarini,Andrea,ITA,Andrea Cesarini (Legavolley 2017) +Cester,Davide,ITA,Davide Cester (Legavolley 2017) +Cester,Enrico,ITA,Enrico Cester (Legavolley 2017) +Cetrullo,Leano,ITA,Leano Cetrullo (Legavolley 2017) +Chadtchyn,Alexander,ITA,Alexander Chadtchyn (Legavolley 2017) +Chiappa,Matteo,ITA,Matteo Chiappa (Legavolley 2017) +Cioffi,Massimiliano,ITA,Massimiliano Cioffi (Legavolley 2017) +Cisolla,Alberto,ITA,Alberto Cisolla (Legavolley 2017) +Ciulli,Filippo,ITA,Filippo Ciulli (Legavolley 2017) +Codarin,Lorenzo,ITA,Lorenzo Codarin (Legavolley 2017) +Colaci,Massimo,ITA,Massimo Colaci (Legavolley 2017) +Colli,Leonardo,ITA,Leonardo Colli (Legavolley 2017) +Cominetti,Roberto,ITA,Roberto Cominetti (Legavolley 2017) +Copelli,Riccardo,ITA,Riccardo Copelli (Legavolley 2017) +Cordano,Andrea,ITA,Andrea Cordano (Legavolley 2017) +Corrado,Francesco,ITA,Francesco Corrado (Legavolley 2017) +Cortellazzi,Emiliano,ITA,Emiliano Cortellazzi (Legavolley 2017) +Cortesia,Lorenzo,ITA,Lorenzo Cortesia (Legavolley 2017) +Corvetta,Antonio,ITA,Antonio Corvetta (Legavolley 2017) +Coscione,Manuel,ITA,Manuel Coscione (Legavolley 2017) +Costanzi,Riccardo,ITA,Riccardo Costanzi (Legavolley 2017) +Cottarelli,Francesco,ITA,Francesco Cottarelli (Legavolley 2017) +Crescini,Keriann,ITA,Keriann Crescini (Legavolley 2017) +Cristofaletti,Mirco,ITA,Mirco Cristofaletti (Legavolley 2017) +Cro',Daniele,ITA,Daniele Cro' (Legavolley 2017) +Cruz,Nandy,ITA,Nandy Cruz (Legavolley 2017) +Cubito,Marco,ITA,Marco Cubito (Legavolley 2017) +D'Amico,Francesco,ITA,Francesco D'Amico (Legavolley 2017) +Dal Corso,Gianluca,ITA,Gianluca Dal Corso (Legavolley 2017) +Daldello,Nicola,ITA,Nicola Daldello (Legavolley 2017) +Danielli,Simone,ITA,Simone Danielli (Legavolley 2017) +De Angelis,Carlo,ITA,Carlo De Angelis (Legavolley 2017) +De Fabritiis,Giacomo,ITA,Giacomo De Fabritiis (Legavolley 2017) +De Marchi,Francesco,ITA,Francesco De Marchi (Legavolley 2017) +De Pandis,Daniele,ITA,Daniele De Pandis (Legavolley 2017) +De Paola,Antonio,ITA,Antonio De Paola (Legavolley 2017) +De Santis,Saverio,ITA,Saverio De Santis (Legavolley 2017) +De Santis,Danilo,ITA,Danilo De Santis (Legavolley 2017) +De Togni,Giorgio,ITA,Giorgio De Togni (Legavolley 2017) +Del Vecchio,Francesco,ITA,Francesco Del Vecchio (Legavolley 2017) +Della Lunga,Dore,ITA,Dore Della Lunga (Legavolley 2017) +Della Rosa,Mattia,ITA,Mattia Della Rosa (Legavolley 2017) +Di Carlo,Andrea,ITA,Andrea Di Carlo (Legavolley 2017) +Di Meo,Pietro,ITA,Pietro Di Meo (Legavolley 2017) +Di Renzo,Leonardo,ITA,Leonardo Di Renzo (Legavolley 2017) +Di Silvestre,Paolo Luigi,ITA,Paolo Luigi Di Silvestre (Legavolley 2017) +Di Tommaso,Simone,ITA,Simone Di Tommaso (Legavolley 2017) +Diamantini,Enrico,ITA,Enrico Diamantini (Legavolley 2017) +Dolfo,Ludovico,ITA,Ludovico Dolfo (Legavolley 2017) +Elia,Alberto,ITA,Alberto Elia (Legavolley 2017) +Erati,Alex,ITA,Alex Erati (Legavolley 2017) +Esposito,Davide,ITA,Davide Esposito (Legavolley 2017) +Fabi,Tommaso,ITA,Tommaso Fabi (Legavolley 2017) +Fabroni,Marco,ITA,Marco Fabroni (Legavolley 2017) +Fantini,Jacopo,ITA,Jacopo Fantini (Legavolley 2017) +Fanuli,Fabio,ITA,Fabio Fanuli (Legavolley 2017) +Federici,Filippo,ITA,Filippo Federici (Legavolley 2017) +Fedrizzi,Michele,ITA,Michele Fedrizzi (Legavolley 2017) +Fei,Alessandro,ITA,Alessandro Fei (Legavolley 2017) +Ferrari,Jacopo,ITA,Jacopo Ferrari (Legavolley 2017) +Ferraro,Mario,ITA,Mario Ferraro (Legavolley 2017) +Ferri,Stefano,ITA,Stefano Ferri (Legavolley 2017) +Festi,Roberto,ITA,Roberto Festi (Legavolley 2017) +Fiore,Alessio,ITA,Alessio Fiore (Legavolley 2017) +Fiori,Federico,ITA,Federico Fiori (Legavolley 2017) +Fortunato,Nicola,ITA,Nicola Fortunato (Legavolley 2017) +Franceschini,Alessandro,ITA,Alessandro Franceschini (Legavolley 2017) +Franzoni,Andrea,ITA,Andrea Franzoni (Legavolley 2017) +Frattini,Alessandro,ITA,Alessandro Frattini (Legavolley 2017) +Frigo,Thomas,ITA,Thomas Frigo (Legavolley 2017) +Fusco,Pasquale,ITA,Pasquale Fusco (Legavolley 2017) +Galabinov,Yordan,ITA,Yordan Galabinov (Legavolley 2017) +Galassi,Gianluca,ITA,Gianluca Galassi (Legavolley 2017) +Galliani,Andrea,ITA,Andrea Galliani (Legavolley 2017) +Gardini,Davide,ITA,Davide Gardini (Legavolley 2017) +Gargiulo,Giovanni Maria,ITA,Giovanni Maria Gargiulo (Legavolley 2017) +Garnica,Fernando Gabriel,ITA,Fernando Gabriel Garnica (Legavolley 2017) +Garofolo,Fabrizio,ITA,Fabrizio Garofolo (Legavolley 2017) +Gaspari,Massimo,ITA,Massimo Gaspari (Legavolley 2017) +Gentilini,Marco,ITA,Marco Gentilini (Legavolley 2017) +Giacobelli,Mario,ITA,Mario Giacobelli (Legavolley 2017) +Giannotti,Stefano,ITA,Stefano Giannotti (Legavolley 2017) +Giosa,Alessandro,ITA,Alessandro Giosa (Legavolley 2017) +Giovi,Andrea,ITA,Andrea Giovi (Legavolley 2017) +Gitto,Carmelo,ITA,Carmelo Gitto (Legavolley 2017) +Giuliani,Ludovico,ITA,Ludovico Giuliani (Legavolley 2017) +Goi,Riccardo,ITA,Riccardo Goi (Legavolley 2017) +Gozzo,Stefano,ITA,Stefano Gozzo (Legavolley 2017) +Gradi,Cesare,ITA,Cesare Gradi (Legavolley 2017) +Grassano,Michele,ITA,Michele Grassano (Legavolley 2017) +Grassi,Tommaso,ITA,Tommaso Grassi (Legavolley 2017) +Graziani,Alessandro,ITA,Alessandro Graziani (Legavolley 2017) +Held,Tim,ITA,Tim Held (Legavolley 2017) +Ingrosso,Paolo,ITA,Paolo Ingrosso (Legavolley 2017) +Innocenti,Luca,ITA,Luca Innocenti (Legavolley 2017) +Ippolito,Andrea,ITA,Andrea Ippolito (Legavolley 2017) +Izzo,Marco,ITA,Marco Izzo (Legavolley 2017) +Juantorena,Osmany,ITA,Osmany Juantorena (Legavolley 2017) +Katalan,Nicolò,ITA,Nicolò Katalan (Legavolley 2017) +Kindgard,Martin Alberto,ITA,Martin Alberto Kindgard (Legavolley 2017) +Kovar,Jiri,ITA,Jiri Kovar (Legavolley 2017) +Lanci,Andrea,ITA,Andrea Lanci (Legavolley 2017) +Lanza,Filippo,ITA,Filippo Lanza (Legavolley 2017) +Larizza,Jacopo,ITA,Jacopo Larizza (Legavolley 2017) +Lavanga,Antonio Jun,ITA,Antonio Jun Lavanga (Legavolley 2017) +Lavia,Daniele,ITA,Daniele Lavia (Legavolley 2017) +Lazzaretto,Enrico,ITA,Enrico Lazzaretto (Legavolley 2017) +Leone,Michele,ITA,Michele Leone (Legavolley 2017) +Leoni,Giacomo,ITA,Giacomo Leoni (Legavolley 2017) +Libraro,Enrico,ITA,Enrico Libraro (Legavolley 2017) +Lipinski,Bartlomiej,ITA,Bartlomiej Lipinski (Legavolley 2017) +Loglisci,Gianluca,ITA,Gianluca Loglisci (Legavolley 2017) +Longo,Giuseppe,ITA,Giuseppe Longo (Legavolley 2017) +Losco,Fabio,ITA,Fabio Losco (Legavolley 2017) +Lucarelli,Marco,ITA,Marco Lucarelli (Legavolley 2017) +Lugli,Leonardo,ITA,Leonardo Lugli (Legavolley 2017) +Luppi,Oreste,ITA,Oreste Luppi (Legavolley 2017) +Maccabruni,Filippo,ITA,Filippo Maccabruni (Legavolley 2017) +Maccarone,Graziano,ITA,Graziano Maccarone (Legavolley 2017) +Maffeis,Filippo,ITA,Filippo Maffeis (Legavolley 2017) +Maiorana,Domenico,ITA,Domenico Maiorana (Legavolley 2017) +Mancini,Andrea,ITA,Andrea Mancini (Legavolley 2017) +Manginelli,Mario,ITA,Mario Manginelli (Legavolley 2017) +Manià,Loris,ITA,Loris Manià (Legavolley 2017) +Marchiani,Manuele,ITA,Manuele Marchiani (Legavolley 2017) +Marchini,Stefano,ITA,Stefano Marchini (Legavolley 2017) +Marchisio,Andrea,ITA,Andrea Marchisio (Legavolley 2017) +Margutti,Pietro,ITA,Pietro Margutti (Legavolley 2017) +Mariano,Romolo,ITA,Romolo Mariano (Legavolley 2017) +Mariella,Giulio,ITA,Giulio Mariella (Legavolley 2017) +Marinelli,Michele,ITA,Michele Marinelli (Legavolley 2017) +Marra,Alberto,ITA,Alberto Marra (Legavolley 2017) +Marra,Emanuele Maria,ITA,Emanuele Maria Marra (Legavolley 2017) +Marra,Davide,ITA,Davide Marra (Legavolley 2017) +Marrazzo,Federico,ITA,Federico Marrazzo (Legavolley 2017) +Marretta,Federico,ITA,Federico Marretta (Legavolley 2017) +Marsili,Sebastiano,ITA,Sebastiano Marsili (Legavolley 2017) +Maruotti,Gabriele,ITA,Gabriele Maruotti (Legavolley 2017) +Massari,Jacopo,ITA,Jacopo Massari (Legavolley 2017) +Mattei,Andrea,ITA,Andrea Mattei (Legavolley 2017) +Mauti,Pierpaolo,ITA,Pierpaolo Mauti (Legavolley 2017) +Mazza,Federico,ITA,Federico Mazza (Legavolley 2017) +Mazzon,Riccardo,ITA,Riccardo Mazzon (Legavolley 2017) +Mazzone,Daniele,ITA,Daniele Mazzone (Legavolley 2017) +Mazzone,Tiziano,ITA,Tiziano Mazzone (Legavolley 2017) +Menardo,Michael,ITA,Michael Menardo (Legavolley 2017) +Mengozzi,Stefano,ITA,Stefano Mengozzi (Legavolley 2017) +Menicali,Michael,ITA,Michael Menicali (Legavolley 2017) +Mercorio,Mario,ITA,Mario Mercorio (Legavolley 2017) +Milan,Sebastiano,ITA,Sebastiano Milan (Legavolley 2017) +Minnoni,Mattia ,ITA,Mattia Minnoni (Legavolley 2017) +Miscione,Mirko,ITA,Mirko Miscione (Legavolley 2017) +Monguzzi,Dario,ITA,Dario Monguzzi (Legavolley 2017) +Monopoli,Natale,ITA,Natale Monopoli (Legavolley 2017) +Montò,Davide,ITA,Davide Montò (Legavolley 2017) +Morelli,Michele,ITA,Michele Morelli (Legavolley 2017) +Morgese,Davide,ITA,Davide Morgese (Legavolley 2017) +Mosca,Leandro,ITA,Leandro Mosca (Legavolley 2017) +Motzo,Matheus,ITA,Matheus Motzo (Legavolley 2017) +Musardo,Donato,ITA,Donato Musardo (Legavolley 2017) +Nannini,Filippo,ITA,Filippo Nannini (Legavolley 2017) +Nelli,Gabriele,ITA,Gabriele Nelli (Legavolley 2017) +Olivati,Andrea,ITA,Andrea Olivati (Legavolley 2017) +Onwuelo,Samuel,ITA,Samuel Onwuelo (Legavolley 2017) +Orduna,Santiago,ITA,Santiago Orduna (Legavolley 2017) +Ottaviani,Giuseppe,ITA,Giuseppe Ottaviani (Legavolley 2017) +Pace,Domenico,ITA,Domenico Pace (Legavolley 2017) +Padura Diaz,Williams,ITA,Williams Padura Diaz (Legavolley 2017) +Panciocco,Marco Rocco,ITA,Marco Rocco Panciocco (Legavolley 2017) +Paoletti,Matteo,ITA,Matteo Paoletti (Legavolley 2017) +Paoli,Alessandro,ITA,Alessandro Paoli (Legavolley 2017) +Paolucci,Adriano,ITA,Adriano Paolucci (Legavolley 2017) +Paris,Matteo,ITA,Matteo Paris (Legavolley 2017) +Parodi,Simone,ITA,Simone Parodi (Legavolley 2017) +Partenio,Pier Paolo,ITA,Pier Paolo Partenio (Legavolley 2017) +Parusso,Michele,ITA,Michele Parusso (Legavolley 2017) +Patriarca,Stefano,ITA,Stefano Patriarca (Legavolley 2017) +Pedron,Matteo,ITA,Matteo Pedron (Legavolley 2017) +Peluso,Christian,ITA,Christian Peluso (Legavolley 2017) +Percoco,Giacomo,ITA,Giacomo Percoco (Legavolley 2017) +Pesare,Giancarlo,ITA,Giancarlo Pesare (Legavolley 2017) +Pesaresi,Nicola,ITA,Nicola Pesaresi (Legavolley 2017) +Peslac,Milan,ITA,Milan Peslac (Legavolley 2017) +Piano,Matteo,ITA,Matteo Piano (Legavolley 2017) +Piazza,Lorenzo,ITA,Lorenzo Piazza (Legavolley 2017) +Piccinelli,Alessandro,ITA,Alessandro Piccinelli (Legavolley 2017) +Picco,Edoardo,ITA,Edoardo Picco (Legavolley 2017) +Piedepalumbo,Pierpaolo,ITA,Pierpaolo Piedepalumbo (Legavolley 2017) +Pierotti,Marco,ITA,Marco Pierotti (Legavolley 2017) +Pilotto,Enrico,ITA,Enrico Pilotto (Legavolley 2017) +Pinali,Giulio,ITA,Giulio Pinali (Legavolley 2017) +Pinelli,Riccardo,ITA,Riccardo Pinelli (Legavolley 2017) +Piscopo,Cosimo Marco,ITA,Cosimo Marco Piscopo (Legavolley 2017) +Pison,Francesco,ITA,Francesco Pison (Legavolley 2017) +Pistolesi,Matteo,ITA,Matteo Pistolesi (Legavolley 2017) +Pizzichini,Matteo,ITA,Matteo Pizzichini (Legavolley 2017) +Pochini,Filippo,ITA,Filippo Pochini (Legavolley 2017) +Polo,Alberto,ITA,Alberto Polo (Legavolley 2017) +Porcelli,Alessandro,ITA,Alessandro Porcelli (Legavolley 2017) +Prandi,Massimiliano,ITA,Massimiliano Prandi (Legavolley 2017) +Presta,Luca,ITA,Luca Presta (Legavolley 2017) +Preti,Alessandro,ITA,Alessandro Preti (Legavolley 2017) +Pricoco,Francesco,ITA,Francesco Pricoco (Legavolley 2017) +Primavera,Alessandro,ITA,Alessandro Primavera (Legavolley 2017) +Provvisiero,Giovanni,ITA,Giovanni Provvisiero (Legavolley 2017) +Quarta,Augusto,ITA,Augusto Quarta (Legavolley 2017) +Quartarone,Davide,ITA,Davide Quartarone (Legavolley 2017) +Raffaele,Michele,ITA,Michele Raffaele (Legavolley 2017) +Raffaelli,Giacomo,ITA,Giacomo Raffaelli (Legavolley 2017) +Ragoni,Alessio,ITA,Alessio Ragoni (Legavolley 2017) +Randazzo,Luigi,ITA,Luigi Randazzo (Legavolley 2017) +Razzetto,Leonardo,ITA,Leonardo Razzetto (Legavolley 2017) +Recine,Francesco,ITA,Francesco Recine (Legavolley 2017) +Ribezzo,Dario,ITA,Dario Ribezzo (Legavolley 2017) +Ricci,Fabio,ITA,Fabio Ricci (Legavolley 2017) +Riva,Matteo,ITA,Matteo Riva (Legavolley 2017) +Rizzo,Marco,ITA,Marco Rizzo (Legavolley 2017) +Robbiati,Gabriele,ITA,Gabriele Robbiati (Legavolley 2017) +Romagnoli,Giulio,ITA,Giulio Romagnoli (Legavolley 2017) +Romanò,Yuri,ITA,Yuri Romanò (Legavolley 2017) +Romiti,Roberto,ITA,Roberto Romiti (Legavolley 2017) +Rondoni,Andrea,ITA,Andrea Rondoni (Legavolley 2017) +Rossatti,Federico,ITA,Federico Rossatti (Legavolley 2017) +Rossi,Andrea,ITA,Andrea Rossi (Legavolley 2017) +Rossini,Salvatore,ITA,Salvatore Rossini (Legavolley 2017) +Rosso,Mattia,ITA,Mattia Rosso (Legavolley 2017) +Russo,Davide Luigi,ITA,Davide Luigi Russo (Legavolley 2017) +Russo,Erminio,ITA,Erminio Russo (Legavolley 2017) +Russo,Roberto,ITA,Roberto Russo (Legavolley 2017) +Sabbi,Giulio,ITA,Giulio Sabbi (Legavolley 2017) +Sacripanti,Mauro,ITA,Mauro Sacripanti (Legavolley 2017) +Saibene,Alberto,ITA,Alberto Saibene (Legavolley 2017) +Salgado,Hiosvany,ITA,Hiosvany Salgado (Legavolley 2017) +Salsi,Nicola,ITA,Nicola Salsi (Legavolley 2017) +Santangelo,Andrea,ITA,Andrea Santangelo (Legavolley 2017) +Santucci,Marco,ITA,Marco Santucci (Legavolley 2017) +Sartori,Luca,ITA,Luca Sartori (Legavolley 2017) +Saturnino,Alessandro,ITA,Alessandro Saturnino (Legavolley 2017) +Savani,Cristian,ITA,Cristian Savani (Legavolley 2017) +Sbertoli,Riccardo,ITA,Riccardo Sbertoli (Legavolley 2017) +Scopelliti,Simone,ITA,Simone Scopelliti (Legavolley 2017) +Segoni,Matteo,ITA,Matteo Segoni (Legavolley 2017) +Sesto,Nicola,ITA,Nicola Sesto (Legavolley 2017) +Sette,Felice,ITA,Felice Sette (Legavolley 2017) +Seveglievich,Nicolò,ITA,Nicolò Seveglievich (Legavolley 2017) +Sideri,Francesco,ITA,Francesco Sideri (Legavolley 2017) +Silva,Giulio,ITA,Giulio Silva (Legavolley 2017) +Simoni,Michele,ITA,Michele Simoni (Legavolley 2017) +Sitti,Alessio,ITA,Alessio Sitti (Legavolley 2017) +Smiriglia,Antonio,ITA,Antonio Smiriglia (Legavolley 2017) +Sordella,Luigi,ITA,Luigi Sordella (Legavolley 2017) +Sorgente,Alessandro,ITA,Alessandro Sorgente (Legavolley 2017) +Sorlini,Emanuele,ITA,Emanuele Sorlini (Legavolley 2017) +Sottile,Daniele,ITA,Daniele Sottile (Legavolley 2017) +Spadavecchia,Vincenzo,ITA,Vincenzo Spadavecchia (Legavolley 2017) +Spagnuolo,Luca,ITA,Luca Spagnuolo (Legavolley 2017) +Spampinato,Emanuele,ITA,Emanuele Spampinato (Legavolley 2017) +Sperandio,Matteo,ITA,Matteo Sperandio (Legavolley 2017) +Sperotto,Lorenzo,ITA,Lorenzo Sperotto (Legavolley 2017) +Spirito,Luca,ITA,Luca Spirito (Legavolley 2017) +Statuto,Enrico,ITA,Enrico Statuto (Legavolley 2017) +Stefani,Tommaso,ITA,Tommaso Stefani (Legavolley 2017) +Suraci,Antonino,ITA,Antonino Suraci (Legavolley 2017) +Taliani,Filippo,ITA,Filippo Taliani (Legavolley 2017) +Tamburo,Vincenzo,ITA,Vincenzo Tamburo (Legavolley 2017) +Tartaglione,Simmaco,ITA,Simmaco Tartaglione (Legavolley 2017) +Tasholli,Fatijon,ITA,Fatijon Tasholli (Legavolley 2017) +Terpin,Jernej,ITA,Jernej Terpin (Legavolley 2017) +Thei,Sebastiano,ITA,Sebastiano Thei (Legavolley 2017) +Tiberti,Simone,ITA,Simone Tiberti (Legavolley 2017) +Tiozzo,Nicola,ITA,Nicola Tiozzo (Legavolley 2017) +Tomassetti,Daniele,ITA,Daniele Tomassetti (Legavolley 2017) +Tondo,Alessandro,ITA,Alessandro Tondo (Legavolley 2017) +Torchia,Ernesto,ITA,Ernesto Torchia (Legavolley 2017) +Torre,Andrea,ITA,Andrea Torre (Legavolley 2017) +Torsello,Mirko,ITA,Mirko Torsello (Legavolley 2017) +Toscani,Alessandro,ITA,Alessandro Toscani (Legavolley 2017) +Tosi,Federico,ITA,Federico Tosi (Legavolley 2017) +Travica,Dragan,ITA,Dragan Travica (Legavolley 2017) +Tulone,Calogero,ITA,Calogero Tulone (Legavolley 2017) +Turla,Alessandro,ITA,Alessandro Turla (Legavolley 2017) +Usai,Valeriano,ITA,Valeriano Usai (Legavolley 2017) +Vacchiano,Marco,ITA,Marco Vacchiano (Legavolley 2017) +Valenti,Simone,ITA,Simone Valenti (Legavolley 2017) +Valsecchi,Damiano,ITA,Damiano Valsecchi (Legavolley 2017) +Vecchi,Riccardo,ITA,Riccardo Vecchi (Legavolley 2017) +Vedovotto,Filippo,ITA,Filippo Vedovotto (Legavolley 2017) +Vettori,Luca,ITA,Luca Vettori (Legavolley 2017) +Villotti,Diego,ITA,Diego Villotti (Legavolley 2017) +Vitelli,Marco,ITA,Marco Vitelli (Legavolley 2017) +Volpato,Marco,ITA,Marco Volpato (Legavolley 2017) +Zaccari,Leon,ITA,Leon Zaccari (Legavolley 2017) +Zamagni,Matteo,ITA,Matteo Zamagni (Legavolley 2017) +Zanardini,Massimo,ITA,Massimo Zanardini (Legavolley 2017) +Zanini,Matteo,ITA,Matteo Zanini (Legavolley 2017) +Zanni,Michael,ITA,Michael Zanni (Legavolley 2017) +Zauli,Marco,ITA,Marco Zauli (Legavolley 2017) +Zaytsev,Ivan,ITA,Ivan Zaytsev (Legavolley 2017) +Zonca,Paolo,ITA,Paolo Zonca (Legavolley 2017) +Zoppellari,Francesco,ITA,Francesco Zoppellari (Legavolley 2017) +Ishikawa,Yuki,JPN,Yuki Ishikawa (Legavolley 2017) +Peda,Janis,LAT,Janis Peda (Legavolley 2017) +Culafic,Milos,MNE,Milos Culafic (Legavolley 2017) +Abdel-Aziz,Nimir,NED,Nimir Abdel-Aziz (Legavolley 2017) +Boswinkel,Hidde,NED,Hidde Boswinkel (Legavolley 2017) +Hoogendoorn,Sjoerd,NED,Sjoerd Hoogendoorn (Legavolley 2017) +Snippe,Jan Willem,NED,Jan Willem Snippe (Legavolley 2017) +Van Garderen,Maarten,NED,Maarten Van Garderen (Legavolley 2017) +Domagala,Damian,POL,Damian Domagala (Legavolley 2017) +Hebda,Milosz,POL,Milosz Hebda (Legavolley 2017) +Iglesias,Arturo,PUR,Arturo Iglesias (Legavolley 2017) +Cebulj,Klemen,SLO,Klemen Cebulj (Legavolley 2017) +Kozamernik,Jan,SLO,Jan Kozamernik (Legavolley 2017) +Pajenk,Alen,SLO,Alen Pajenk (Legavolley 2017) +Stern,Toncek,SLO,Toncek Stern (Legavolley 2017) +Urnaut,Tine,SLO,Tine Urnaut (Legavolley 2017) +Atanasijevic,Aleksandar,SRB,Aleksandar Atanasijevic (Legavolley 2017) +Cirovic,Lazar,SRB,Lazar Cirovic (Legavolley 2017) +Jovanovic,Igor,SRB,Igor Jovanovic (Legavolley 2017) +Kovacevic,Uros,SRB,Uros Kovacevic (Legavolley 2017) +Petkovic,Dusan,SRB,Dusan Petkovic (Legavolley 2017) +Podrascanin,Marko,SRB,Marko Podrascanin (Legavolley 2017) +Premovic,Petar,SRB,Petar Premovic (Legavolley 2017) +Stankovic,Dragan,SRB,Dragan Stankovic (Legavolley 2017) +Starovic,Sasha,SRB,Sasha Starovic (Legavolley 2017) +Bencz,Milan,SVK,Milan Bencz (Legavolley 2017) +Nemec,Martin,SVK,Martin Nemec (Legavolley 2017) +Link,Jacob,SWE,Jacob Link (Legavolley 2017) +Shavrak,Dmitriy,UKR,Dmitriy Shavrak (Legavolley 2017) +Averill,Taylor,USA,Taylor Averill (Legavolley 2017) +Christenson,Micah,USA,Micah Christenson (Legavolley 2017) +Fey,Kupono,USA,Kupono Fey (Legavolley 2017) +Franciskovic,Jennings,USA,Jennings Franciskovic (Legavolley 2017) +Holt,Maxwell Philip,USA,Maxwell Philip Holt (Legavolley 2017) +Jaeschke,Thomas,USA,Thomas Jaeschke (Legavolley 2017) +Kaminski,Conrad,USA,Conrad Kaminski (Legavolley 2017) +Langlois,Jake,USA,Jake Langlois (Legavolley 2017) +Mochalski,Eric,USA,Eric Mochalski (Legavolley 2017) +Patch,Benjamin,USA,Benjamin Patch (Legavolley 2017) +Penning,Mitchell,USA,Mitchell Penning (Legavolley 2017) +Russell,Aaron,USA,Aaron Russell (Legavolley 2017) +Sander,Taylor,USA,Taylor Sander (Legavolley 2017) +Shaw,James,USA,James Shaw (Legavolley 2017) +Shoji,Kawika,USA,Kawika Shoji (Legavolley 2017) +Shoji,Erik Thomas,USA,Erik Thomas Shoji (Legavolley 2017) +Vega,Gabriel Michael,USA,Gabriel Michael Vega (Legavolley 2017) +Walsh,Brett James,USA,Brett James Walsh (Legavolley 2017) +Yoder,Lucas,USA,Lucas Yoder (Legavolley 2017) +Zanettin,Ivan,VEN,Ivan Zanettin (Legavolley 2017) diff --git a/2017-11-wikidata-volleyball-players/volleyball-players.php b/2017-11-wikidata-volleyball-players/volleyball-players.php new file mode 100755 index 0000000..76ae56d --- /dev/null +++ b/2017-11-wikidata-volleyball-players/volleyball-players.php @@ -0,0 +1,1097 @@ +fetch( [ + 'action' => 'query', + 'meta' => 'tokens', + 'type' => 'login' +] ); +if( ! isset( $response->query->tokens->logintoken ) ) { + throw new Exception("can't retrieve login token"); +} +$logintoken = $response->query->tokens->logintoken; + +################ +# Wikidata login +################ + +$response = $wikidata_api->post( [ + 'action' => 'login', + 'lgname' => WIKI_USERNAME, + 'lgpassword' => WIKI_PASSWORD, + 'lgtoken' => $logintoken +] ); +if( ! isset( $response->login->result ) || $response->login->result !== 'Success' ) { + throw new Exception("login failed"); +} + +############################## +# Wikidata CSRF token (logged) +############################## + +$response = $wikidata_api->fetch( [ + 'action' => 'query', + 'meta' => 'tokens', + 'type' => 'csrf' +] ); +if( ! isset( $response->query->tokens->csrftoken ) ) { + throw new Exception("missing csrf"); +} +$WIKIDATA_CSRF_TOKEN = $response->query->tokens->csrftoken; + +$SCRIPT = 'python ~/pywikibot/pwb.py'; + +############# +# Nations CSV +############# + +$NATIONS = []; +if( ($handle = fopen('commons-volleyball-nationalities.csv', 'r') ) !== false ) { + while( ($data = fgetcsv($handle, 1000, ';') ) !== false ) { + + // :P This prevents warnings if $better_cat is missing; or don't care if $better_cat is present. + $data[] = null; + + list($code, $wikidata_id, $it_m, $it_f, $en, $cat, $better_cat ) = $data; + $NATIONS[ $code ] = new Nat($wikidata_id, $it_m, $en, $cat, $better_cat); + } + fclose($handle); +} + +$missing_natcodes = []; + +######################## +# Volleyball players CSV +######################## + +if( ( $handle = fopen('commons-volleyball-players.csv', 'r') ) !== false ) { + + $porcelain = false; + + $i = -1; + while( ( $data = fgetcsv($handle, 1000, ',')) !== false ) { + $i++; + + if( $i === 0 ) { + // Skip header + continue; + } + + list($surname, $name, $natcode, $file) = $data; + + if( ! isset( $NATIONS[ $natcode ] ) ) { + $missing_natcodes[] = $natcode; + $porcelain = true; + } + + if( $porcelain ) { + continue; + } + + $filepath = "$file.jpg"; + $filename = "File:$filepath"; + if( ! commons_page_exists( $filename ) ) { + echo "# Skipping [[$filename]] that does not exist\n"; + continue; + } + + $filename_url = commons_page_url( $filename ); + + $complete_name = "$name $surname"; + $personal_category = $complete_name; + $personal_category_prefixed = "Category:$personal_category"; + $personal_category_url = commons_page_url( $personal_category_prefixed ); + $personal_category_exists = commons_category_exists( $personal_category_prefixed ); + + if( $personal_category_exists ) { + if( ! commons_search_term_in_page_categories( $personal_category_prefixed, 'volleyball' ) ) { + if( ! INTERACTION ) { + interaction_warning(); + continue; + } + + echo "# Is he a volleyball player? [ENTER/n]\n"; + echo "# [[$personal_category_prefixed]]\n"; + echo "# " . commons_page_url( $personal_category_prefixed ) . "\n"; + $no = read(); + if( $no === 'n' || $no === 'N' ) { + $personal_category .= ' (volleyball player)'; + echo "Insert MANUALLY something as '$personal_category':"; + $personal_category = read( $personal_category ); + $personal_category_prefixed = "Category:$personal_category"; + echo "# Input: [[$personal_category_prefixed]]\n"; + echo "# " . commons_page_url( $personal_category_prefixed ) . "\n"; + $personal_category_exists = commons_category_exists( $personal_category_prefixed ); + + echo "# Confirm?"; + read(); + } + } + } + + $italian_category = "Men's volleyball players from Italy"; + $italian_category_prefixed = "Category:$italian_category"; + + $nation = $NATIONS[ $natcode ]; + $national_category = $nation->cat; + $national_category_prefixed = "Category:$national_category"; + + // Wikidata labels + $LABELS = [ + 'en' => sprintf( + '%s %s, %s volleyball player', + $name, + $surname, + $nation->en + ), + 'it' => sprintf( + '%s %s, pallavolista %s', + $name, + $surname, + $nation->it + ) + ]; + + $better_national_category_exists = isset( $nation->better_cat ); + if( $better_national_category_exists ) { + $better_national_category = $nation->better_cat; + $better_national_category_prefixed = "Category:$better_national_category"; + $personal_category_has_better_national_category = commons_page_has_categories( $personal_category_prefixed, [ $better_national_category_prefixed ] ); + } + + $file_has_personal_category = commons_page_has_categories( $filename, [ $personal_category_prefixed ] ); + $file_has_italian_category = commons_page_has_categories( $filename, [ $italian_category_prefixed ] ); + $file_has_iten_templates = commons_page_has_templates( $filename, [ 'Template:En', 'Template:It' ] ); + $file_has_template_depicted = commons_page_has_templates( $filename, [ 'Template:Depicted person' ] ); + $personal_category_has_national_category = commons_page_has_categories( $personal_category_prefixed, [ $national_category_prefixed ] ); + $personal_category_has_wikidata_template = commons_page_has_templates( $personal_category_prefixed, [ 'Template:Wikidata person' ] ); + + $personal_category_has_best_national_category = $better_national_category_exists + ? $personal_category_has_better_national_category + : $personal_category_has_national_category; + + $best_national_category = $better_national_category_exists + ? $better_national_category + : $national_category; + + $best_national_category_prefixed = "Category:$best_national_category"; + + echo "# $name $surname [[$filename_url]]\n"; + + $wikidata_item = get_wikidata_item( $filename, $complete_name ); + + if( SANDBOXED ) { + $wikidata_item = $WIKIDATA_SANDBOX; + } + + $wikidata_item_new_data = new WikidataDataModel(); + + $claims = []; + + if( $wikidata_item ) { + // Retrieve + // https://www.wikidata.org/w/api.php?action=help&modules=wbgetentities + $wikidata_item_data = $wikidata_api->fetch( [ + 'action' => 'wbgetentities', + 'ids' => $wikidata_item, + 'props' => 'info|sitelinks|aliases|labels|descriptions|claims|datatype' + ] ); + if( ! isset( $wikidata_item_data->entities->{ $wikidata_item } ) ) { + throw new Exception("$wikidata_item does not exist?"); + } + $wikidata_item_data = $wikidata_item_data->entities->{ $wikidata_item }; + + ## + # Append new labels + ## + $labels = []; + foreach( $LABELS as $lang => $label ) { + if( ! isset( $wikidata_item_data->labels->{ $lang } ) ) { + $labels[] = $LABELS[ $lang ]; + } + } + $wikidata_item_new_data->setLabels( $labels, 'add' ); + + // Image + if( ! isset( $wikidata_item_data->claims->{ 'P18' } ) ) { + $claims[] = legavolley_wikidata_claim_property_commonsmedia('P18', $filepath); + } + + // Commons category + if( ! isset( $wikidata_item_data->claims->{ 'P373' } ) ) { + $claims[] = legavolley_wikidata_claim_property_string('P373', $personal_category); + } + + // Sex: male + if( ! isset( $wikidata_item_data->claims->{ 'P21' } ) ) { + $claims[] = legavolley_wikidata_claim_property_entity('P21', 'Q6581097'); + } + + // Country of citizenship (P27) + if( ! isset( $wikidata_item_data->claims->{ 'P27' } ) ) { + $claims[] = legavolley_wikidata_claim_property_entity('P27', $nation->wd); + } + + // Occupation: volleyball player + if( ! isset( $wikidata_item_data->claims->{ 'P106' } ) ) { + $claims[] = legavolley_wikidata_claim_property_entity('P106', 'Q15117302'); + } + + $wikidata_item_new_data->set( [ + 'claims' => claims( $claims ) + ] ); + + echo json_encode( $wikidata_item_new_data->get(), JSON_PRETTY_PRINT ); + echo "Confirm"; + read(); + + // Save existing + // https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity + $wikidata_api->post( [ + 'action' => 'wbeditentity', + 'id' => $wikidata_item, + 'summary' => SUMMARY, + 'token' => $WIKIDATA_CSRF_TOKEN, + 'bot' => 1, + 'data' => $wikidata_item_new_data->getJSON() + ] ); + + exit; + } else { + exit; + + // All labels + $wikidata_item_new_data->setLabels( $LABELS ); + + // Image + $claims[] = legavolley_wikidata_claim_property_commonsmedia('P18', $filepath); + + // Commons category + $claims[] = legavolley_wikidata_claim_property_string('P373', $personal_category); + + // Sex: male + $claims[] = legavolley_wikidata_claim_property_entity('P21', 'Q6581097'); + + // Country of citizenship (P27) + $claims = legavolley_wikidata_claim_property_entity('P27', $nation->wd); + + // Occupation: volleyball player + $claims = legavolley_wikidata_claim_property_entity('P106', 'Q15117302'); + + $wikidata_item_new_data->set( [ + 'claims' => $claims + ] ); + + // Create + // https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity + $wikidata_api->post( [ + 'action' => 'wbeditentity', + 'new' => 'item', + 'summary' => SUMMARY, + 'token' => $WIKIDATA_CSRF_TOKEN, + 'bot' => 1, + 'data' => $wikidata_item_new_data->getJSON() + ] ); + } + + if( ! $file_has_template_depicted || ! $file_has_personal_category ) { + $summary = SUMMARY; + $pwb = clone $PWB; + $pwb->arg('replace.py') + ->arg('-regex') + ->arg('-lang:commons') + ->arg('-family:commons') + ->arg("-page:$filename"); + + $replace = false; + + if( $wikidata_item ) { + if( ! $file_has_template_depicted ) { + $pwb->arg('{{[ ]*[eE]n *\|.+?}}\n?'); + $pwb->arg(''); + $pwb->arg('{{[ ]*[iI]t *\|.+?}}'); + $pwb->arg( sprintf( + '{{Depicted person|%s}}', + $wikidata_item + ) ); + $summary .= "; +[[Template:Depicted person]] [[d:$wikidata_item]]"; + $replace = true; + } + } elseif( ! $file_has_iten_templates ) { + // {{It|asd}} + $pwb->arg( '{{[ ]*[iI]t *\|.+?}}' ); + $pwb->arg( sprintf( + '{{en|%s}}\n{{it|%s}}', + $LABELS['en'], + $LABELS['it'] + ) ); + + $summary .= "; +[[Template:En]] +[[Template:It]]"; + $replace = true; + } + + if( $file_has_italian_category ) { + if( $national_category !== $italian_category ) { + if( ! $file_has_personal_category ) { + $pwb->arg( Generic::space2regex( $italian_category_prefixed ) ); + $pwb->arg( $personal_category_prefixed ); + $summary .= "; [[$italian_category_prefixed]] → [[$personal_category_prefixed]]"; + + $file_has_italian_category = false; + $file_has_personal_category = true; + $replace = true; + } + } + if( $file_has_italian_category ) { + $pwb->arg( '\[\[ *' . Generic::space2regex( $italian_category_prefixed ) . ' *\]\]\n*' ); + $pwb->arg(''); + $summary .= "; -[[$italian_category_prefixed]]"; + $replace = true; + } + } + + if( ! $file_has_personal_category ) { + $pwb->arg('$'); + $pwb->arg('\n[[' . $personal_category_prefixed . ']]'); + $summary .= "; +[[$personal_category_prefixed]]"; + $replace = true; + } + + if( ALWAYS ) { + $pwb->arg('-always'); + } + + if( $replace ) { + echo $pwb->arg("-summary:$summary")->get(); + + if( INTERACTION ) { + read(); + } + } + } else { + echo "# Skipped..."; + } + + echo "\n\n"; + + if( $personal_category_exists ) { + echo "# [[Category:$personal_category]] [[$personal_category_url]]\n"; + + // Decides if skip + if( $personal_category_has_best_national_category ) { + if( $personal_category_has_wikidata_template ) { + echo "# It's perfect yet! Skip.\n"; + continue; + } elseif( ! $wikidata_item ) { + $wikidata_item = get_wikidata_item( $filename, $complete_name ); + if( ! INTERACTION && null === $wikidata_item ) { + interaction_warning(); + continue; + } + + if( ! $wikidata_item ) { + echo "# It misses the Wikidata template, but no Wikidata item. Skip.\n"; + continue; + } + } + } + + // Pywikibot replace.py + $pwb = clone $PWB; + $pwb->arg('replace.py') + ->arg('-regex') + ->arg('-lang:commons') + ->arg('-family:commons') + ->arg("-page:$personal_category_prefixed"); + + $summary = SUMMARY; + + if( ! $personal_category_has_wikidata_template ) { + $wikidata_item = get_wikidata_item( $filename, $complete_name ); + if( ! INTERACTION && null === $wikidata_item ) { + interaction_warning(); + continue; + } + + if( $wikidata_item ) { + $summary .= $wikidata_item ? sprintf("; +[[Template:Wikidata person]] [[d:%s]]", $wikidata_item) : ''; + + $pwb->arg('^(?!{{Wikidata person)'); + $pwb->arg( sprintf( + '{{Wikidata person|%s}}\n', + $wikidata_item + ) ); + } + } + + if( ! $personal_category_has_best_national_category ) { + + if( $better_national_category_exists ) { + if( $personal_category_has_national_category ) { + // National → Best national + $pwb->arg( Generic::space2regex( $national_category_prefixed ) ); + $pwb->arg( $better_national_category_prefixed ); + $summary .= "; better national category"; + } else { + // + Best national + $pwb->arg('$'); + $pwb->arg('\n[[' . $better_national_category_prefixed . ']]'); + $summary .= "; +[[$better_national_category_prefixed]]"; + } + } elseif( ! $personal_category_has_national_category ) { + // + National + $pwb->arg('$'); + $pwb->arg('\n[[' . $national_category_prefixed . ']]'); + $summary .= "; +[[$national_category_prefixed]]"; + } + } + + $pwb->arg("-summary:$summary"); + + if( ALWAYS ) { + $pwb->arg('-always'); + } + + echo $pwb->get(); + + if( INTERACTION ) { + read(); + } + + } else { + // Pywikibot create + + $summary = SUMMARY; + + $wikidata_item = get_wikidata_item( $filename, $complete_name ); + if( ! INTERACTION && null === $wikidata_item ) { + interaction_warning(); + continue; + } + + $temp = tmpfile(); + $temp_name = stream_get_meta_data( $temp ); + $temp_name = $temp_name['uri']; + + // https://www.mediawiki.org/wiki/Manual:Pywikibot/pagefromfile.py + $lines = []; + + $lines[] = '{{-start-}}'; + + $lines[] = "'''$personal_category_prefixed'''"; + + if( $wikidata_item ) { + $lines[] = sprintf( + '{{Wikidata person|%s}}', + $wikidata_item + ); + $summary .= "; +[[Template:Wikidata person]] [[d:$wikidata_item]]"; + } + + $lines[] = sprintf( + '{{DEFAULTSORT:%s, %s}}', + $surname, + $name + ); + + if( ! $wikidata_item ) { + $lines[] = "[[Category:Men by name]]"; + $lines[] = "[[Category:$name (given name)]]"; + $lines[] = "[[Category:$surname (surname)|$name $surname]]"; + $lines[] = "[[Category:Year of birth missing]]"; + $summary .= "; +categories"; + } + + $lines[] = "[[$best_national_category_prefixed]]"; + $summary .= "; +[[$best_national_category_prefixed]]"; + + $lines[] = '{{-stop-}}'; + + // Yes, I know, but don't fight about it + $tmp = '/tmp/asd'; + echo "cat > '$tmp' <arg('pagefromfile.py') + ->arg('-lang:commons') + ->arg('-family:commons') + ->arg('-notitle') + ->arg('-safe') + ->arg("-file:$tmp") + ->arg("-summary:$summary"); + + echo $pwb->get(); + + echo "\n"; + echo "rm '$tmp'\n"; + + if( INTERACTION ) { + read(); + } + } + } + + if( ! INTERACTION ) { + echo "sleep 5\n"; + } + + echo "\n\n\n\n"; +} + +if( $missing_natcodes ) { + echo "Missing natcodes: "; + echo implode("\n", array_unique( $missing_natcodes ) ); +} + +################# +# Commons queries +################# + +function commons_page_exists( $page_title ) { + if( VERBOSE ) { + echo "# Does [[$page_title]] exists?\n"; + } + $pages_exists = APIRequest::factory('https://commons.wikimedia.org/w/api.php', [ + 'action' => 'query', + 'titles' => $page_title, + 'prop' => 'info' + ] )->fetch(); + foreach( $pages_exists->query->pages as $page_id => $page ) { + if( $page_id > 0 ) { + return true; + } + } + return false; +} + +function commons_category_exists($category_name) { + if( VERBOSE ) { + echo "# Does [[$category_name]] exist?\n"; + } + $category_info = APIRequest::factory('https://commons.wikimedia.org/w/api.php', [ + 'action' => 'query', + 'prop' => 'categoryinfo', + 'titles' => $category_name + ] )->fetch(); + foreach( $category_info->query->pages as $page_id => $page ) { + if( $page_id > 0 ) { + return true; + } + } + return false; +} + +function commons_search_term_in_page_categories( $page_title, $search_term ) { + if( VERBOSE ) { + echo "# Cesarelombrosing [[$page_title]] looking for '$search_term'\n"; + } + $categories = APIRequest::factory('https://commons.wikimedia.org/w/api.php', [ + 'action' => 'query', + 'prop' => 'categories', + 'clshow' => '!hidden', + 'titles' => $page_title + ] )->fetch(); + foreach( $categories->query->pages as $page ) { + foreach( $page->categories as $category ) { + $title = strtolower( $category->title ); + if( false !== strpos( $title, $search_term ) ) { + if( VERBOSE ) { + echo "# Matches\n"; + } + return true; + } + } + } + if( VERBOSE ) { + echo "# Doesn't match\n"; + } + return false; +} + +function commons_page_has_categories( $page_title, $categories = [] ) { + if( VERBOSE ) { + echo "# Does [[$page_title]] have these categories? ([[{$categories[0]}]], ...)\n"; + } + $results = commons_page_props( $page_title, 'categories', [ + 'clcategories' => implode( '|', $categories ) + ] ); + $status = false; + foreach( $results as $result ) { + foreach( $result->query->pages as $page ) { + if( isset( $page->categories ) ) { + $status = count( $page->categories ) === count( $categories ); + break; + } + } + } + debug_yes_no( $status ); + return $status; +} + +function commons_page_has_templates( $page_title, $templates = [] ) { + if( VERBOSE ) { + echo "# Does [[$page_title]] have these templates? ([[{$templates[0]}]], ...)\n"; + } + $results = commons_page_props( $page_title, 'templates', [ + 'tlnamespace' => 10, + 'tltemplates' => implode( '|', $templates ) + ] ); + $status = false; + foreach( $results as $result ) { + foreach( $result->query->pages as $page ) { + if( isset( $page->templates ) ) { + $status = count( $page->templates ) === count( $templates ); + break; + } + } + } + debug_yes_no( $status ); + return $status; +} + +function commons_page_props( $page, $prop, $args = [] ) { + $args = array_merge( [ + 'action' => 'query', + 'prop' => $prop, + 'titles' => $page + ], $args ); + + $api = APIRequest::factory( 'https://commons.wikimedia.org/w/api.php', $args ); + $pages = []; + while( $api->hasNext() ) { + // TODO: callback to obtain the right object? + $pages[] = $api->getNext(); + } + return $pages; +} + +################## +# Wikidata queries +################## + +function search_disperately_wikidata_item( $title ) { + echo "# Searching Wikidata item as '$title'\n"; + $wbsearch = APIRequest::factory( 'https://www.wikidata.org/w/api.php', [ + 'action' => 'query', + 'list' => 'wbsearch', + 'wbssearch' => $title, + 'wbslanguage' => 'en' + ] )->fetch(); + $titles = []; + foreach( $wbsearch->query->wbsearch as $wbsearch ) { + $titles[] = $wbsearch->title; + } + + $titles = filter_volleyball_wikidata_IDs( $titles ); + + return ask_which( $titles, "Pick Wikidata Item for '$title' volleyball player:", function( $title ) { + return "https://www.wikidata.org/wiki/{$title}"; + } ); +} + +/** + * Giving a list of volleyball player Wikidata IDs, returns which of them has a "volleyball label". + */ +function filter_volleyball_wikidata_IDs( $wikidata_IDs ) { + if( ! $wikidata_IDs ) { + return []; + } + + if( VERBOSE ) { + echo "# Cesarelombrosing following volleyball players:\n"; + foreach( $wikidata_IDs as $wikidata_ID ) { + echo "# \t https://www.wikidata.org/wiki/$wikidata_ID \n"; + } + } + + $SEARCH_TERMS = [ + 'de' => 'volleyball', + 'en' => 'volleyball', + 'it' => 'pallavol' // pallavolo | pallavolista + ]; + + $languages = array_keys( $SEARCH_TERMS ); + + // https://www.wikidata.org/w/api.php?action=wbgetentities&props=descriptions&ids=Q19675&languages=en|it + $entities = APIRequest::factory( 'https://www.wikidata.org/w/api.php', [ + 'action' => 'wbgetentities', + 'props' => 'descriptions', + 'ids' => implode( '|', $wikidata_IDs ), + 'languages' => implode( '|', $languages ) + ] ); + $matching_wikidata_IDs = []; + while( $entities->hasNext() ) { + $entity = $entities->getNext(); + foreach( $entity->entities as $entity_ID => $entity ) { + foreach( $wikidata_IDs as $wikidata_ID ) { + if( $wikidata_ID === $entity_ID ) { + foreach( $SEARCH_TERMS as $language => $term ) { + if( isset( $entity->descriptions->{ $language } ) ) { + $label = $entity->descriptions->{ $language }; + if( false !== strpos( $label->value, $term ) ) { + if( VERBOSE ) { + echo "# Wikidata $language label match\n"; + } + $matching_wikidata_IDs[ $wikidata_ID ] = true; + break; + } + } + } + } + } + } + } + $matching_wikidata_IDs = array_keys( $matching_wikidata_IDs ); + if( VERBOSE ) { + echo "# Matching:\n"; + foreach($matching_wikidata_IDs as $matching_wikidata_ID) { + echo "# https://www.wikidata.org/wiki/$wikidata_ID \n"; + } + if( ! $matching_wikidata_IDs ) { + echo "# None :(\n"; + } + } + return $matching_wikidata_IDs; +} + +function fetch_wikidata_item( $page_name ) { + // https://commons.wikimedia.org/w/api.php?action=query&prop=wbentityusage&titles=Category:Alberto+Casadei + $wbentityusage = APIRequest::factory( 'https://commons.wikimedia.org/w/api.php', [ + 'action' => 'query', + 'prop' => 'wbentityusage', + 'titles' => $page_name + ] )->fetch(); + + // Page not found + if( isset( $wbentityusage->query->pages->{-1} ) ) { + return false; + } + + foreach( $wbentityusage->query->pages as $page_id => $page ) { + if( isset( $page->wbentityusage ) ) { + foreach( $page->wbentityusage as $wikidata_id => $aspects ) { + // Just the first is enough + return $wikidata_id; + } + } + } + + // Wikidata element not found + return null; +} + +function get_wikidata_item( $page_name, $title ) { + static $latest; + static $latest_title; + if( $latest_title === $title ) { + return $latest; + } + $latest_title = $title; + $latest = fetch_wikidata_item( $page_name ); + if( ! $latest ) { + $latest = search_disperately_wikidata_item( $title ); + } + return $latest; +} + +############################## +# Legavolley referenced claims +############################## + +function legavolley_wikidata_claim_property_snak( $property, $snak ) { + return wikidata_claim_property_snak( $property, $snak, legavolley_references() ); +} + +function legavolley_wikidata_claim_property_entity( $property, $entity ) { + return wikidata_claim_property_entity( $property, $entity, legavolley_references() ); +} + +function legavolley_wikidata_claim_property_string( $property, $string ) { + return wikidata_claim_property_string( $property, $value, legavolley_references() ); +} + +function legavolley_wikidata_claim_property_commonsmedia( $property, $filename ) { + return wikidata_claim_property_commonsmedia( $property, $filename, legavolley_references() ); +} + +function legavolley_references() { + return [ [ 'snaks' => snaks( [ + // stated in: Lega Pallavolo Serie A + snak_item( 'P248', 'Q16571730' ) + ] ) ] ]; +} + +################################### +# Claims (they are formed by snaks) +################################### + +function wikidata_claim_property_snak( $property, $snak, $references = [] ) { + $claim = [ + 'mainsnak' => $snak, + 'type' => 'statement', + 'rank' => 'normal' + ]; + if( $references ) { + $claim['references'] = $references; + } + return $claim; +} + +function wikidata_claim_property_entity( $property, $entity, $references = [] ) { + return wikidata_claim_property_snak( + $property, + snak_item( $property, $entity ), + $references + ); +} + +function wikidata_claim_property_commonsmedia( $property, $filename, $references = [] ) { + return wikidata_claim_property_snak( + $property, + snak_commonmedia( $property, $filename ), + $references + ); +} + +############################### +# Snaks (they have a datavalue) +############################### + +function snak( $snaktype, $property, $datatype, $datavalue ) { + return [ + 'snaktype' => $snaktype, + 'property' => $property, + 'datatype' => $datatype, + 'datavalue' => $datavalue + ]; +} + +function snak_commonmedia( $property, $filename ) { + return snak( + 'value', + $property, + 'commonsMedia', + datavalue_string( $filename ) + ); +} + +function snak_item( $property, $item ) { + return snak( + 'value', + $property, + 'wikibase-item', + datavalue_item( $item ) + ); +} + +############################### +# Datavalues (snak's datavalue) +############################### + +function datavalue( $type, $value ) { + return [ + 'type' => $type, + 'value' => $value + ]; +} + +function datavalue_string( $value ) { + return datavalue( 'string', $value ); +} + +function datavalue_item( $entity ) { + $entity_numeric = (int) substr( $entity, 1 ); + return datavalue( 'wikibase-entityid', [ + 'entity-type' => 'item', + 'numeric-id' => $entity_numeric, + 'id' => $entity + ] ); +} + +##################################################################### +# Property aggregators (snaks and claims must be property-associated) +##################################################################### + +function snaks( $snaks ) { + $properties = []; + foreach( $snaks as $snak ) { + $property = $snak['property']; + if( ! isset( $properties[ $property ] ) ) { + $properties[ $property ] = []; + } + $properties[ $property ][] = $snak; + } + return $properties; +} + +function claims( $claims = [] ) { + $properties = []; + foreach( $claims as $claim ) { + $property = $claim['mainsnak']['property']; + if( ! isset( $properties[ $property ] ) ) { + $properties[ $property ] = []; + } + $properties[ $property ][] = $claim; + } + return $properties; +} + +########### +# CSV stuff +########### + +class Nat { + var $wd; + var $it; + var $en; + var $cat; + var $better_cat; + + function __construct( $wikidata_id, $it, $en, $cat, $better_cat ) { + $this->wd = $wikidata_id; + $this->it = $it; + $this->en = $en; + $this->cat = $cat; + $this->better_cat = $better_cat; + } +} + +############ +# Mixed shit +############ + +function read( $default = '' ) { + $v = chop( fgets(STDIN) ); + return $v ? $v : $default; +} + +function interaction_warning() { + echo "# Skipping: it requires interaction\n"; +} + +function commons_page_url($page) { + return 'https://commons.wikimedia.org/wiki/' . urlencode( str_replace(' ', '_', $page) ); +} + +function debug_yes_no($v) { + if( VERBOSE ) { + $yesno = $v ? "yes" : "no"; + echo "# $yesno\n"; + } +} + +function ask_which($answers, $question, $callback = null) { + if( ! $answers ) { + return false; + } + + if( 1 === count( $answers ) ) { + return array_pop( $answers ); + } + + echo "# $question\n"; + $answers = array_values( $answers ); + foreach( $answers as $i => $question ) { + if( $callback !== null ) { + $question = $callback( $question ); + } + printf("# \t[%s]: %s\n", $i + 1, $question); + } + + if( ! INTERACTION ) { + echo "# More than one result\n"; + return null; + } + + printf("\t[ENTER]: none\n"); + + $in = (int) read(); + + return $in <= 0 ? false : $answers[ $in - 1 ]; +} diff --git a/config-example.php b/config-example.php new file mode 100644 index 0000000..ef6ef0a --- /dev/null +++ b/config-example.php @@ -0,0 +1,5 @@ +