#Resolution 1440p 125%
#Firefox 100 % Côté gauche
#Explorateur ouvert sur dossier de destination, colonnes bien rangées à gauche, dossiers triés par dernière date de création
#Barre des tâches : firefox et explorateur à gauche, petites icônes toujours afficher tout
#IDM dossier de dl : dossier>nouveau dossier
#ShareX installé et lancé
#Clavier+ lancé et installé



def defilement(items, debut, decompte, page):
	global items, debut, decompte, page
	wait(1)
	if exists("1709898310179.png"):
		if debut == 1:
			wait(1)
		else:
			type(Key.UP)
			type(Key.UP)
			wait(1)
	else:
		if debut == 1:
			type(Key.UP)
			type(Key.UP)
			wait(1)
	if items == 1:
		wait(1)
	wait(0.5)
	region = Region(383,85,188,191)
	while not region.exists(Pattern("1709850708429.png").targetOffset(61,-1)):
		type(Key.UP)
		wait(0.5)
		if exists("1709856016062.png"):
			reg = Region(328,252,630,23)
			prec = reg.find(Pattern("1709856203064.png").exact())
			hover(prec)
			wait(1)
			mouseMove(-20, -5)
			wait(1)
			mouseDown(Button.LEFT)
			mouseUp(Button.LEFT)
			wait(5)
			type(Key.END)
			wait(3)
			page = page - 1
			wait(1)
			decompte = 0
			wait(1)
			items = 10
			wait(1)
			debut = 1

def download(items, debut):
	global items, debut
	wait(2)
	if exists("1709898310179.png"):
		if debut == 1:
			region = Region(134,194,635,544)
		else:
			region = Region(150,82,619,403)
	if not exists("1709898310179.png"):
		region = Region(150,82,619,403)
	if region.exists(Pattern("1709900719160.png").targetOffset(60,0)):
		set = region.getLastMatch()
		wait(1)
		hover(set)
		wait(1)
		mouseMove(33, 15)
		wait(0.5)
		mouseDown(Button.LEFT)
		mouseUp(Button.LEFT)
		mouseDown(Button.LEFT)
		mouseUp(Button.LEFT)
		mouseDown(Button.LEFT)
		mouseUp(Button.LEFT)
		wait(0.5)
		type("c", KEY_CTRL)
		wait(1)
	if region.exists(Pattern("1709899912402.png").exact()):
		download = region.find("1709899961539.png")
		if region.exists(Pattern("1709900399882.png").exact()):
			download = region.find(Pattern("1709900430657.png").similar(0.90))
	else:
		download = region.find("1709851754573.png")
		wait(0.5)
	hover(download)
	wait(1)
	mouseMove(70, 0)
	wait(0.5)
	type(Key.PRINTSCREEN)
	wait(0.5)
	mouseDown(Button.LEFT)
	mouseUp(Button.LEFT)
	wait(1)

def couv():
	region = Region(153,353,234,302)
	if region.exists("1709856601218.png"):
		couv = region.getLastMatch()
		wait(1)
		click(couv)
		wait(2)
		hover(Location(625, 673))
		wait(0.5)
		mouseDown(Button.RIGHT)
		mouseUp(Button.RIGHT)
		wait(1)
		click("1709856690569.png")
		wait(2)
		wait("1709853092694.png", 60)
		wait(0.5)
		region = Region(1476,629,78,166)
		region.wait("1709852119030.png", 60)
		wait(1)
		region = Region(1389,648,59,59)
		click(region.find("1709856773181.png"))
		wait(1)
		mouseMove(-50, 15)
		mouseDown(Button.LEFT)
		mouseUp(Button.LEFT)
		wait(2)
		click("1709852349665.png")
		wait(2)
		if exists("1709852395138.png"):
			click("1709852402526.png")
		wait(1)
		keyDown(Key.CTRL)
		wait(0.5)
		type("w")
		wait(0.5)
		keyUp(Key.CTRL)
		wait(1)
		print(debut)

def missing():
	wait(0.5)
	region = Region(0,1358,450,82)
	explorer = region.find("1709852440164.png")
	hover(explorer)
	wait(0.5)
	mouseDown(Button.LEFT)
	mouseUp(Button.LEFT)
	wait(0.5)
	click("1709852508524.png")
	wait(3)
	click("1709852948314.png")
	wait(3)
	type("v", KEY_CTRL)
	wait(3)
	type(Key.ENTER)
	wait(0.5)
	if exists("1709852252916.png"):
		click("1709852265180.png")
		wait(1)
		click("1709852508524.png")
		wait(3)
		click("1709852948314.png")
		type("v", KEY_CTRL)
		wait(3)
		import random
		num = random.randint(0,999999999999)
		type(str(num))
		wait(0.5)
		type(Key.ENTER)
		wait(2)
		type(Key.ENTER)
		wait(0.5)
		hover(Location(1247, 388))
		wait(0.5)
		mouseDown(Button.RIGHT)
		mouseUp(Button.RIGHT)
		wait(0.5)
		hover("1709855178860.png")
		wait(2)
		click("1709855209155.png")
		wait(0.5)
		type("Pas de video")
		wait(0.5)
		type(Key.ENTER)
		wait(0.5)
		type(Key.BACKSPACE)
		wait(0.5)
		
def idm(items):
	global items
	wait(2)
	wait("1709853092694.png", 60)
	wait(0.5)
	region = Region(1476,629,78,166)
	region.wait("1709852119030.png", 60)
	wait(1)
	if exists("1709852135104.png"):
		wait(0.5)
		click("1709852151631.png")
		wait("1709852168815.png", 10)
		click("1709852178497.png")
		wait(0.5)
		click("1709859443255.png")
		wait("1709853523343.png", 60)
		type("v", KEY_CTRL)
		wait(3)
		if exists(Pattern("1709852230866.png").similar(0.90)):
			while exists(Pattern("1709852230866.png").similar(0.90)):			
				click(Pattern("1709852230866.png").similar(0.90))
				wait(0.5)		
		if exists("1709852252916.png"):
			click(Pattern("1709893893792.png").similar(0.90))
			wait(2)
			type(Key.F2)
			wait(1)
			type("v", KEY_CTRL)
			wait(1)
			import random
			num = random.randint(0,999999999999)
			type(str(num))
			wait(0.5)
			if exists(Pattern("1709852230866.png").similar(0.90)):
				while exists(Pattern("1709852230866.png").similar(0.90)):
					click(Pattern("1709852230866.png").similar(0.90))
					wait(0.5)
		if exists(Pattern("1709852331965.png").similar(0.90)):
			while exists(Pattern("1709852331965.png").similar(0.90)):
				click(Pattern("1709852331965.png").similar(0.90))
				wait(2)
		click("1709852349665.png")
		wait(2)
		if exists("1709852395138.png"):
			click("1709852402526.png")
	items = items - 1

if __name__ == "__main__":
	debut = 1
	page = 44
	decompte = 1
	while page > 0:
		if decompte == 1:
			items = 3
			wait(0.1)
		else:
			items = 10
			wait(0.1)
		while items > 0:
			defilement(items, debut, decompte, page)
			wait(1)
			download(items, debut)
			wait(1)
			idm(items)
			wait(1)
			couv()
			debut = 0


Voici l'erreur que j'obtiens : 

[error] script stopped with error in line 12 at column 1
[error] SyntaxError ( "name 'items' is local and global",  )