Hoppa till innehållet

Wikipedia:Projekt DotNetWikiBot Framework/Lavallen/Uppladdning

Från Wikipedia
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Xml;
using System.Threading;
using DotNetWikiBot;

class MyBot : Bot
{
	public static void Main()
	{

		Site site = new Site("http://commons.wikimedia.org", "Lavallen", "********");
		

		{
			string mapp = Directory.GetCurrentDirectory() + "\\Files";
			foreach(string fil in Directory.GetFiles(mapp, "*.png"))
			{
				string titel = Path.GetFileName(fil);
							
				string index = titel.Substring(titel.IndexOf(".png")-3,3);
				
				string description = "{{BookNaviBar|Myrberg GT |png|{{subst:padleft:{{subst:#expr:"+index+"-1}}|3}}|{{subst:padleft:{{subst:#expr:"+index+"+1}}|3}}}}\r\n{{Book\r\n| Author         = various \r\n| Translator     = [[:sv:Otto Myrberg|O. F. Myrberg]] (1824-99)\r\n| Title          = Gamla Testamentet\r\n| Subtitle       = Hjobs bok, Psaltaren, Ordspråksboken, Predikareboken och Höga visan\r\n| Publisher      = P. A. Norstedt & Söner\r\n| Printer        = Kungliga boktryckeriet.\r\n| Date           = 1895\r\n| City           = Stockholm\r\n| Language       = sv\r\n| Description    = {{sv|Bok: Gamla Testamentet öfversatt av O. F. Myrberg}}{{en|Book: Old Testament translated by O. F. Myrberg}}\r\n| Source         = own scan\r\n| Permission     = {{PD-old}}\r\n| Wikisource     = s:sv:Bibeln (Myrberg)\r\n| Homecat        = Gamla Testamentet (Myrberg)\r\n| other_versions = \r\n}}\r\n\r\n[[Category:Gamla Testamentet (Myrberg)|#"+index+"]]";
				Console.WriteLine(titel);
				Page myPage = new Page(site, site.namespaces["6"] + ":" + titel);
				string[] arr = {myPage.title};
				PageList pl = new PageList(site, arr);
				myPage.Load();
				if(myPage.Exists())
				{
					/*
					
					/**/
				}
				else
				{
					myPage.UploadImage(fil, description , "", "", "");
					File.Move(fil, Directory.GetCurrentDirectory() + "\\Files\\Klar\\" + Path.GetFileName(fil));
					pl.Watch();
				}
				
				
				
				Thread.Sleep(60000);
			}
		}
	}
}