Jump to content

User:Ramaksoud2000Bot/ShadowsCommons source

From Wikipedia, the free encyclopedia

This relies on this file by MER-C, and only includes the code for this task.

Wiki wiki;
wiki = new Wiki("en.wikipedia.org"); // create a new wiki connection to en.wikipedia.org
try{
    BufferedReader fileIn = new BufferedReader(new FileReader("quarry.csv")); 
    String line = fileIn.readLine();
    line=fileIn.readLine();
    while (line!=null)
    {
        enwikifiles.add("File:" + line); //build ArrayList of enwiki titles
        line=fileIn.readLine();
    }
    System.out.println(enwikifiles.toString()); //print array
}
catch (IOException ex)
{
    System.out.println(ex);
}
try
{
    wiki.setAssertionMode(1);
    for (String page : enwikifiles)
    {
       String wikiText=wiki.getPageText(page);
       if (wikiText==null)
       {
            //do nothing
       }
       else if (allowBots(wikiText, "Ramaksoud2000Bot")==false) //exclusion compliance
       {
            //do nothing
       }
       else
       {
            wiki.prepend(page, "{{ShadowsCommons}}", "Different file with the same name exists on Commons. Adding {{ShadowsCommons}}.", false, true);
       }
      }
}
      
 catch (LoginException ex)
{
    System.out.println(ex);
}  
catch (IOException ex)
{
    System.out.println(ex);
}