Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1651 Le 04/12/2012, à 08:55

ragamatrix

Re : [Conky] Alternative à weather.com (2)

Merci les pros !
L'image est bien générée correctement, par contre lorsque je lance conky avec ces deux lignes la carte ne s'affiche pas:

 ${execi 1200 /home/climatix/.conky/script/gws.sh
${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -f 60} 

Elle s'affiche uniquement si je commente l'appel du script.(donc pas d'actualisation) sad

Hors ligne

#1652 Le 04/12/2012, à 09:02

ragamatrix

Re : [Conky] Alternative à weather.com (2)

en gros l'idée serait ça:
globsat

Dernière modification par ragamatrix (Le 04/12/2012, à 09:05)

Hors ligne

#1653 Le 04/12/2012, à 09:18

jpdipsy

Re : [Conky] Alternative à weather.com (2)

ragamatrix a écrit :

Merci les pros !
L'image est bien générée correctement, par contre lorsque je lance conky avec ces deux lignes la carte ne s'affiche pas:

 ${execi 1200 /home/climatix/.conky/script/gws.sh
${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -f 60} 

Elle s'affiche uniquement si je commente l'appel du script.(donc pas d'actualisation) sad

remplace : ${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -f 60}
par :${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -n}

Hors ligne

#1654 Le 04/12/2012, à 09:30

ragamatrix

Re : [Conky] Alternative à weather.com (2)

jpdipsy a écrit :
ragamatrix a écrit :

Merci les pros !
L'image est bien générée correctement, par contre lorsque je lance conky avec ces deux lignes la carte ne s'affiche pas:

 ${execi 1200 /home/climatix/.conky/script/gws.sh
${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -f 60} 

Elle s'affiche uniquement si je commente l'appel du script.(donc pas d'actualisation) sad

remplace : ${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -f 60}
par :${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -n}

ça ne marche pas non plus.

Hors ligne

#1655 Le 04/12/2012, à 09:52

jpdipsy

Re : [Conky] Alternative à weather.com (2)

ragamatrix a écrit :
jpdipsy a écrit :
ragamatrix a écrit :

Merci les pros !
L'image est bien générée correctement, par contre lorsque je lance conky avec ces deux lignes la carte ne s'affiche pas:

 ${execi 1200 /home/climatix/.conky/script/gws.sh
${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -f 60} 

Elle s'affiche uniquement si je commente l'appel du script.(donc pas d'actualisation) sad

remplace : ${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -f 60}
par :${image ~/sphere_satireu1.png -p 20,370 -s 300x300 -n}

ça ne marche pas non plus.

petit ragamatrix ne manque t'il pas quelque chose  ici tout au bout ${execi 1200 /home/climatix/.conky/script/gws.sh hein je pose la question ?

Hors ligne

#1656 Le 04/12/2012, à 10:30

ragamatrix

Re : [Conky] Alternative à weather.com (2)

J'ai un peu honte mais je ne vois pas ce que tu veux dire c'est sûrement un truc tout simple...:/

Hors ligne

#1657 Le 04/12/2012, à 10:33

jpdipsy

Re : [Conky] Alternative à weather.com (2)

ragamatrix a écrit :

J'ai un peu honte mais je ne vois pas ce que tu veux dire c'est sûrement un truc tout simple...:/

}

tu peux avoir honte lol lol lol

Hors ligne

#1658 Le 04/12/2012, à 10:43

ragamatrix

Re : [Conky] Alternative à weather.com (2)

jpdipsy a écrit :
ragamatrix a écrit :

J'ai un peu honte mais je ne vois pas ce que tu veux dire c'est sûrement un truc tout simple...:/

}

tu peux avoir honte lol lol lol

Non de ZEUS comment j'ai pu en arriver là !!
Là tu m'as eu merci...
Je ne peux même pas me cacher big_smile

Hors ligne

#1659 Le 04/12/2012, à 21:48

ragamatrix

Re : [Conky] Alternative à weather.com (2)

Je suis toujours avec convert pour essayer de faire la même chose avec une carte des us; evidemment c'est grand et difficile de faire une sphère avec un rectangle; donc dans le script j'ai séléctionné un carré grace à cette commande:

  convert /tmp/g13.2012339.1645_US_vis.jpg -filter Lanczos -crop  450x450+530+410\! /tmp/g13.2012339.1645_US_vis.png

Par contre je ne trouve pas les bons parametres pour centrer le masque afin d'obtenir une image "propre"parce que là c'est un peu moyen...
centrus

script convert :

 #!/bin/bash
###Script de sphérisation carte satellite pour l'Europe ou les Etats-Unis ## http://weather.msfc.nasa.gov/GOES/ICG13-09312012339.jpg ##
									  ## http://www.meteo-mc.fr/dedie/Images/sat/satireu1.gif
									  ## http://weather.rap.ucar.edu/satellite/g13.2012339.1645_US_vis.jpg
##convert /tmp/g13.2012339.1645_US_vis.jpg /tmp/gwsus.png
wget  -q -O  /tmp/g13.2012339.1645_US_vis.jpg "http://weather.rap.ucar.edu/satellite/g13.2012339.1645_US_vis.jpg"

convert /tmp/g13.2012339.1645_US_vis.jpg -filter Lanczos -crop  450x450+530+410\! /tmp/g13.2012339.1645_US_vis.png

#creation du masque 
convert -size 450x450 xc:black -fill white -draw 'circle 224.5,224.5 224.5,0'   /tmp/masque.png

convert -size 450x450 xc:  -channel R  -fx 'yy=(j+.5)/h-.5; (i/w-.5)/(sqrt(1-4*yy^2))+.5' \
-separate  +channel     /tmp/sphere_lut.png

convert /tmp/masque.png \
 \( +clone -blur 0x20 -shade 110x21.7 -contrast-stretch 0% \
 +sigmoidal-contrast 6x50% -fill grey50 -colorize 10%  \) \
 -composite /tmp/overlay.png



convert /tmp/g13.2012339.1645_US_vis.png -resize 450x450   /tmp/sphere_lut.png   -fx 'p{ v*w, j }' \
overlay.png   -compose HardLight  -composite \
masque.png -alpha off -compose CopyOpacity -composite \
/tmp/sphere_gwsus.png 

S'il y a des spécialistes de convert, merci encore...

Dernière modification par ragamatrix (Le 04/12/2012, à 21:50)

Hors ligne

#1660 Le 05/12/2012, à 02:01

jpdipsy

Re : [Conky] Alternative à weather.com (2)

ragamatrix a écrit :

Je suis toujours avec convert pour essayer de faire la même chose avec une carte des us; evidemment c'est grand et difficile de faire une sphère avec un rectangle; donc dans le script j'ai séléctionné un carré grace à cette commande:

  convert /tmp/g13.2012339.1645_US_vis.jpg -filter Lanczos -crop  450x450+530+410\! /tmp/g13.2012339.1645_US_vis.png

Par contre je ne trouve pas les bons parametres pour centrer le masque afin d'obtenir une image "propre"parce que là c'est un peu moyen...
centrus

script convert :

 #!/bin/bash
###Script de sphérisation carte satellite pour l'Europe ou les Etats-Unis ## http://weather.msfc.nasa.gov/GOES/ICG13-09312012339.jpg ##
									  ## http://www.meteo-mc.fr/dedie/Images/sat/satireu1.gif
									  ## http://weather.rap.ucar.edu/satellite/g13.2012339.1645_US_vis.jpg
##convert /tmp/g13.2012339.1645_US_vis.jpg /tmp/gwsus.png
wget  -q -O  /tmp/g13.2012339.1645_US_vis.jpg "http://weather.rap.ucar.edu/satellite/g13.2012339.1645_US_vis.jpg"

convert /tmp/g13.2012339.1645_US_vis.jpg -filter Lanczos -crop  450x450+530+410\! /tmp/g13.2012339.1645_US_vis.png

#creation du masque 
convert -size 450x450 xc:black -fill white -draw 'circle 224.5,224.5 224.5,0'   /tmp/masque.png

convert -size 450x450 xc:  -channel R  -fx 'yy=(j+.5)/h-.5; (i/w-.5)/(sqrt(1-4*yy^2))+.5' \
-separate  +channel     /tmp/sphere_lut.png

convert /tmp/masque.png \
 \( +clone -blur 0x20 -shade 110x21.7 -contrast-stretch 0% \
 +sigmoidal-contrast 6x50% -fill grey50 -colorize 10%  \) \
 -composite /tmp/overlay.png



convert /tmp/g13.2012339.1645_US_vis.png -resize 450x450   /tmp/sphere_lut.png   -fx 'p{ v*w, j }' \
overlay.png   -compose HardLight  -composite \
masque.png -alpha off -compose CopyOpacity -composite \
/tmp/sphere_gwsus.png 

S'il y a des spécialistes de convert, merci encore...

Des spécialistes je sais pas mais des opticiens peut-être  lol lol lol
Sans essayer de prime abord je dirais que tu prends pour référence des images différentes
overlay.png   -compose HardLight  -composite \

devrait être
/tmp/overlay.png   -compose HardLight  -composite \

et pareil pour
masque.png -alpha off -compose CopyOpacity -composite \

au lieu de
/tmp/masque.png -alpha off -compose CopyOpacity -composite \

Il serai bon que tu ajoutes à la fin de tes scripts un peu de nettoyage:
rm /tmp/overlay.png ;rm /tmp/masque.png ;rm /tmp/sphere_lut.png

Ah ces jeunes ! roll

Hors ligne

#1661 Le 05/12/2012, à 02:34

jpdipsy

Re : [Conky] Alternative à weather.com (2)

C'est pour ma pomme naturellement !

@Didier  et toutes,tous depuis cette nuit problème avec meteo.lua
Conky: llua_do_call: function conky_Meteo_enligne execution failed: /home/jean64/.conky/Meteo-Lua/scripts/meteo.lua:506: field 'day' missing in date table

c'est pareil chez vous ?

A l'approche du 21/12/2012 peut être que le temps s'arrête  lol

Dernière modification par jpdipsy (Le 05/12/2012, à 02:37)

Hors ligne

#1662 Le 05/12/2012, à 06:40

Didier-T

Re : [Conky] Alternative à weather.com (2)

jpdipsy a écrit :

C'est pour ma pomme naturellement !

@Didier  et toutes,tous depuis cette nuit problème avec meteo.lua
Conky: llua_do_call: function conky_Meteo_enligne execution failed: /home/jean64/.conky/Meteo-Lua/scripts/meteo.lua:506: field 'day' missing in date table

c'est pareil chez vous ?

A l'approche du 21/12/2012 peut être que le temps s'arrête  lol

mais tu dors jamais...
en effet il y a un soucis, j’ai vue sa hier soir après avoir couché mon garçon, depuis 19h30 plus de mise a jour, je regarde aujourd'hui d’où viens le problème.

Hors ligne

#1663 Le 05/12/2012, à 07:38

Didier-T

Re : [Conky] Alternative à weather.com (2)

Bon et bien j'ai une bonne et une mauvaise nouvelle.

la bonne nouvelle c'est que je sais d’où viens le soucis avec la météo, il s'agit de la de mise a jour, soit conky soit lua.
la mauvaise nouvelle est que je ne trouve pas de solution pour revenir a l'ancienne version de conky
perso je pencherais pour la mise a jour de conky en 1.9 alors que nous étions en 1.8

Dernière modification par Didier-T (Le 05/12/2012, à 07:50)

Hors ligne

#1664 Le 05/12/2012, à 07:50

jpdipsy

Re : [Conky] Alternative à weather.com (2)

Didier-T a écrit :

Bon et bien j'ai une bonne et une mauvaise nouvelle.

la bonne nouvelle c'est que je sais d’où viens le soucis avec la météo, il s'agit de la de mise a jour, soit conky soit lua.
la mauvaise nouvelle est que je ne trouve pas de solution pour revenir a l'ancienne version de conky

J'ai regardé un peu le fichier téléchargé, est-ce que accuweather n'aurai pas changé quelque chose parce que je trouve un décalage dans le référencement des lignes lors de l'extraction des données dans météo.lua et la place de ces lignes dans le fichier (ou je me trompe)?

Hors ligne

#1665 Le 05/12/2012, à 07:53

Didier-T

Re : [Conky] Alternative à weather.com (2)

jpdipsy a écrit :
Didier-T a écrit :

Bon et bien j'ai une bonne et une mauvaise nouvelle.

la bonne nouvelle c'est que je sais d’où viens le soucis avec la météo, il s'agit de la de mise a jour, soit conky soit lua.
la mauvaise nouvelle est que je ne trouve pas de solution pour revenir a l'ancienne version de conky

J'ai regardé un peu le fichier téléchargé, est-ce que accuweather n'aurai pas changé quelque chose parce que je trouve un décalage dans le référencement des lignes lors de l'extraction des données dans météo.lua et la place de ces lignes dans le fichier (ou je me trompe)?

en fait sa ne viens pas du script.
en tous cas pas pour le problème signalé par le lancement de conky.
si je suis si affirmatif c'est que pour développer les fonctions, j'ai fais des mini script qui tourne en lua (sans conky) et qu’avec la version 5.2 tous roules.

Hors ligne

#1666 Le 05/12/2012, à 08:07

jpdipsy

Re : [Conky] Alternative à weather.com (2)

Didier-T a écrit :
jpdipsy a écrit :
Didier-T a écrit :

Bon et bien j'ai une bonne et une mauvaise nouvelle.

la bonne nouvelle c'est que je sais d’où viens le soucis avec la météo, il s'agit de la de mise a jour, soit conky soit lua.
la mauvaise nouvelle est que je ne trouve pas de solution pour revenir a l'ancienne version de conky

J'ai regardé un peu le fichier téléchargé, est-ce que accuweather n'aurai pas changé quelque chose parce que je trouve un décalage dans le référencement des lignes lors de l'extraction des données dans météo.lua et la place de ces lignes dans le fichier (ou je me trompe)?

en fait sa ne viens pas du script.
en tous cas pas pour le problème signalé par le lancement de conky.
si je suis si affirmatif c'est que pour développer les fonctions, j'ai fais des mini script qui tourne en lua (sans conky) et qu’avec la version 5.2 tous roules.

Bigre sans qu'il y'est de M.A.J de conky et lua étonnant.
Donc un appel au peuple s'impose !
Ami de météo.lua et conky si tu n'as pas fait de mise à jour de ton système depuis hier matin est-ce que ton météo.lua fonctionne correctement ?

Hors ligne

#1667 Le 05/12/2012, à 08:58

ragamatrix

Re : [Conky] Alternative à weather.com (2)

jpdipsy a écrit :
Didier-T a écrit :
jpdipsy a écrit :

J'ai regardé un peu le fichier téléchargé, est-ce que accuweather n'aurai pas changé quelque chose parce que je trouve un décalage dans le référencement des lignes lors de l'extraction des données dans météo.lua et la place de ces lignes dans le fichier (ou je me trompe)?

en fait sa ne viens pas du script.
en tous cas pas pour le problème signalé par le lancement de conky.
si je suis si affirmatif c'est que pour développer les fonctions, j'ai fais des mini script qui tourne en lua (sans conky) et qu’avec la version 5.2 tous roules.

Bigre sans qu'il y'est de M.A.J de conky et lua étonnant.
Donc un appel au peuple s'impose !
Ami de météo.lua et conky si tu n'as pas fait de mise à jour de ton système depuis hier matin est-ce que ton météo.lua fonctionne correctement ?

Lancement après mise à jour :
problème avec la lune apparemment;

 ┌─( climatix ) - ( 3.2.0-34-generic ) - ( ~ )
└─> conky -c ~/.conky/conky38/conkyrc_meteo_lua
Conky: can't parse X color 'lightwhite'
Conky: can't parse X color 'lightwhite'
Conky: forked to background, pid is 26874
┌─( climatix ) - ( 3.2.0-34-generic ) - ( ~ )
└─> 
Conky: desktop window (ae) is root window
Conky: window type - desktop
Conky: drawing to created window (0x2a00001)
Conky: drawing to double buffer
	version = v4.7
	web = http://www.accuweather.com/fr/ch/horgen/316407/current-weather/316407
	Pévision Nb jours = 5
	Pévision Matin = oui
	Pévision Après Midi = oui
	Pévision Soirée = oui
	Pévision Nuit = oui
	Prévision sur 8 heures = oui
	Délais = 1200
	Chemin de travail = /tmp
	Palier = 20
	Chemin de sauvegarde = /home/climatix/.conky/conky38/meteo
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
Conky: llua_do_call: function conky_Meteo_enligne execution failed: /home/climatix/.conky/conky38/script/meteo.lua:506: field 'day' missing in date table
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
Conky: Unable to load image '/tmp/lune.png'
 

meteolua
Pour décembre, c'est le choix de police quin'est pas bon.
@Didier-T jpdipsy; merci pour ton oeil de lynx !
J'ai fais un test pour la carte de us et c'est mieux:
gwsus

ps/Avant la mise à jour j'avais cette erreur aussi
post mis à jour; vous formez une tellement bonne équipe pour aider les étourdis de mon espèce que j'arrive aussi à vous confondre...:rolleyes:

Dernière modification par ragamatrix (Le 05/12/2012, à 13:26)

Hors ligne

#1668 Le 05/12/2012, à 09:10

jpdipsy

Re : [Conky] Alternative à weather.com (2)

@ragamatrix

Chez toi ça ne fonctionne plus aussi tu es en hors ligne

Conky: llua_do_call: function conky_Meteo_enligne execution failed: /home/climatix/.conky/conky38/script/meteo.lua:506: field 'day' missing in date table

il bute sur la même ligne que nous failed: /home/climatix/.conky/conky38/script/meteo.lua:506

et j'ai essayé avec une version antérieur à la 4.7 celà ne fonctionne plus du tout donc wait and see

Hors ligne

#1669 Le 05/12/2012, à 11:17

Didier-T

Re : [Conky] Alternative à weather.com (2)

jpdipsy a raison il s'agit bien de modification sur le site, je ferais une correctif cette après midi pendant la sieste de louis.
il y a eut beaucoup de modifications, je ne suis pas certain de pouvoir refaire fonctionner tous de suite le module huit heure.

Hors ligne

#1670 Le 05/12/2012, à 11:38

jpdipsy

Re : [Conky] Alternative à weather.com (2)

Didier-T a écrit :

je ne suis pas certain de pouvoir refaire fonctionner tous de suite le module huit heure.

ouais j'ai regardé les pages c'est pas de la petite biére.
Remarque on s'en fout il sert juste à Ragamatrix (je déconne évidement)
Par contre Ragamatrix il faut vraiment que tu ailles chez l'opticien tu en arrives même à remercier Didier suite à mon message lol
C'était la minute défoulement.  lol

Hors ligne

#1671 Le 05/12/2012, à 12:20

Didier-T

Re : [Conky] Alternative à weather.com (2)

jpdipsy a écrit :

...
Par contre Ragamatrix il faut vraiment que tu ailles chez l'opticien tu en arrives même à remercier Didier suite à mon message lol
C'était la minute défoulement.  lol

je me demandai justement ce que j'avais bien pu faire...

Dernière modification par Didier-T (Le 05/12/2012, à 12:21)

Hors ligne

#1672 Le 05/12/2012, à 13:20

Didier-T

Re : [Conky] Alternative à weather.com (2)

voici le script corrigé.

surtout n'oublier pas de désactiver les prévisions a huit heure (trop de chose a reprendre pour le moment)

meteo.lua 4.8b

-- Créé par Didier-T (forum.ubuntu-fr.org)
-- Nécessite imagemagick http://apt.ubuntu.com/p/imagemagick
-- Nécessite Curl



require "io"
require "os"
local Version = "v4.8b"
local conditionJour = {}
local conditionNuit = {}
local conditionMatin = {}
local conditionAM = {}
local conditionSoiree = {}
local conditionNoct = {}
local InfoJour = {}
local conditioncourante = {}
local huitHeures = {}
local Rep, cmd, jours, matin, apresmidi, soiree, nuit, delais, r, repsauv, l, fichier_init, MAJ, tc, dermodif, VilleAdresse
local Debug = "Problème Info "
--Liste des accents et carractère non pris en charge par les patterns
local pat="%é%è%à%ä%â%ê%ô%ç%É%È%À%Â%Ä%Ê%Ô%Ç"


--Traduction date
function trad_date(d)
	local date = d
	date = date:gsub("Monday", "Lundi"):gsub("Tuesday", "Mardi"):gsub("Wednesday", "Mercredi"):gsub("Thursday", "Jeudi"):gsub("Friday", "Vendredi"):gsub("Saturday", "Samedi"):gsub("Sunday", "Dimanche")

	date = date:gsub("lun", "Lun"):gsub("mar", "Mar"):gsub("mer", "Mer"):gsub("jeu", "Jeu"):gsub("ven", "Ven"):gsub("sam", "Sam"):gsub("dim", "Dim")

	date = date:gsub("Mon", "Lun"):gsub("Tue", "Mar"):gsub("Wed", "Mer"):gsub("Thu", "Jeu"):gsub("Fri", "Ven"):gsub("Sat", "Sam"):gsub("Sun", "Dim")
	
	date = date:gsub("January", "Janvier"):gsub("February", "Février"):gsub("March", "Mars"):gsub("April", "Avril"):gsub("May", "Mai"):gsub("June", "Juin"):gsub("July", "Juillet"):gsub("August", "Août"):gsub("September", "Septembre"):gsub("October", "Octobre"):gsub("November", "Novembre"):gsub("December", "Décembre")

	date = date:gsub("jan", "Jan"):gsub("fev", "Fév"):gsub("mar", "Mar"):gsub("avr", "Avr"):gsub("mai", "Mai"):gsub("jui", "Jui"):gsub("aou", "Aoû"):gsub("sep", "Sep"):gsub("oct", "Oct"):gsub("nov", "Nov"):gsub("dec", "Déc")
	
	date = date:gsub("Feb", "Fév"):gsub("Apr", "Avr"):gsub("May", "Mai"):gsub("Jun", "Juin"):gsub("Jul", "Juil"):gsub("Aug", "Aoû"):gsub("Dec", "Déc")
		
	return date
end

--Vérifier l'existence d'un fichier
function existe(file) 
  local a = io.open(file, "r")
  local present
  if a then
    present = true
    io.close(a)
  else
    present = false
  end
  return present
end

--Formatage des pages web
function string.formatage(ligne)
ligne = ligne:gsub("ô", "ô"):gsub("â", "â"):gsub("é", "é"):gsub("è", "è"):gsub("à", "à"):gsub("ç", "ç"):gsub("ê", "ê"):gsub("ö", "ö"):gsub("î", "î"):gsub("ï", "ï"):gsub("û", "û"):gsub("ü", "ü"):gsub("'", "'"):gsub("Poudreries", "Bourrasques de neige"):gsub("É", "É"):gsub("°",""):gsub("[\n\r]",""):gsub("é", "é")
return ligne
end

--Traitement Huit prochaines heures

function Huit_Heures(web)
	local f, i, line, heure1, heure2, heure3, heure4, heure5, heure6, heure7, heure8, icone1, icone2, icone3, icone4, icone5, icone6, icone7, icone8, Temp1, Temp2, Temp3, Temp4, Temp5, Temp6, Temp7, Temp8, TempR1, TempR2, TempR3, TempR4, TempR5, TempR6, TempR7, TempR8, Humi1, Humi2, Humi3, Humi4, Humi5, Humi6, Humi7, Humi8, Pluie1, Pluie2, Pluie3, Pluie4, Pluie5, Pluie6, Pluie7, Pluie8, Neige1, Neige2, Neige3, Neige4, Neige5, Neige6, Neige7, Neige8, Verglas1, Verglas2, Verglas3, Verglas4, Verglas5, Verglas6, Verglas7, Verglas8, Vitesse1, Dir1, Vitesse2, Dir2, Vitesse3, Dir3, Vitesse4, Dir4, Vitesse5, Dir5, Vitesse6, Dir6, Vitesse7, Dir7, Vitesse8, Dir8, UV1, UV2, UV3, UV4, UV5, UV6, UV7, UV8, CouvNuage1, CouvNuage2, CouvNuage3, CouvNuage4, CouvNuage5, CouvNuage6, CouvNuage7, CouvNuage8, Rosee1, Rosee2, Rosee3, Rosee4, Rosee5, Rosee6, Rosee7, Rosee8, h, Dbg
	
	f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A202 'hourly\"' | sed 's/%//g'"))
	line=f:read()
	i=0
	for line in f:lines() do
		i=i+1
		--Récup. des heures
		if i==8 then
			heure1=line:match("/>(%d*)</")
		elseif i==9 then
			heure2=line:match(">(%d*)</")
		elseif i==10 then
			heure3=line:match(">(%d*)</")
		elseif i==11 then
			heure4=line:match(">(%d*)</")
		elseif i==12 then
			heure5=line:match(">(%d*)</")
		elseif i==13 then
			heure6=line:match(">(%d*)</")
		elseif i==14 then
			heure7=line:match(">(%d*)</")
		elseif i==15 then
			heure8=line:match(">(%d*)</")
		--Récup. des icones
		elseif i==34 then
			icone1=line:match("i%p(%a*)\">")
		elseif i==37 then
			icone2=line:match("i%p(%a*)\">")
		elseif i==40 then
			icone3=line:match("i%p(%a*)\">")
		elseif i==43 then
			icone4=line:match("i%p(%a*)\">")
		elseif i==46 then
			icone5=line:match("i%p(%a*)\">")
		elseif i==49 then
			icone6=line:match("i%p(%a*)\">")
		elseif i==52 then
			icone7=line:match("i%p(%a*)\">")
		elseif i==55 then
			icone8=line:match("i%p(%a*)\">")
		--Températures
		elseif i==60 then
			Temp1=line:match(">([%p%d]*)&")
		elseif i==61 then
			Temp2=line:match(">([%p%d]*)&")
		elseif i==62 then
			Temp3=line:match(">([%p%d]*)&")
		elseif i==63 then
			Temp4=line:match(">([%p%d]*)&")
		elseif i==64 then
			Temp5=line:match(">([%p%d]*)&")
		elseif i==65 then
			Temp6=line:match(">([%p%d]*)&")
		elseif i==66 then
			Temp7=line:match(">([%p%d]*)&")
		elseif i==67 then
			Temp8=line:match(">([%p%d]*)&")
		--Températures ressentie
		elseif i==71 then
			TempR1=line:match(">([%p%d]*)&")
		elseif i==72 then
			TempR2=line:match(">([%p%d]*)&")
		elseif i==73 then
			TempR3=line:match(">([%p%d]*)&")
		elseif i==74 then
			TempR4=line:match(">([%p%d]*)&")
		elseif i==75 then
			TempR5=line:match(">([%p%d]*)&")
		elseif i==76 then
			TempR6=line:match(">([%p%d]*)&")
		elseif i==77 then
			TempR7=line:match(">([%p%d]*)&")
		elseif i==78 then
			TempR8=line:match(">([%p%d]*)&")
		--Humidité
		elseif i==82 then
			Humi1=line:match(">(%d*)<")
		elseif i==83 then
			Humi2=line:match(">(%d*)<")
		elseif i==84 then
			Humi3=line:match(">(%d*)<")
		elseif i==85 then
			Humi4=line:match(">(%d*)<")
		elseif i==86 then
			Humi5=line:match(">(%d*)<")
		elseif i==87 then
			Humi6=line:match(">(%d*)<")
		elseif i==88 then
			Humi7=line:match(">(%d*)<")
		elseif i==89 then
			Humi8=line:match(">(%d*)<")
		--Pluie
		elseif i==109 then
			Pluie1=line:match("v>(%d*)<")
		elseif i==110 then
			Pluie2=line:match("v>(%d*)<")
		elseif i==111 then
			Pluie3=line:match("v>(%d*)<")
		elseif i==112 then
			Pluie4=line:match("v>(%d*)<")
		elseif i==113 then
			Pluie5=line:match("v>(%d*)<")
		elseif i==114 then
			Pluie6=line:match("v>(%d*)<")
		elseif i==115 then
			Pluie7=line:match("v>(%d*)<")
		elseif i==116 then
			Pluie8=line:match("v>(%d*)<")
		--Neige
		elseif i==120 then
			Neige1=line:match("v>(%d*)<")
		elseif i==121 then
			Neige2=line:match("v>(%d*)<")
		elseif i==122 then
			Neige3=line:match("v>(%d*)<")
		elseif i==123 then
			Neige4=line:match("v>(%d*)<")
		elseif i==124 then
			Neige5=line:match("v>(%d*)<")
		elseif i==125 then
			Neige6=line:match("v>(%d*)<")
		elseif i==126 then
			Neige7=line:match("v>(%d*)<")
		elseif i==127 then
			Neige8=line:match("v>(%d*)<")
		--Verglas
		elseif i==131 then
			Verglas1=line:match("v>(%d*)<")
		elseif i==132 then
			Verglas2=line:match("v>(%d*)<")
		elseif i==133 then
			Verglas3=line:match("v>(%d*)<")
		elseif i==134 then
			Verglas4=line:match("v>(%d*)<")
		elseif i==135 then
			Verglas5=line:match("v>(%d*)<")
		elseif i==136 then
			Verglas6=line:match("v>(%d*)<")
		elseif i==137 then
			Verglas7=line:match("v>(%d*)<")
		elseif i==138 then
			Verglas8=line:match("v>(%d*)<")
		--Vent
		elseif i==159 then
			Vitesse1, Dir1=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
			VentP1=vent_plein(Dir1)
		elseif i==160 then
			Vitesse2, Dir2=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
			VentP2=vent_plein(Dir2)
		elseif i==161 then
			Vitesse3, Dir3=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
			VentP3=vent_plein(Dir3)
		elseif i==162 then
			Vitesse4, Dir4=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
			VentP4=vent_plein(Dir4)
		elseif i==163 then
			Vitesse5, Dir5=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
			VentP5=vent_plein(Dir5)
		elseif i==164 then
			Vitesse6, Dir6=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
			VentP6=vent_plein(Dir6)
		elseif i==165 then
			Vitesse7, Dir7=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
			VentP7=vent_plein(Dir7)
		elseif i==166 then
			Vitesse8, Dir8=line:gsub("W","O"):match(">(%d*)%s(%a*)<")
			VentP8=vent_plein(Dir8)
		--Uv
		elseif i==170 then
			UV1=line:match(">(%d*)<")
		elseif i==171 then
			UV2=line:match(">(%d*)<")
		elseif i==172 then
			UV3=line:match(">(%d*)<")
		elseif i==173 then
			UV4=line:match(">(%d*)<")
		elseif i==174 then
			UV5=line:match(">(%d*)<")
		elseif i==175 then
			UV6=line:match(">(%d*)<")
		elseif i==176 then
			UV7=line:match(">(%d*)<")
		elseif i==177 then
			UV8=line:match(">(%d*)<")
		--Couverture nuageuse
		elseif i==181 then
			CouvNuage1=line:match(">(%d*)<")
		elseif i==182 then
			CouvNuage2=line:match(">(%d*)<")
		elseif i==183 then
			CouvNuage3=line:match(">(%d*)<")
		elseif i==184 then
			CouvNuage4=line:match(">(%d*)<")
		elseif i==185 then
			CouvNuage5=line:match(">(%d*)<")
		elseif i==186 then
			CouvNuage6=line:match(">(%d*)<")
		elseif i==187 then
			CouvNuage7=line:match(">(%d*)<")
		elseif i==188 then
			CouvNuage8=line:match(">(%d*)<")
		--Point de rosée
		elseif i==192 then
			Rosee1=line:match(">([%p%d]*)&")
		elseif i==193 then
			Rosee2=line:match(">([%p%d]*)&")
		elseif i==194 then
			Rosee3=line:match(">([%p%d]*)&")
		elseif i==195 then
			Rosee4=line:match(">([%p%d]*)&")
		elseif i==196 then
			Rosee5=line:match(">([%p%d]*)&")
		elseif i==197 then
			Rosee6=line:match(">([%p%d]*)&")
		elseif i==198 then
			Rosee7=line:match(">([%p%d]*)&")
		elseif i==199 then
			Rosee8=line:match(">([%p%d]*)&")
		end
	end
	f:close()

	huitHeures[1] = {Heure=heure1, Icone=icone1, TempMax=Temp1, TempMaxR=TempR1, VentDir=Dir1, VentForce=Vitesse1, Humidite=Humi1, CouvNuage=CouvNuage1, PointRosee=Rosee1, UV=UV1, Pluie=Pluie1, Neige=Neige1, Verglas=Verglas1, VentP=VentP1}
	huitHeures[2] = {Heure=heure2, Icone=icone2, TempMax=Temp2, TempMaxR=TempR2, VentDir=Dir2, VentForce=Vitesse2, Humidite=Humi2, CouvNuage=CouvNuage2, PointRosee=Rosee2, UV=UV2, Pluie=Pluie2, Neige=Neige2, Verglas=Verglas2, VentP=VentP2}
	huitHeures[3] = {Heure=heure3, Icone=icone3, TempMax=Temp3, TempMaxR=TempR3, VentDir=Dir3, VentForce=Vitesse3, Humidite=Humi3, CouvNuage=CouvNuage3, PointRosee=Rosee3, UV=UV3, Pluie=Pluie3, Neige=Neige3, Verglas=Verglas3, VentP=VentP3}
	huitHeures[4] = {Heure=heure4, Icone=icone4, TempMax=Temp4, TempMaxR=TempR4, VentDir=Dir4, VentForce=Vitesse4, Humidite=Humi4, CouvNuage=CouvNuage4, PointRosee=Rosee4, UV=UV4, Pluie=Pluie4, Neige=Neige4, Verglas=Verglas4, VentP=VentP4}
	huitHeures[5] = {Heure=heure5, Icone=icone5, TempMax=Temp5, TempMaxR=TempR5, VentDir=Dir5, VentForce=Vitesse5, Humidite=Humi5, CouvNuage=CouvNuage5, PointRosee=Rosee5, UV=UV5, Pluie=Pluie5, Neige=Neige5, Verglas=Verglas5, VentP=VentP5}
	huitHeures[6] = {Heure=heure6, Icone=icone6, TempMax=Temp6, TempMaxR=TempR6, VentDir=Dir6, VentForce=Vitesse6, Humidite=Humi6, CouvNuage=CouvNuage6, PointRosee=Rosee6, UV=UV6, Pluie=Pluie6, Neige=Neige6, Verglas=Verglas6, VentP=VentP6}
	huitHeures[7] = {Heure=heure7, Icone=icone7, TempMax=Temp7, TempMaxR=TempR7, VentDir=Dir7, VentForce=Vitesse7, Humidite=Humi7, CouvNuage=CouvNuage7, PointRosee=Rosee7, UV=UV7, Pluie=Pluie7, Neige=Neige7, Verglas=Verglas7, VentP=VentP7}
	huitHeures[8] = {Heure=heure8, Icone=icone8, TempMax=Temp8, TempMaxR=TempR8, VentDir=Dir8, VentForce=Vitesse8, Humidite=Humi8, CouvNuage=CouvNuage8, PointRosee=Rosee8, UV=UV8, Pluie=Pluie8, Neige=Neige8, Verglas=Verglas8, VentP=VentP8}
	
	local t = {"VentP", "Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas"}
	for j = 1, 8 do
		local donee = {}
		donee = huitHeures[j]
		for i = 1,13 do
			if donee[t[i]] == nil then
				local file = assert(io.open(repsauv.."/Debug", "a+"))
				file:write ("\n", Debug,"huitHeures ", t[i]," jour n° ", j)
				donee[t[i]]="N/A"
			end
		end
		huitHeures[j] = donee
	end


	for h = 1,8 do
		if huitHeures[h].VentDir == "CLM" then
			huitHeures[h].VentDir = "Calme"
			huitHeures[h].VentForce = "0"
		end
		huitHeures[h].VentIcone = icone_vent(direction_vent(huitHeures[h].VentDir), huitHeures[h].VentForce)
		huitHeures[h].VentP = vent_plein(huitHeures[h].VentDir)
	end

end
--Traitement information Quart de journée
function Prevision_Quart_T(web)
	local f, i, line, icone, cond, Tmax, Tmin, Tmaxres, Tminres, dirvent, forcevent, Precipitationpourcent, Pluie, Neige, Humidite,Couverture, Pointrosee, Visibilite, Dbg

	f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A50 '/#detail-' | sed 's/%//g'"))
	line=f:read()
	i=0
	for line in f:lines() do
		i=i+1
		if i==4 then
			icone=line:match("icon i%p(%a*)\">")
		elseif i==5 then
			cond=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</")
		elseif i==6 then
			Tmax=line:match(">([%p%d]*)<s")
		elseif i==7 then
			Tmin=line:match("lo\">%a*%s([%p%d]*)<s")
		elseif i==10 then
			Tmaxres, Tminres=line:formatage():match("&#174; ([%p%d]*) / ([%p%d]*)</")
		elseif i==27 then
			dirvent=line:gsub("W","O"):match("'(%a*)'")
		elseif i==28 then
			forcevent=line:match("'(%d*)[%a%p]*'")
		elseif i==38 then
			Precipitationpourcent=line:match(">(%d*)</")
		elseif i==39 then
			Pluie=line:match(">([%d%p]*) %a*</")
		elseif i==40 then
			Neige=line:match(">([%d%p]*) %a*</")
		elseif i==41 then
			Humidite=line:match(">(%d*)</")
		elseif i==42 then
			Couverture=line:match(">(%d*)</")
		elseif i==43 then
			Pointrosee=line:match(">([%p%d]*)&#")
		elseif i==44 then
			Visibilite=line:match(">(%d*) %a*</")
		end
	end
	f:close()
	

	return {Icone=icone, CondMeteo=cond, TempMax=Tmax, TempMin=Tmin, TempMaxR=Tmaxres, TempMinR=Tminres, VentDir=dirvent, VentForce=forcevent, Humidite=Humidite, CouvNuage=Couverture, PointRosee=Pointrosee, ProbPrec=Precipitationpourcent, Visibilite=Visibilite, QNeige=Neige, QPluie=Pluie}
end


--Prévision
function prevision(web)
	local f, i, line, iconej, Tmax, Tmaxr, ProbPrecj, Vdirj, Vforcej, Vrafalesj, Descriptifj, UV, ProbOragesj, Precj, Pluiej, Neigej, Verglasj, iconen, Tmin, Tminr, ProbPrecn, Vdirn, Vforcen, Vrafalesn, Descriptifn, UVn, ProbOragesn, Precn, Pluien, Neigen, Verglasn, jour,mois, annee, AujoudhuiMax, NormaleMax, RecordMax, Histo_Max, AujoudhuiMin, NormaleMin, RecordMin, Histo_Min,  LeverSoleil, LeverSoleilH, LeverSoleilM, Culmine, CulmineH, CulmineM, CoucherSoleil, CoucherSoleilH, CoucherSoleilM, Datej

	f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed 's/%//g' | grep -A193 '/#detail-'"))
	line=f:read()
	i=0
	for line in f:lines() do
		i=i+1
		--jour
		if i==5 then
			iconej=line:match("icon i%p(%a*)\">")
		elseif i==6 then
			Tmax=line:match("temp\">([%p%d]*)<")
		elseif i==7 then
			Tmaxr=line:match("174; ([%p%d]*)&#")
		elseif i==8 then
			ProbPrecj=line:match("feel[%a%p%d]* (%d*)</")
		elseif i==40 then
			Vdirj, Vforcej=line:gsub("W","O"):match(">(%a*) (%d*) [%a%p]*<")
		elseif i==43 then
			Vrafalesj=line:match("> (%d*) [%a%p]*<")
		elseif i==47 then
			Descriptifj=line:formatage():gsub(";",""):match("<p>([%a%p%s%d"..pat.."]*)</p>")
		elseif i==51 then
			UV=line:match("g>(%d*)</s")
		elseif i==52 then
			ProbOragesj=line:match(">(%d*)</s")
		elseif i==53 then
			Precj=line:match(">([%d%p]*) %a*</s")
		elseif i==54 then
			Pluiej=line:match(">([%d%p]*) %a*</s")
		elseif i==55 then
			Neigej=line:match(">([%d%p]*) %a*</s")
		elseif i==56 then
			Verglasj=line:match(">([%d%p]*) %a*</s")
		--nuit
		elseif i==65 then
			iconen=line:match("icon i%p(%a*)\">")
		elseif i==66 then
			Tmin=line:match("temp\">([%p%d]*)<")
		elseif i==67 then
			Tminr=line:match("174; ([%p%d]*)&#")
		elseif i==68 then
			ProbPrecn=line:match("feel[%a%p%d]* (%d*)</")
		elseif i==101 then
			Vdirn, Vforcen=line:gsub("W","O"):match(">(%a*) (%d*) [%a%p]*<")
		elseif i==104 then
			Vrafalesn=line:match("> (%d*) [%a%p]*<")
		elseif i==108 then
			Descriptifn=line:formatage():gsub(";",""):match("<p>([%a%p%s%d"..pat.."]*)</p>")
		elseif i==112 then
			UVn=line:match("g>([%a%p%d]*)</s")
		elseif i==113 then
			ProbOragesn=line:match(">(%d*)</s")
		elseif i==114 then
			Precn=line:match(">([%d%p]*) %a*</s")
		elseif i==115 then
			Pluien=line:match(">([%d%p]*) %a*</s")
		elseif i==116 then
			Neigen=line:match(">([%d%p]*) %a*</s")
		elseif i==117 then
			Verglasn=line:match(">([%d%p]*) %a*</s")
		--historique
		elseif i==133 then
			jour,mois,annee=line:match("- (%d*)/(%d*)/(%d*)</")
		elseif i==151 then
			AujoudhuiMax=line:formatage():match(">([%d%a%p]*)</")
		elseif i==153 then
			NormaleMax=line:formatage():match(">([%d%a%p]*)</")
		elseif i==155 then
			RecordMax=line:formatage():match(">([%d%a%p]*)</")
		elseif i==157 then
			Histo_Max=line:formatage():match(">([%d%a%p]*)</")
		elseif i==162 then
			AujoudhuiMin=line:formatage():match(">([%d%a%p]*)</")
		elseif i==164 then
			NormaleMin=line:formatage():match(">([%d%a%p]*)</")
		elseif i==166 then
			RecordMin=line:formatage():match(">([%d%a%p]*)</")
		elseif i==168 then
			Histo_Min=line:formatage():match(">([%d%a%p]*)</")
		--Lever coucher soleil
		elseif i==185 then
			LeverSoleil,LeverSoleilH,LeverSoleilM=line:match(">((%d*):(%d*))<")
		elseif i==188 then
			Culmine, CulmineH, CulmineM=line:match(">((%d*):(%d*))<")
		elseif i==191 then
			CoucherSoleil,CoucherSoleilH,CoucherSoleilM=line:match(">((%d*):(%d*))<")
		end
	end
	f:close()

	Datej = os.time{year=annee, month=mois, day=jour, hour=0}

	return { Icone=iconej, CondMeteo=Descriptifj, Temp=Tmax, TempRes=Tmaxr, ProbPrec=ProbPrecj, VentDir=Vdirj, VentForce=Vforcej, VentRafales=Vrafalesj, Uv=UV, ProbOrage=ProbOragesj, NivPrec=Precj, QPluie=Pluiej, QNeige=Neigej, EVerglas=Verglasj }, { Icone=iconen, CondMeteo=Descriptifn, Temp=Tmin, TempRes=Tminr, ProbPrec=ProbPrecn, VentDir=Vdirn, VentForce=Vforcen, VentRafales=Vrafalesn, ProbOrage=ProbOragesn, NivPrec=Precn, QPluie=Pluien, QNeige=Neigen, EVerglas=Verglasn }, { Jour=Datej, LeverSoleil=LeverSoleil, LeverSoleilH=LeverSoleilH, LeverSoleilM=LeverSoleilM, CoucherSoleil=CoucherSoleil, CoucherSoleilH=CoucherSoleilH, CoucherSoleilM=CoucherSoleilM, Histo_Max=Histo_Max, Histo_Min=Histo_Min }

end


--Infos condition courante
function current(web)
	local f, i, line, ville, lat, lon, icone, cur, temp, tempres, directvent, vitessevent, Humidite, Pression, Couvnuageuse, UV, Pointderosee, Precipitations, Visibilite, jour, mois, annee, Date, Dbg

	f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | sed -e 's/%//g' -e '/var apgWxInfoObj/,/\"detail-now\"/d' | grep -A190 'meta'"))
	line=f:read()
	i=0
	for line in f:lines() do
		i=i+1
		if i==2 then
			ville,lat,lon=line:match("city: '([%w%s%-]*)'[%s%w%p]*lat: '([%d%p]*)'[%s%w%p]*lon: '([%d%p]*)'")
		elseif i==5 then
			icone=line:match("icon i%p(%a*)\">")
		elseif i==6 then
			cur, temp, tempres=line:formatage():match("cond\">([%a%p%s"..pat.."]*)</[%a%p%s]*temp\">([%p%d]*)<s[%w%p%s]*; ([%p%d]*)<s")
		elseif i==22 then
			directvent=line:gsub("W","O"):match("'(%a*)'")
		elseif i==23 then
			vitessevent=line:match("'(%d*)[%a%p]*'")
		elseif i==34 then
			Humidite=line:match("g>(%d*)</s")
		elseif i==35 then
			Pression=line:match("g>(%d*).")
		elseif i==36 then
			UV=line:match("g>(%d*)</s")
		elseif i==37 then
			Couvnuageuse=line:match("g>(%d*)</s")
		elseif i==39 then
			Pointderosee=line:match("g>([%p%d]*)&#176")
		elseif i==40 then
			Visibilite=line:match("g>(%d*) ")
		elseif i==181 then
			jour, mois, annee=line:match(">[%a%d%p%s]* (%d*)/(%d*)/(%d*)<")
		end
	end
	f:close()

	Date = os.time{year=annee, month=mois, day=jour, hour=0}

	return {Icone=icone, Cond=cur, Temp=temp, Tempr=tempres, VentDir=directvent, VentForce=vitessevent, Humidite=Humidite, Pression=Pression, CouvNuage=Couvnuageuse, Uv=UV, PointRosee=Pointderosee, Visibilite=Visibilite, Date=Date, Ville=ville, latitude=lat, longitude=lon}

end


--Infos lunaison
function lunaison(r)
	local s, web, Lune
	
	web="http://www.calendrier-lunaire.net/"

	f=assert(io.popen("curl --max-time 60 --retry 3 --silent '"..web.."' | grep -A53 'ephemerides\"' | sed 's/%//g'"))
	line=f:read()
	i=0
	for line in f:lines() do
		i=i+1
		if i==3 then
			icone=line:match("src=\"([%w%p]*)\"")
		elseif i==7 then
			ephemerides1, ephemerides2=line:formatage():match(">(%a*)</span> (%a*)<")
		elseif i==11 then
			Visibilite=line:match("\">([%d%p]*) <")
		elseif i==12 then
			Phases, Phases1, Phases2=line:formatage():match("\">(([%a%p%d"..pat.."]*),%s*([%a%p%d"..pat.."]*))</s")
		elseif i==13 then
			Noeud_lunaire=line:match("\">([%a%d%p%s]*)</s")
		elseif i==14 then
			Apogee=line:match("\">([%a%d%p%s]*)</s")
		elseif i==15 then
			Perigee=line:match("\">([%a%d%p%s]*)</s")
		elseif i==16 then
			Distance=line:match("\">(%d*) %a*</s")
		elseif i==18 then
			Age=line:match("\">([%a%d%s]*)</")
		elseif i==19 then
			Lever_LuneHeure, Lever_LuneMinute, Coucher_LuneHeure, Coucher_LuneMinute=line:match("\">([%d%p]*):([%d%p]*)</span>[%a%p%s]*;\">([%d%p]*):([%d%p]*)</")
		elseif i==48 then
			Eclipse_partielle=line:match("\">([%w%s]* <br /> [%d%p]*)</a>")
		elseif i==49 then
			Eclipse_total=line:match("\">([%w%s]* <br /> [%d%p]*)</a>")
		end
	end
	f:close()	if Noeud_lunaire:match("(%d+)") ~= nil then Noeud_lunaire = Noeud_lunaire:match("(%d+)") end

	if Apogee:match("(%d+)") ~= nil then Apogee = Apogee:match("(%d+)") end
	if Perigee:match("(%d+)") ~= nil then Perigee = Perigee:match("(%d+)") end
	ephemerides = ephemerides1.." "..ephemerides2	
	Eclipse_partielle = datelune(Eclipse_partielle)
	Eclipse_total = datelune(Eclipse_total)
	s = "${exec wget --tries=3 -q -O "..r.."/lune.png http://www.calendrier-lunaire.net/"..icone.."}"
	conky_parse( s )
	conky_parse( "${exec convert "..r.."/lune.png -transparent '#091a2a' "..r.."/lune.png}" )

end

function datelune(d)
	local j, m, a, h, min = d:gsub("Janvier", "01"):gsub("Février", "02"):gsub("Mars", "03"):gsub("Avril", "04"):gsub("Mais", "05"):gsub("Juin", "06"):gsub("Juillet", "07"):gsub("Août", "08"):gsub("septembre", "09"):gsub("Octobre", "10"):gsub("Novembre", "11"):gsub("Décembre", "12"):match("(%d+) (%d+) (%d+) <br /> (%d+):(%d+)")
	d = os.time{year=a, month=m, day=j, hour=h, min=min}

	return d
	
end


--Détermine icône vent
function direction_vent(i)

	if i == "Calme" then
		return 0
	elseif i == "N" then
		return 10
	elseif i == "NNE" then
		return 11
	elseif i == "NE" then
		return 12
	elseif i == "ENE" then
		return 13
	elseif i == "E" then
		return 14
	elseif i == "ESE" then
		return 15
	elseif i == "SE" then
		return 16
	elseif i == "SSE" then
		return 17
	elseif i == "S" then
		return 2
	elseif i == "SSO" then
		return 3
	elseif i == "SO" then
		return 4
	elseif i == "OSO" then
		return 5
	elseif i == "O" then
		return 6
	elseif i == "ONO" then
		return 7
	elseif i == "NO" then
		return 8
	elseif i == "NNO" then
		return 9
	else
		return 1
	end

end


--Renvoi vent direction pleine en toute lettre
function vent_plein(d)

	local b

	if string.len(d) == 1 then
		if string.find(d, "N") ~= nil then 
			b = string.gsub(d, "N", "Nord") 
		elseif string.find(d, "S") ~= nil then 
			b = string.gsub(d, "S", "Sud") 
		elseif string.find(d, "E") ~= nil then
			b = string.gsub(d, "E", "Est") 
		elseif string.find(d, "O") ~= nil then
			b = string.gsub(d, "O", "Ouest")
		end
	else
		b = d
	end

	return b

end


--Détermine l'icône vent en tenant conte de la force du vent
function icone_vent(d, fo)

	local f = tonumber(fo)
	local n

	if f <= Palier then
		n = d
	elseif f <= Palier*2 then
		n = d + 17
	elseif f <= Palier*3 then
		n = d + 34
	elseif f >= (Palier*3)+1 then
		n = d + 51
	end

	if n <= 9 then 
		n = "0"..n
	end

	return n..".png"

end


--Découpage descriptions sur deux lignes
function decoupage(d)

	local l1, l2, n, p1, p2, n1, n2, l1b, l2b, dm, dp
	if string.len(d) >= 22 then
		n = math.ceil(string.len(d)/2)
		dm = string.sub(d, 1, n)
		dp = string.sub(d, n)
		p1 = string.find(dp, " ")
		local b = 1
		p2 = nil
		if string.find(dm, ' ') then
			while p2 == nil do
				b = b+1
				p2 = string.find(dm, ' ', -b)
			end
		end
		if p1 ~= nil then p1 = n+p1-1 end
		
		if p1 == nil and p2 == nil then p1 = string.find(d, " ") end
		if p2 == nil then p2 = p1 end
		if p1 == nil then p1 = p2 end
		if p1-n >= n-p2 then
			l1b = string.sub(d, 1, p2-1)
			l2b = string.sub(d, p2+1)
		else
			l1b = string.sub(d, 1, p1-1)
			l2b = string.sub(d, p1+1)
		end
	else
		l1b = d
		l2b = " "
	end
	n1 = math.ceil((22 - string.len(l1b))/2)
	l1 = string.rep(" ", n1)..l1b 
	n2 = math.ceil((22 - string.len(l2b))/2)
	l2 = string.rep(" ", n2)..l2b 

--Retour information avec espaces ligne 1 & 2 et sans espaces ligne 1 & 2
	return l1, l2, l1b, l2b

end


--Information Matin
function Prevision_Matin(a, j, x)
	local i = j+x
	conditionMatin[j] = Prevision_Quart_T(a..'?day='..i)
	
	local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"}
		
	local donee = {}
	donee = conditionMatin[j]
	for i = 1,15 do
		if donee[t[i]] == nil then
			local file = assert(io.open(repsauv.."/Debug", "a+"))
			file:write ("\n", Debug, "conditionMatin ", t[i]," jour n° ", j)
			donee[t[i]]="N/A"
		end
	end
	conditionMatin[j]=donee
	
	if conditionMatin[j].VentDir == "CLM" then
		conditionMatin[j].VentDir = "Calme"
		conditionMatin[j].VentForce = "0"
	end
	conditionMatin[j].VentIcone = icone_vent(direction_vent(conditionMatin[j].VentDir), conditionMatin[j].VentForce)
	conditionMatin[j].VentP = vent_plein(conditionMatin[j].VentDir)
	conditionMatin[j].CondMeteo1, conditionMatin[j].CondMeteo2, conditionMatin[j].CondMeteo1se, conditionMatin[j].CondMeteo2se = decoupage(conditionMatin[j].CondMeteo)
	print("Matin "..j.." Ok")
end


--Information Après-midi
function Prevision_AM(a, j, x)
	local i = j+x
	conditionAM[j] = Prevision_Quart_T(a..'?day='..i)
	
	local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"}
		
	local donee = {}
	donee = conditionAM[j]
	for i = 1,15 do
		if donee[t[i]] == nil then
			local file = assert(io.open(repsauv.."/Debug", "a+"))
			file:write ("\n", Debug, "conditionAM ", t[i]," jour n° ", j)
			donee[t[i]]="N/A"
		end
	end
	conditionAM[j]=donee

	if conditionAM[j].VentDir == "CLM" then
		conditionAM[j].VentDir = "Calme"
		conditionAM[j].VentForce = "0"
	end
	conditionAM[j].VentIcone = icone_vent(direction_vent(conditionAM[j].VentDir), conditionAM[j].VentForce)
	conditionAM[j].VentP = vent_plein(conditionAM[j].VentDir)
	conditionAM[j].CondMeteo1, conditionAM[j].CondMeteo2, conditionAM[j].CondMeteo1se, conditionAM[j].CondMeteo2se = decoupage(conditionAM[j].CondMeteo)
	print("Apres Midi "..j.." Ok")
end


--Information Soirée
function Prevision_Soiree(a, j, x)
	local i = j+x
	conditionSoiree[j] = Prevision_Quart_T(a..'?day='..i)
	
	local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"}
		
	local donee = {}
	donee = conditionSoiree[j]
	for i = 1,15 do
		if donee[t[i]] == nil then
			local file = assert(io.open(repsauv.."/Debug", "a+"))
			file:write ("\n", Debug, "conditionSoiree ", t[i]," jour n° ", j)
			donee[t[i]]="N/A"
		end
	end
	conditionSoiree[j]=donee

	if conditionSoiree[j].VentDir == "CLM" then
		conditionSoiree[j].VentDir = "Calme"
		conditionSoiree[j].VentForce = "0"
	end
	conditionSoiree[j].VentIcone = icone_vent(direction_vent(conditionSoiree[j].VentDir), conditionSoiree[j].VentForce)
	conditionSoiree[j].VentP = vent_plein(conditionSoiree[j].VentDir)
	conditionSoiree[j].CondMeteo1, conditionSoiree[j].CondMeteo2, conditionSoiree[j].CondMeteo1se, conditionSoiree[j].CondMeteo2se = decoupage(conditionSoiree[j].CondMeteo)
	print("Soiree "..j.." Ok")
end


--Information Nuit
function Prevision_Nuit(a, j, x)
	local i = j+x
	conditionNoct[j] = Prevision_Quart_T(a..'?day='..i)
	
	local t = {"Icone", "CondMeteo", "TempMax", "TempMin", "TempMaxR", "TempMinR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "ProbPrec", "Visibilite", "QNeige", "QPluie"}
		
	local donee = {}
	donee = conditionNoct[j]
	for i = 1,15 do
		if donee[t[i]] == nil then
			local file = assert(io.open(repsauv.."/Debug", "a+"))
			file:write ("\n", Debug, "conditionNoct ", t[i]," jour n° ", j)
			donee[t[i]]="N/A"
		end
	end
	conditionNoct[j]=donee

	if conditionNoct[j].VentDir == "CLM" then
		conditionNoct[j].VentDir = "Calme"
		conditionNoct[j].VentForce = "0"
	end
	conditionNoct[j].VentIcone = icone_vent(direction_vent(conditionNoct[j].VentDir), conditionNoct[j].VentForce)
	conditionNoct[j].VentP = vent_plein(conditionNoct[j].VentDir)
	conditionNoct[j].CondMeteo1, conditionNoct[j].CondMeteo2, conditionNoct[j].CondMeteo1se, conditionNoct[j].CondMeteo2se = decoupage(conditionNoct[j].CondMeteo)
	print("Nuit "..j.." Ok")
end

--Information Huit heures
function Prevision_Huit_Heures(a)
	Huit_Heures(a)
	
	
	print("Huit prochaines heures Ok")

end 

--Traitement infos prévisions (15 jours max) jour 1 = aujourd'hui
function jour_n(a, j, x)

	local i = j+x
	conditionJour[j], conditionNuit[j], InfoJour[j] = prevision(a..'?day='..i)

	local t = { "Icone", "CondMeteo", "Temp", "TempRes", "ProbPrec", "VentDir", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "EVerglas" }
	local donee = {}
	donee = conditionJour[j]
	for i = 1,14 do
		if donee[t[i]] == nil then
			local file = assert(io.open(repsauv.."/Debug", "a+"))
			file:write ("\n", Debug, "conditionJour ", t[i]," jour n° ", j)
			donee[t[i]]="N/A"
		end
	end
	conditionJour[j]=donee
	
	local t = { "Icone", "CondMeteo", "Temp", "TempRes", "ProbPrec", "VentDir", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "EVerglas" }
	donee = conditionNuit[j]
	for i = 1,13 do
		if donee[t[i]] == nil then
			local file = assert(io.open(repsauv.."/Debug", "a+"))
			file:write ("\n", Debug, "conditionNuit ", t[i]," jour n° ", j)
			donee[t[i]]="N/A"
		end
	end
	conditionNuit[j]=donee
	
	local t = { "Jour", "LeverSoleil", "LeverSoleilH", "LeverSoleilM", "CoucherSoleil", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min" }
	donee = InfoJour[j]
	for i = 1,9 do
		if donee[t[i]] == nil then
			local file = assert(io.open(repsauv.."/Debug", "a+"))
			file:write ("\n", Debug, "InfoJour ", t[i]," jour n° ", j)
			donee[t[i]]="N/A"
		end
	end
	InfoJour[j]=donee

	if conditionJour[j].VentDir == "CLM" then
		conditionJour[j].VentDir = "Calme"
		conditionJour[j].VentForce = "0"
	end
	conditionJour[j].VentIcone = icone_vent(direction_vent(conditionJour[j].VentDir), conditionJour[j].VentForce)
	conditionJour[j].RafalesIcone = icone_vent(direction_vent(conditionJour[j].VentDir), conditionJour[j].VentRafales)
	conditionJour[j].VentP = vent_plein(conditionJour[j].VentDir)
	conditionJour[j].CondMeteo1, conditionJour[j].CondMeteo2, conditionJour[j].CondMeteo1se, conditionJour[j].CondMeteo2se = decoupage(conditionJour[j].CondMeteo)

	if conditionNuit[j].VentDir == "Calme" then
		conditionNuit[j].VentForce = "0"
	end
	conditionNuit[j].VentIcone = icone_vent(direction_vent(conditionNuit[j].VentDir), conditionNuit[j].VentForce)
	conditionNuit[j].RafalesIcone = icone_vent(direction_vent(conditionNuit[j].VentDir), conditionNuit[j].VentRafales)
	conditionNuit[j].VentP = vent_plein(conditionNuit[j].VentDir)
	conditionNuit[j].CondMeteo1, conditionNuit[j].CondMeteo2, conditionNuit[j].CondMeteo1se, conditionNuit[j].CondMeteo2se = decoupage(conditionNuit[j].CondMeteo)
	print("Prévision "..j.." Ok")

end

--initialisation paramètres
function conky_init(cfg)

	local cmd1, pos1
	local home = os.getenv("HOME")
	cfg = string.gsub(cfg, "~", home)
	cfg = string.gsub(cfg, "$HOME", home)
	fichier_init = cfg
	
	local file = assert(io.open(cfg, "rb") )
	local line = file:read()
	for line in file:lines() do
		pos1 = string.find(line, '#')
		if pos1 ~= nil then
			line = string.sub(line, 1, pos1-1)
		end
		pos1 = string.find(line, '=')
		if string.find(line, 'repsauv=') ~= nil then
			repsauv = string.sub(line, pos1+1)
		elseif string.find(line, 'TempShell=') ~= nil then
			r = string.sub(line, pos1+1)
		elseif string.find(line, 'web=') ~= nil then
			cmd1 = string.sub(line, pos1+1)
		elseif string.find(line, 'periode=') ~= nil then
			jours = string.sub(line, pos1+1)
		elseif string.find(line, 'matinée=') ~= nil then
			matin = string.sub(line, pos1+1)
		elseif string.find(line, 'am=') ~= nil then
			apresmidi = string.sub(line, pos1+1)
		elseif string.find(line, 'soiree=') ~= nil then
			soiree = string.sub(line, pos1+1)
		elseif string.find(line, 'nuit=') ~= nil then
			nuit = string.sub(line, pos1+1)
		elseif string.find(line, 'Prev8heures=') ~= nil then
			huit = string.sub(line, pos1+1)
		elseif string.find(line, 'Palier=') ~= nil then
			Palier = tonumber(string.sub(line, pos1+1))
		elseif string.find(line, 'update=') ~= nil then
			delais = string.sub(line, pos1+1)
		end
	end
	io.close(file)	
	r = r:gsub("~", home):gsub("$HOME", home)
	repsauv = repsauv:gsub("~", home):gsub("$HOME", home)
	VilleAdresse=string.match(cmd1, ".com/%a*/%a*/([%w%p%s]*)/%d*/%a*")
	
print("", "version = "..Version.."\n", "web = "..cmd1.."\n", "Pévision Nb jours = "..jours.."\n", "Pévision Matin = "..matin.."\n", "Pévision Après Midi = "..apresmidi.."\n", "Pévision Soirée = "..soiree.."\n", "Pévision Nuit = "..nuit.."\n","Prévision sur 8 heures = "..huit.."\n", "Délais = "..delais.."\n", "Chemin de travail = "..r.."\n","Palier = "..Palier.."\n", "Chemin de sauvegarde = "..repsauv)

--Création répertoire de travail
	l = cmd1:match("/(%d+)")
	if string.find(cmd1, 'forecast') ~= nil then
		pos1 = string.find(cmd1, '/weather')
		cmd = string.sub(cmd1, 0, pos1-1)
	else
		pos1 = string.find(cmd1, '/current')
		cmd = string.sub(cmd1, 0, pos1-1)
	end

	local bar, bar1
	local l1 = string.gsub(cmd, '/'..l, "" )
	local b = 1
	while bar1 == nil do
		b = b+1
		bar1 = string.find(l1, '/', -b)
	end
	l1 = string.sub(l1, bar1+1)
	Rep = r.."/"..l1.."/"..l
	if os.execute("cd "..Rep) ~= 0 then
		os.execute("mkdir "..r.."/"..l1.."&& mkdir "..Rep)
	end
	
--initialisation compteurs
	t = os.time()-delais
	tc = t
	start = 1
	
--Vérification existence repsauv

	if os.execute("cd "..repsauv) ~= 0 then
--création de repsauv si inexistant
		local pos1 = 1
		local chemin = nil
		local cheminsup = nil
		while pos1 ~= nil do
			pos1 = string.find(repsauv, '/', pos1+1)
			if pos1 ~= nil then
				cheminsup = string.sub(repsauv, pos1)
				chemin = string.gsub(repsauv, cheminsup, "")
			else
				cheminsup = ""
				chemin = repsauv
			end
			if os.execute("cd "..chemin) ~= 0 then
				os.execute("mkdir "..chemin)
			end
		end
	end
	
	if not existe(repsauv.."/CondCour") then
		conky_Meteo_enligne()
	end
	
	MAJ ="0"
	
end

--Mise à jour météo
function conky_Meteo_Maj()

	local s = '${if_gw}${lua conky_Meteo_enligne}${else}${lua conky_Meteo_horsligne}${endif}'
	conky_parse( s )
	return " "
end

--hors ligne récupération de données
function conky_Meteo_horsligne()

	if dermodif == nil or dermodif ~= conky_parse("${exec date -r "..repsauv.."/CondCour '+%s'}") then
		dermodif=conky_parse("${exec date -r "..repsauv.."/CondCour '+%s'}")
--Récupération dernière condition courante
		local file = assert(io.open(repsauv.."/CondCour", "r") )
		local line = file:read()
		local i = 0
		local donee = {}
		for line in file:lines() do
			i = i+1
			donee[i] = line
		end
		local t = {"Icone", "Tempr", "Temp", "Cond", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "VentDir", "VentPlein", "VentForce", "VentIcone", "Humidite", "PointRosee", "Pression", "Visibilite", "Date", "Ville", "CouvNuage", "Uv", "QPrec", "latitude", "longitude"}
		for i = 1,23 do
			conditioncourante[t[i]] = donee[i]
		end
		time = donee[24]
		io.close(file)
		
--Récupération prévision
		
		for j = 1,jours do
			local file = assert(io.open(repsauv.."/prevision"..j, "r"))
			local line = file:read()
			local i = 0
			local donee = {}
			for line in file:lines() do
				i = i+1
				donee[i] = line
			end
			local info = {}
			local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"}
			conditionJour[j] = {}
			for i = 1, 21 do
				info[t[i]] = donee[i]
			end
			conditionJour[j] = info
			local info1 = {}
			t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"}
			conditionNuit[j] = {}
			for i = 22, 41 do
				info1[t[i-21]] = donee[i]
			end
			conditionNuit[j] = info1
			local info2 = {}
			t= {"Jour", "LeverSoleilH", "LeverSoleilM", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min"}
			InfoJour[j] = {}
			for i = 42, 48 do
				info2[t[i-41]] = donee[i]
			end
			InfoJour[j] = info2
			io.close(file)
			
			if matin == "oui" then
				local file = assert(io.open(repsauv.."/matin"..j, "r"))
				local line = file:read()
				local i = 0
				local donee = {}
				for line in file:lines() do
					i = i+1
					donee[i] = line
				end
				local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
				conditionMatin[j] = {}
				local info3 = {}
				for i = 1, 21 do
					info3[t[i]] = donee[i]
				end
				conditionMatin[j] = info3
				io.close(file)
			end

			if apresmidi == "oui" then
				local file = assert(io.open(repsauv.."/ApresMidi"..j, "r"))
				local line = file:read()
				local i = 0
				local donee = {}
				for line in file:lines() do
					i = i+1
					donee[i] = line
				end
				local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
				conditionAM[j] = {}
				local info3 = {}
				for i = 1, 21 do
					info3[t[i]] = donee[i]
				end
				conditionAM[j] = info3
				io.close(file)
			end

			if soiree == "oui" then
				local file = assert(io.open(repsauv.."/Soiree"..j, "r"))
				local line = file:read()
				local i = 0
				local donee = {}
				for line in file:lines() do
					i = i+1
					donee[i] = line
				end
				local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
				conditionSoiree[j] = {}
				local info3 = {}
				for i = 1, 21 do
					info3[t[i]] = donee[i]
				end
				conditionSoiree[j] = info3
				io.close(file)
			end

			if nuit == "oui" then
				local file = assert(io.open(repsauv.."/Nuit"..j, "r"))
				local line = file:read()
				local i = 0
				local donee = {}
				for line in file:lines() do
					i = i+1
					donee[i] = line
				end
				local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
				conditionNoct[j] = {}
				local info3 = {}
				for i = 1, 21 do
					info3[t[i]] = donee[i]
				end
				conditionNoct[j] = info3
				io.close(file)
			end
		end
		
		if huit == "oui" then
			for j = 1,8 do
				local file = assert(io.open(repsauv.."/huitHeures"..j, "r"))
				local line = file:read()
				local i = 0
				local donee = {}
				for line in file:lines() do
					i = i+1
					donee[i] = line
				end
				local t = {"Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas", "VentP", "VentIcone"}
				huitHeures[j] = {}
				local info3 = {}
				for i = 1, 15 do
					info3[t[i]] = donee[i]
				end
				huitHeures[j] = info3
				io.close(file)
			end
		end			


--Récupération lunaison
		local file = assert(io.open(repsauv.."/lunaison", "r"))
		local line = file:read()
		local i = 0
		local donee = {}
		for line in file:lines() do
			i = i+1
			donee[i] = line
		end
		ephemerides = donee[1]
		ephemerides1 = donee[2]
		ephemerides2 = donee[3]
		Visibilite = donee[4]
		Phases = donee[5]
		Phases1 = donee[6]
		Phases2 = donee[7]
		Noeud_lunaire = donee[8]
		Apogee = donee[9]
		Perigee = donee[10]
		Distance = donee[11]
		Age = donee[12]
		Lever_LuneHeure = donee[13]
		Lever_LuneMinute = donee[14]
		Coucher_LuneHeure = donee[15]
		Coucher_LuneMinute = donee[16]
		Eclipse_partielle = donee[17]
		Eclipse_total = donee[18]
		io.close(file)

		
		if MAJ == "0" then
			MAJ = "1"
		else
			MAJ = "0"
		end

		
		collectgarbage()
	end
	return ""
end

--en ligne mise à jour
function conky_Meteo_enligne()
	local i
	if tonumber(delais) <= os.difftime(os.time(), t) then
		t = os.time()
		time = t

			conditioncourante.Date = nil
			while conditioncourante.Date == nil do

				conditioncourante = current(cmd..'/current-weather/'..l)
				
					local y = {"Icone", "Cond", "Temp", "Tempr", "VentDir", "VentForce", "Humidite", "Pression", "CouvNuage", "Uv", "PointRosee", "Visibilite", "Ville", "latitude","Date", "longitude"}
					local donee = conditioncourante
					
					for i = 1,16 do
						if donee[y[i]] == nil then
							local file = assert(io.open(repsauv.."/Debug", "a+"))
							file:write ("\n", Debug, "conditioncourante ", y[i])
							donee[y[i]]="N/A"
						end
					end
					conditioncourante=donee

				if conditioncourante.VentDir == "CLM" then
					conditioncourante.VentDir = "Calme"
					conditioncourante.VentForce = "0"
				end
				if conditioncourante.Ville == "" then
					conditioncourante.Ville = VilleAdresse
				end
				conditioncourante.VentIcone = icone_vent(direction_vent(conditioncourante.VentDir), conditioncourante.VentForce)
				conditioncourante.VentPlein = vent_plein(conditioncourante.VentDir)
				conditioncourante.CondMeteo1, conditioncourante.CondMeteo2, conditioncourante.CondMeteo1se, conditioncourante.CondMeteo2se = decoupage(conditioncourante.Cond)
				print("Condition courante Ok")

				if 14400 <= os.difftime(os.time(), tc) or start == 1 then
					start = 2
					tc = t

					local addr_week = cmd..'/daily-weather-forecast/'..l
					jour_n(addr_week, 1, 0)

					if conditioncourante.Date == InfoJour[1].Jour then
						for i = 2,jours do jour_n(addr_week, i, 0) end
					else
						for i = 1,jours do jour_n(addr_week, i, 1) end
					end

--infos matin si demandée
					if matin == "oui" then
						addr_week = cmd..'/morning-weather-forecast/'..l

						if conditioncourante.Date == InfoJour[1].Jour then
							for i = 1,jours do Prevision_Matin(addr_week, i, 0) end
						else
							for i = 1,jours do Prevision_Matin(addr_week, i, 1) end
						end
					end

--infos Après Midi si demandée
					if apresmidi == "oui" then
						addr_week = cmd..'/afternoon-weather-forecast/'..l

						if conditioncourante.Date == InfoJour[1].Jour then
							for i = 1,jours do Prevision_AM(addr_week, i, 0) end
						else
							for i = 1,jours do Prevision_AM(addr_week, i, 1) end
						end
					end

--infos Soirée si demandée
					if soiree == "oui" then
						addr_week = cmd..'/evening-weather-forecast/'..l

						if conditioncourante.Date == InfoJour[1].Jour then
							for i = 1,jours do Prevision_Soiree(addr_week, i, 0) end
						else
							for i = 1,jours do Prevision_Soiree(addr_week, i, 1) end
						end
					end

--infos Nuit si demandée
					if nuit == "oui" then
						addr_week = cmd..'/overnight-weather-forecast/'..l

						if conditioncourante.Date == InfoJour[1].Jour then
							for i = 1,jours do Prevision_Nuit(addr_week, i, 0) end
						else
							for i = 1,jours do Prevision_Nuit(addr_week, i, 1) end
						end
					end
					
				end -- fin mise à jour compète
			end
			
			if huit == "oui" then
				addr_week = cmd..'/hourly-weather-forecast/'..l
				Prevision_Huit_Heures(addr_week)
			end
			
			lunaison(r)
			print("lunaison Ok")
--lancement sauvegarde
		if repsauv ~= nil then
			sauvegarde()
		end
		
		
		if MAJ == "0" then
			MAJ = "1"
		else
			MAJ = "0"
		end

		
		collectgarbage()
		print(os.difftime(os.time(), t).." seconde(s)")
	end
	return " "
end


--Retour d'information météo

--Condition courrante

function conky_Meteo_IconeM(r, p, s, f)
	if os.date("%H%M", os.time()) <= InfoJour[1].CoucherSoleilH..InfoJour[1].CoucherSoleilM and os.date("%H%M", os.time()) >= InfoJour[1].LeverSoleilH..InfoJour[1].LeverSoleilM then
		return "${image "..r.."/jour/"..conditioncourante.Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
	else
		return "${image "..r.."/nuit/"..conditioncourante.Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
	end
end

function conky_Meteo_TempRes()
	return conditioncourante.Tempr
end

function conky_Meteo_TempAct()
	return conditioncourante.Temp
end

function conky_Meteo_CondMeteo()
	return conditioncourante.Cond
end

function conky_Meteo_CondMeteo1()
	return conditioncourante.CondMeteo1
end

function conky_Meteo_CondMeteo2()
	return conditioncourante.CondMeteo2
end

function conky_Meteo_CondMeteo1se()
	return conditioncourante.CondMeteo1se
end

function conky_Meteo_CondMeteo2se()
	return conditioncourante.CondMeteo2se
end

function conky_Meteo_VentDir()
	return conditioncourante.VentDir
end

function conky_Meteo_VentDirP()
	return conditioncourante.VentPlein
end

function conky_Meteo_VentForce()
	return conditioncourante.VentForce
end

function conky_Meteo_IconeV(r, p, s, f)
	return "${image "..r.."/"..conditioncourante.VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_Humidite()
	return tonumber(conditioncourante.Humidite)
end

function conky_Meteo_Rose()
	return tonumber(conditioncourante.PointRosee)
end

function conky_Meteo_Pression()
	return tonumber(conditioncourante.Pression)
end

function conky_Meteo_Visibilite()
	return tonumber(conditioncourante.Visibilite)
end

function conky_Meteo_Date(format)
	format = string.gsub(format, "_", " ")
	return trad_date(os.date(format, conditioncourante.Date))
end

function conky_Meteo_Ville()
	return conditioncourante.Ville
end

function conky_Meteo_CouvNuage()
	return tonumber(conditioncourante.CouvNuage)
end

function conky_Meteo_Uv()
	return conditioncourante.Uv
end

function conky_Meteo_latitude()
	return conditioncourante.latitude
end

function conky_Meteo_longitude()
	return conditioncourante.longitude
end

function conky_Meteo_Heure()
	return os.date("%H", time)
end

function conky_Meteo_Minute()
	return os.date("%M", time)
end


--Prévision Météo

--Jour

function conky_Meteo_Jour_CondMeteo(j)
	return conditionJour[tonumber(j)].CondMeteo
end

function conky_Meteo_Jour_CondMeteo1(j)
	return conditionJour[tonumber(j)].CondMeteo1
end

function conky_Meteo_Jour_CondMeteo2(j)
	return conditionJour[tonumber(j)].CondMeteo2
end

function conky_Meteo_Jour_CondMeteo1se(j)
	return conditionJour[tonumber(j)].CondMeteo1se
end

function conky_Meteo_Jour_CondMeteo2se(j)
	return conditionJour[tonumber(j)].CondMeteo2se
end

function conky_Meteo_Jour_Temp(j)
	return tonumber(conditionJour[tonumber(j)].Temp)
end

function conky_Meteo_Jour_TempRes(j)
	return tonumber(conditionJour[tonumber(j)].TempRes)
end

function conky_Meteo_Jour_ProbPrec(j)
	return tonumber(conditionJour[tonumber(j)].ProbPrec)
end

function conky_Meteo_Jour_VentDir(j)
	return conditionJour[tonumber(j)].VentDir
end

function conky_Meteo_Jour_VentDirP(j)
	return conditionJour[tonumber(j)].VentP
end

function conky_Meteo_Jour_VentForce(j)
	return tonumber(conditionJour[tonumber(j)].VentForce)
end

function conky_Meteo_Jour_VentRafales(j)
	return tonumber(conditionJour[tonumber(j)].VentRafales)
end

function conky_Meteo_Jour_Uv(j)
	return tonumber(conditionJour[tonumber(j)].Uv)
end

function conky_Meteo_Jour_ProbOrage(j)
	return tonumber(conditionJour[tonumber(j)].ProbOrage)
end

function conky_Meteo_Jour_NivPrec(j)
	return tonumber(conditionJour[tonumber(j)].NivPrec)
end

function conky_Meteo_Jour_QPluie(j)
	return tonumber(conditionJour[tonumber(j)].QPluie)
end

function conky_Meteo_Jour_QNeige(j)
	return tonumber(conditionJour[tonumber(j)].QNeige)
end

function conky_Meteo_Jour_EVerglas(j)
	return tonumber(conditionJour[tonumber(j)].EVerglas)
end

function conky_Meteo_Jour_IconeM(r, p, s, f, j)
	return "${image "..r.."/jour/"..conditionJour[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_Jour_IconeV(r, p, s, f, j)
	return "${image "..r.."/"..conditionJour[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_Jour_IconeR(r, p, s, f, j)
	return "${image "..r.."/"..conditionJour[tonumber(j)].RafalesIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end


--Nuit

function conky_Meteo_Nuit_CondMeteo(j)
	return conditionNuit[tonumber(j)].CondMeteo
end

function conky_Meteo_Nuit_CondMeteo1(j)
	return conditionNuit[tonumber(j)].CondMeteo1
end

function conky_Meteo_Nuit_CondMeteo2(j)
	return conditionNuit[tonumber(j)].CondMeteo2
end

function conky_Meteo_Nuit_CondMeteo1se(j)
	return conditionNuit[tonumber(j)].CondMeteo1se
end

function conky_Meteo_Nuit_CondMeteo2se(j)
	return conditionNuit[tonumber(j)].CondMeteo2se
end

function conky_Meteo_Nuit_Temp(j)
	return tonumber(conditionNuit[tonumber(j)].Temp)
end

function conky_Meteo_Nuit_TempRes(j)
	return tonumber(conditionNuit[tonumber(j)].TempRes)
end

function conky_Meteo_Nuit_ProbPrec(j)
	return tonumber(conditionNuit[tonumber(j)].ProbPrec)
end

function conky_Meteo_Nuit_VentDir(j)
	return conditionNuit[tonumber(j)].VentDir
end

function conky_Meteo_Nuit_VentDirP(j)
	return conditionNuit[tonumber(j)].VentP
end

function conky_Meteo_Nuit_VentForce(j)
	return tonumber(conditionNuit[tonumber(j)].VentForce)
end

function conky_Meteo_Nuit_VentRafales(j)
	return tonumber(conditionNuit[tonumber(j)].VentRafales)
end

function conky_Meteo_Nuit_ProbOrage(j)
	return tonumber(conditionNuit[tonumber(j)].ProbOrage)
end

function conky_Meteo_Nuit_NivPrec(j)
	return tonumber(conditionNuit[tonumber(j)].NivPrec)
end

function conky_Meteo_Nuit_QPluie(j)
	return tonumber(conditionNuit[tonumber(j)].QPluie)
end

function conky_Meteo_Nuit_QNeige(j)
	return tonumber(conditionNuit[tonumber(j)].QNeige)
end

function conky_Meteo_Nuit_EVerglas(j)
	return tonumber(conditionNuit[tonumber(j)].EVerglas)
end

function conky_Meteo_Nuit_IconeM(r, p, s, f, j)
	return "${image "..r.."/nuit/"..conditionNuit[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_Nuit_IconeV(r, p, s, f, j)
	return "${image "..r.."/"..conditionNuit[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_Nuit_IconeR(r, p, s, f, j)
	return "${image "..r.."/"..conditionNuit[tonumber(j)].RafalesIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end


--Infos sur la journée

function conky_Meteo_Jour(format, j)
	format = string.gsub(format, "_", " ")
	return trad_date(os.date(format, InfoJour[tonumber(j)].Jour))
end

function conky_Meteo_HLeverSoleil(j)
	return InfoJour[tonumber(j)].LeverSoleilH
end

function conky_Meteo_MLeverSoleil(j)
	return InfoJour[tonumber(j)].LeverSoleilM
end

function conky_Meteo_LeverSoleil(j)
	return tonumber((InfoJour[tonumber(j)].LeverSoleilH*60)+InfoJour[tonumber(j)].LeverSoleilM)
end

function conky_Meteo_HCoucherSoleil(j)
	return InfoJour[tonumber(j)].CoucherSoleilH
end

function conky_Meteo_MCoucherSoleil(j)
	return InfoJour[tonumber(j)].CoucherSoleilM
end

function conky_Meteo_CoucherSoleil(j)
	return tonumber((InfoJour[tonumber(j)].CoucherSoleilH*60)+InfoJour[tonumber(j)].CoucherSoleilM)
end

function conky_Meteo_HDureeJour(j)
	return InfoJour[tonumber(j)].CoucherSoleilH-InfoJour[tonumber(j)].LeverSoleilH
end

function conky_Meteo_MDureeJour(j)
	return os.date("%M", ((((InfoJour[tonumber(j)].CoucherSoleilH*3600)-3600)+(InfoJour[tonumber(j)].CoucherSoleilM*60))-(((InfoJour[tonumber(j)].LeverSoleilH*3600))+(InfoJour[tonumber(j)].LeverSoleilM*60))))
end

function conky_Meteo_Histo_Min(j)
	return InfoJour[tonumber(j)].Histo_Min
end

function conky_Meteo_Histo_Max(j)
	return InfoJour[tonumber(j)].Histo_Max
end


--Matin

function conky_Meteo_Matin_CondMeteo(j)
	return conditionMatin[tonumber(j)].CondMeteo
end

function conky_Meteo_Matin_CondMeteo1(j)
	return conditionMatin[tonumber(j)].CondMeteo1
end

function conky_Meteo_Matin_CondMeteo2(j)
	return conditionMatin[tonumber(j)].CondMeteo2
end

function conky_Meteo_Matin_CondMeteo1se(j)
	return conditionMatin[tonumber(j)].CondMeteo1se
end

function conky_Meteo_Matin_CondMeteo2se(j)
	return conditionMatin[tonumber(j)].CondMeteo2se
end

function conky_Meteo_Matin_TempMax(j)
	return tonumber(conditionMatin[tonumber(j)].TempMax)
end

function conky_Meteo_Matin_TempMin(j)
	return tonumber(conditionMatin[tonumber(j)].TempMin)
end

function conky_Meteo_Matin_TempMaxRes(j)
	return tonumber(conditionMatin[tonumber(j)].TempMaxR)
end

function conky_Meteo_Matin_TempMinRes(j)
	return tonumber(conditionMatin[tonumber(j)].TempMinR)
end

function conky_Meteo_Matin_ProbPrec(j)
	return tonumber(conditionMatin[tonumber(j)].ProbPrec)
end

function conky_Meteo_Matin_VentDir(j)
	return conditionMatin[tonumber(j)].VentDir
end

function conky_Meteo_Matin_VentDirP(j)
	return conditionMatin[tonumber(j)].VentP
end

function conky_Meteo_Matin_VentForce(j)
	return tonumber(conditionMatin[tonumber(j)].VentForce)
end

function conky_Meteo_Matin_QPluie(j)
	return tonumber(conditionMatin[tonumber(j)].QPluie)
end

function conky_Meteo_Matin_QNeige(j)
	return tonumber(conditionMatin[tonumber(j)].QNeige)
end

function conky_Meteo_Matin_Humidite(j)
	return tonumber(conditionMatin[tonumber(j)].Humidite)
end

function conky_Meteo_Matin_CouvNuage(j, r)
	if r == nil then r = 100 end
	local Couv = (tonumber(conditionMatin[tonumber(j)].CouvNuage) / 100) * r
	if Couv - math.floor(Couv) <= 0.5 then 
		Couv = math.floor(Couv)
	else
		Couv = math.ceil(Couv)
	end
	return Couv
end

function conky_Meteo_Matin_Rose(j)
	return tonumber(conditionMatin[tonumber(j)].PointRosee)
end

function conky_Meteo_Matin_Visibilite(j)
	return tonumber(conditionMatin[tonumber(j)].Visibilite)
end

function conky_Meteo_Matin_IconeM(r, p, s, f, j)
	return "${image "..r.."/jour/"..conditionMatin[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_Matin_IconeV(r, p, s, f, j)
	return "${image "..r.."/"..conditionMatin[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end


--Après Midi

function conky_Meteo_AM_CondMeteo(j)
	return conditionAM[tonumber(j)].CondMeteo
end

function conky_Meteo_AM_CondMeteo1(j)
	return conditionAM[tonumber(j)].CondMeteo1
end

function conky_Meteo_AM_CondMeteo2(j)
	return conditionAM[tonumber(j)].CondMeteo2
end

function conky_Meteo_AM_CondMeteo1se(j)
	return conditionAM[tonumber(j)].CondMeteo1se
end

function conky_Meteo_AM_CondMeteo2se(j)
	return conditionAM[tonumber(j)].CondMeteo2se
end

function conky_Meteo_AM_TempMax(j)
	return tonumber(conditionAM[tonumber(j)].TempMax)
end

function conky_Meteo_AM_TempMin(j)
	return tonumber(conditionAM[tonumber(j)].TempMin)
end

function conky_Meteo_AM_TempMaxRes(j)
	return tonumber(conditionAM[tonumber(j)].TempMaxR)
end

function conky_Meteo_AM_TempMinRes(j)
	return tonumber(conditionAM[tonumber(j)].TempMinR)
end

function conky_Meteo_AM_ProbPrec(j)
	return tonumber(conditionAM[tonumber(j)].ProbPrec)
end

function conky_Meteo_AM_VentDir(j)
	return conditionAM[tonumber(j)].VentDir
end

function conky_Meteo_AM_VentDirP(j)
	return conditionAM[tonumber(j)].VentP
end

function conky_Meteo_AM_VentForce(j)
	return tonumber(conditionAM[tonumber(j)].VentForce)
end

function conky_Meteo_AM_QPluie(j)
	return tonumber(conditionAM[tonumber(j)].QPluie)
end

function conky_Meteo_AM_QNeige(j)
	return tonumber(conditionAM[tonumber(j)].QNeige)
end

function conky_Meteo_AM_Humidite(j)
	return tonumber(conditionAM[tonumber(j)].Humidite)
end

function conky_Meteo_AM_CouvNuage(j, r)
	if r == nil then r = 100 end
	local Couv = (tonumber(conditionAM[tonumber(j)].CouvNuage) / 100) * r
	if Couv - math.floor(Couv) <= 0.5 then 
		Couv = math.floor(Couv)
	else
		Couv = math.ceil(Couv)
	end
	return Couv
end

function conky_Meteo_AM_Rose(j)
	return tonumber(conditionAM[tonumber(j)].PointRosee)
end

function conky_Meteo_AM_Visibilite(j)
	return tonumber(conditionAM[tonumber(j)].Visibilite)
end

function conky_Meteo_AM_IconeM(r, p, s, f, j)
	return "${image "..r.."/jour/"..conditionAM[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_AM_IconeV(r, p, s, f, j)
	return "${image "..r.."/"..conditionAM[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end


--Soirée

function conky_Meteo_Soiree_CondMeteo(j)
	return conditionSoiree[tonumber(j)].CondMeteo
end

function conky_Meteo_Soiree_CondMeteo1(j)
	return conditionSoiree[tonumber(j)].CondMeteo1
end

function conky_Meteo_Soiree_CondMeteo2(j)
	return conditionSoiree[tonumber(j)].CondMeteo2
end

function conky_Meteo_Soiree_CondMeteo1se(j)
	return conditionSoiree[tonumber(j)].CondMeteo1se
end

function conky_Meteo_Soiree_CondMeteo2se(j)
	return conditionSoiree[tonumber(j)].CondMeteo2se
end

function conky_Meteo_Soiree_TempMax(j)
	return tonumber(conditionSoiree[tonumber(j)].TempMax)
end

function conky_Meteo_Soiree_TempMin(j)
	return tonumber(conditionSoiree[tonumber(j)].TempMin)
end

function conky_Meteo_Soiree_TempMaxRes(j)
	return tonumber(conditionSoiree[tonumber(j)].TempMaxR)
end

function conky_Meteo_Soiree_TempMinRes(j)
	return tonumber(conditionSoiree[tonumber(j)].TempMinR)
end

function conky_Meteo_Soiree_ProbPrec(j)
	return tonumber(conditionSoiree[tonumber(j)].ProbPrec)
end

function conky_Meteo_Soiree_VentDir(j)
	return conditionSoiree[tonumber(j)].VentDir
end

function conky_Meteo_Soiree_VentDirP(j)
	return conditionSoiree[tonumber(j)].VentP
end

function conky_Meteo_Soiree_VentForce(j)
	return tonumber(conditionSoiree[tonumber(j)].VentForce)
end

function conky_Meteo_Soiree_QPluie(j)
	return tonumber(conditionSoiree[tonumber(j)].QPluie)
end

function conky_Meteo_Soiree_QNeige(j)
	return tonumber(conditionSoiree[tonumber(j)].QNeige)
end

function conky_Meteo_Soiree_Humidite(j)
	return tonumber(conditionSoiree[tonumber(j)].Humidite)
end

function conky_Meteo_Soiree_CouvNuage(j, r)
	if r == nil then r = 100 end
	local Couv = (tonumber(conditionSoiree[tonumber(j)].CouvNuage) / 100) * r
	if Couv - math.floor(Couv) <= 0.5 then 
		Couv = math.floor(Couv)
	else
		Couv = math.ceil(Couv)
	end
	return Couv
end

function conky_Meteo_Soiree_Rose(j)
	return tonumber(conditionSoiree[tonumber(j)].PointRosee)
end

function conky_Meteo_Soiree_Visibilite(j)
	return tonumber(conditionSoiree[tonumber(j)].Visibilite)
end

function conky_Meteo_Soiree_IconeM(r, p, s, f, j)
	return "${image "..r.."/jour/"..conditionSoiree[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_Soiree_IconeV(r, p, s, f, j)
	return "${image "..r.."/"..conditionSoiree[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end


--Nuit

function conky_Meteo_Noct_CondMeteo(j)
	return conditionNoct[tonumber(j)].CondMeteo
end

function conky_Meteo_Noct_CondMeteo1(j)
	return conditionNoct[tonumber(j)].CondMeteo1
end

function conky_Meteo_Noct_CondMeteo2(j)
	return conditionNoct[tonumber(j)].CondMeteo2
end

function conky_Meteo_Noct_CondMeteo1se(j)
	return conditionNoct[tonumber(j)].CondMeteo1se
end

function conky_Meteo_Noct_CondMeteo2se(j)
	return conditionNoct[tonumber(j)].CondMeteo2se
end

function conky_Meteo_Noct_TempMax(j)
	return tonumber(conditionNoct[tonumber(j)].TempMax)
end

function conky_Meteo_Noct_TempMin(j)
	return tonumber(conditionNoct[tonumber(j)].TempMin)
end

function conky_Meteo_Noct_TempMaxRes(j)
	return tonumber(conditionNoct[tonumber(j)].TempMaxR)
end

function conky_Meteo_Noct_TempMinRes(j)
	return tonumber(conditionNoct[tonumber(j)].TempMinR)
end

function conky_Meteo_Noct_ProbPrec(j)
	return tonumber(conditionNoct[tonumber(j)].ProbPrec)
end

function conky_Meteo_Noct_VentDir(j)
	return conditionNoct[tonumber(j)].VentDir
end

function conky_Meteo_Noct_VentDirP(j)
	return conditionNoct[tonumber(j)].VentP
end

function conky_Meteo_Noct_VentForce(j)
	return tonumber(conditionNoct[tonumber(j)].VentForce)
end

function conky_Meteo_Noct_QPluie(j)
	return tonumber(conditionNoct[tonumber(j)].QPluie)
end

function conky_Meteo_Noct_QNeige(j)
	return tonumber(conditionNoct[tonumber(j)].QNeige)
end

function conky_Meteo_Noct_Humidite(j)
	return tonumber(conditionNoct[tonumber(j)].Humidite)
end

function conky_Meteo_Noct_CouvNuage(j, r)
	if r == nil then r = 100 end
	local Couv = (tonumber(conditionNoct[tonumber(j)].CouvNuage) / 100) * r
	if Couv - math.floor(Couv) <= 0.5 then 
		Couv = math.floor(Couv)
	else
		Couv = math.ceil(Couv)
	end
	return Couv
end

function conky_Meteo_Noct_Rose(j)
	return tonumber(conditionNoct[tonumber(j)].PointRosee)
end

function conky_Meteo_Noct_Visibilite(j)
	return tonumber(conditionNoct[tonumber(j)].Visibilite)
end

function conky_Meteo_Noct_IconeM(r, p, s, f, j)
	return "${image "..r.."/nuit/"..conditionNoct[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_Noct_IconeV(r, p, s, f, j)
	return "${image "..r.."/"..conditionNoct[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end

--Huit prochaines heures


function conky_Meteo_huitHeures_VentDirP(j)
	return huitHeures[tonumber(j)].VentP
end

function conky_Meteo_huitHeures_IconeV(r, p, s, f, j)
	return "${image "..r.."/"..huitHeures[tonumber(j)].VentIcone.." -p "..p.." -s "..s.." -f "..f.."}"
end

function conky_Meteo_huitHeures_Heure(j)
	return tonumber(huitHeures[tonumber(j)].Heure)
end

function conky_Meteo_huitHeures_IconeM(r, p, s, f, j)
	if huitHeures[tonumber(j)].Heure <= InfoJour[1].CoucherSoleilH and huitHeures[tonumber(j)].Heure >= InfoJour[1].LeverSoleilH then
		return "${image "..r.."/jour/"..huitHeures[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
	else
		return "${image "..r.."/nuit/"..huitHeures[tonumber(j)].Icone..".png -p "..p.." -s "..s.." -f "..f.."}"
	end
end

function conky_Meteo_huitHeures_Temp(j)
	return tonumber(huitHeures[tonumber(j)].TempMax)
end

function conky_Meteo_huitHeures_TempR(j)
	return tonumber(huitHeures[tonumber(j)].TempMaxR)
end

function conky_Meteo_huitHeures_VentDir(j)
	return huitHeures[tonumber(j)].VentDir
end

function conky_Meteo_huitHeures_VentForce(j)
	return tonumber(huitHeures[tonumber(j)].VentForce)
end

function conky_Meteo_huitHeures_Humidite(j)
	return tonumber(huitHeures[tonumber(j)].Humidite)
end

function conky_Meteo_huitHeures_CouvNuage(j)
	return tonumber(huitHeures[tonumber(j)].CouvNuage)
end

function conky_Meteo_huitHeures_Rose(j)
	return tonumber(huitHeures[tonumber(j)].PointRosee)
end

function conky_Meteo_huitHeures_ProbPluie(j)
	return tonumber(huitHeures[tonumber(j)].Pluie)
end

function conky_Meteo_huitHeures_ProbNeige(j)
	return tonumber(huitHeures[tonumber(j)].Neige)
end

function conky_Meteo_huitHeures_ProbVerglas(j)
	return tonumber(huitHeures[tonumber(j)].Verglas)
end

function conky_Meteo_huitHeures_Uv(j)
	return tonumber(huitHeures[tonumber(j)].UV)
end

--Lunaison

function conky_Lune_ephemerides()
	return ephemerides
end

function conky_Lune_ephemerides1()
	return ephemerides1
end

function conky_Lune_ephemerides2()
	return ephemerides2
end

function conky_Lune_Visibilite()
	return Visibilite
end

function conky_Lune_Phases()
	return Phases
end

function conky_Lune_Phases1()
	return Phases1
end

function conky_Lune_Phases2()
	return Phases2
end

function conky_Lune_Noeudlunaire()
	return Noeud_lunaire
end

function conky_Lune_Apogee()
	return Apogee
end

function conky_Lune_Perigee()
	return Perigee
end

function conky_Lune_Distance()
	return Distance
end

function conky_Lune_Age()
	return Age
end

function conky_Lune_HLeverLune()
	return Lever_LuneHeure
end

function conky_Lune_MLeverLune()
	return Lever_LuneMinute
end

function conky_Lune_HCoucherLune()
	return Coucher_LuneHeure
end

function conky_Lune_MCoucherLune()
	return Coucher_LuneMinute
end

function conky_Lune_EclipsePartielle(format)
	if format == nil then format = "%A_%d_%B_%Y_à_%H:%M" end
	format = string.gsub(format, "_", " ")
	return trad_date(os.date(format, Eclipse_partielle))
end

function conky_Lune_EclipseTotal()
	if format == nil then format = "%A_%d_%B_%Y_à_%H:%M" end
	format = string.gsub(format, "_", " ")
	return trad_date(os.date(format, Eclipse_total))
end


--Informations sur le lua
function conky_Version()
	return Version
end

function conky_Meteo_fichier_init()
	return fichier_init
end

function conky_Meteo_etat_MAJ()
	return MAJ
end


--Sauvegarde des données
function sauvegarde()

--sauvegarde prévision
	for j = 1,jours do
		local file = assert(io.open(repsauv.."/prevision"..j, "w+"))
		file:write ("\n")
		local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "Uv", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"}
		for i = 1, 21 do
			file:write (conditionJour[j][t[i]], "\n")
		end
		t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "Temp", "TempRes", "ProbPrec", "VentDir", "VentP", "VentForce", "VentRafales", "ProbOrage", "NivPrec", "QPluie", "QNeige", "Icone", "VentIcone", "RafalesIcone", "EVerglas"}
		for i = 1, 20 do
			file:write (conditionNuit[j][t[i]], "\n")
		end
		t= {"Jour", "LeverSoleilH", "LeverSoleilM", "CoucherSoleilH", "CoucherSoleilM", "Histo_Max", "Histo_Min"}
		for i = 1, 7 do
			file:write (InfoJour[j][t[i]], "\n")
		end
		io.close(file)

		if matin == "oui" then
			local file = assert(io.open(repsauv.."/matin"..j, "w+"))
			file:write ("\n")
			local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
			for i = 1, 21 do
				file:write (conditionMatin[j][t[i]], "\n")
			end
			io.close(file)
		end
		if apresmidi == "oui" then
			local file = assert(io.open(repsauv.."/ApresMidi"..j, "w+"))
			file:write ("\n")
			local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
			for i = 1, 21 do
				file:write (conditionAM[j][t[i]], "\n")
			end
			io.close(file)
		end
		if soiree == "oui" then
			local file = assert(io.open(repsauv.."/Soiree"..j, "w+"))
			file:write ("\n")
			local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
			for i = 1, 21 do
				file:write (conditionSoiree[j][t[i]], "\n")
			end
			io.close(file)
		end
		if nuit == "oui" then
			local file = assert(io.open(repsauv.."/Nuit"..j, "w+"))
			file:write ("\n")
			local t = {"CondMeteo", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "TempMax", "TempMin", "TempMaxR", "TempMinR", "ProbPrec", "VentDir", "VentP", "VentForce", "QPluie", "QNeige", "Humidite", "CouvNuage", "PointRosee", "Visibilite", "Icone", "VentIcone"}
			for i = 1, 21 do
				file:write (conditionNoct[j][t[i]], "\n")
			end
			io.close(file)
		end
	end

	if huit == "oui" then
		for j = 1,8 do
			local file = assert(io.open(repsauv.."/huitHeures"..j, "w+"))
			file:write ("\n")
			local t = {"Heure", "Icone", "TempMax", "TempMaxR", "VentDir", "VentForce", "Humidite", "CouvNuage", "PointRosee", "UV", "Pluie", "Neige", "Verglas", "VentP", "VentIcone"}
			for i = 1, 15 do
				file:write (huitHeures[j][t[i]], "\n")
			end
			io.close(file)
		end
	end			

--sauvegarde lunaison
	local file = assert(io.open(repsauv.."/lunaison", "w+"))
	file:write ("\n", ephemerides, "\n")
	file:write (ephemerides1, "\n")
	file:write (ephemerides2, "\n")
	file:write (Visibilite, "\n")
	file:write (Phases, "\n")
	file:write (Phases1, "\n")
	file:write (Phases2, "\n")
	file:write (Noeud_lunaire, "\n")
	file:write (Apogee, "\n")
	file:write (Perigee, "\n")
	file:write (Distance, "\n")
	file:write (Age, "\n")
	file:write (Lever_LuneHeure, "\n")
	file:write (Lever_LuneMinute, "\n")
	file:write (Coucher_LuneHeure, "\n")
	file:write (Coucher_LuneMinute, "\n")
	file:write (Eclipse_partielle, "\n")
	file:write (Eclipse_total, "\n")
	io.close(file)
	
--Sauvegarde condition courante
	local file = assert(io.open(repsauv.."/CondCour", "w+") )
	file:write ("\n")
	local t = {"Icone", "Tempr", "Temp", "Cond", "CondMeteo1", "CondMeteo2", "CondMeteo1se", "CondMeteo2se", "VentDir", "VentPlein", "VentForce", "VentIcone", "Humidite", "PointRosee", "Pression", "Visibilite", "Date", "Ville", "CouvNuage", "Uv", "latitude", "longitude"}
	for i = 1,22 do
		file:write (conditioncourante[t[i]], "\n")
	end
	file:write (time, "\n")
	io.close(file)

--modification des droits utilisateur
	os.execute('chmod o+rw- '..r..'/*lun*')
	os.execute('chmod -R o+rw- '..repsauv)
	os.execute('chmod -R o+rw- '..Rep)
end

Hors ligne

#1673 Le 05/12/2012, à 14:20

jpdipsy

Re : [Conky] Alternative à weather.com (2)

Didier-T a écrit :

voici le script corrigé.

surtout n'oublier pas de désactiver les prévisions a huit heure (trop de chose a reprendre pour le moment)

ça roule merki....

Hors ligne

#1674 Le 05/12/2012, à 15:26

ragamatrix

Re : [Conky] Alternative à weather.com (2)

jpdipsy a écrit :
Didier-T a écrit :

voici le script corrigé.

surtout n'oublier pas de désactiver les prévisions a huit heure (trop de chose a reprendre pour le moment)

ça roule merki....

Chez moi j'ai cette erreur concernant les précipitations...
désolé..

 Nuit 4 Ok
Nuit 5 Ok
Conky: llua_do_call: function conky_Meteo_enligne execution failed: /home/climatix/.conky/conky38/script/meteo.lua:620: bad argument #1 to 'len' (string expected, got nil)
Conky: llua_do_call: function conky_Meteo_QPrec execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_Meteo_QPrec execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_Meteo_QPrec execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_Meteo_ 

Hors ligne

#1675 Le 05/12/2012, à 17:23

Didier-T

Re : [Conky] Alternative à weather.com (2)

ragamatrix a écrit :
jpdipsy a écrit :
Didier-T a écrit :

voici le script corrigé.

surtout n'oublier pas de désactiver les prévisions a huit heure (trop de chose a reprendre pour le moment)

ça roule merki....

Chez moi j'ai cette erreur concernant les précipitations...
désolé..

 Nuit 4 Ok
Nuit 5 Ok
Conky: llua_do_call: function conky_Meteo_enligne execution failed: /home/climatix/.conky/conky38/script/meteo.lua:620: bad argument #1 to 'len' (string expected, got nil)
Conky: llua_do_call: function conky_Meteo_QPrec execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_Meteo_QPrec execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_Meteo_QPrec execution failed: attempt to call a nil value
Conky: llua_do_call: function conky_Meteo_ 

Et bah tien, il me semblai bien que j'avais oublié quelque chose, cette information n'existe plus. Elle est remplacé par Ceiling (plafond ???)
Donc pour le moment pas de traitement pour cette nouvelle info

Dernière modification par Didier-T (Le 05/12/2012, à 17:24)

Hors ligne