begin process at 2012 02 12 04:40:31
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Réseau & Internet

 > VDOWNLOAD - MULTIPLE TÉLÉCHARGEUR DE FICHIERS

VDOWNLOAD - MULTIPLE TÉLÉCHARGEUR DE FICHIERS


 Information sur la source

Note :
5 / 10 - par 4 personnes
5,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Réseau & Internet Niveau :Expert Date de création :17/01/2004 Vu :23 158

Auteur : Hades53

Ecrire un message privé
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

Permet de télécharger des fichiers sur Internet. Vous pouvez en télécharger simultanément autant que vous voulez. Renvoi si vous le voulez à un alias que vous avez défini les informations de progression (taille du fichier, bits copiés, pourcentage et taux de transfert) et vous informe quand un téléchargement est fini.

Source

  • ;vdownload - Créé le vendredi 16 Janvier 2004 par Had`S - Version 1.0
  • ;$vdownload(name|_,AP|_,AF|_,url,emplacement).[bin|txt]
  • ;name = Nom du téléchargement. Il est évidemment préférable de mettre des noms différents (ou de mettre _) si vous faites plusieurs téléchargement en même temps. Si vous mettez _ le nom sera généré aléatoirement. Le nom du socket sera toujours vdownload_S où S est le nom du socket défini ou le nom du socket généré aléatoirement.
  • ;AP = Alias de progression. Le snippet renvoi à l'alias que vous mettez: $1=taille total du fichier, $2=bits-copiés, $3=pourcentage, $4=taux de transfert en bits/s, si vous mettez _ alors le snippet ne renverra pas les informations de progression à un alias.
  • ;AF = Alias de fin. Le snippet exécute l'alias que vous mettez quand le téléchargement est fini.
  • ;url = adresse du fichier à télécharger sur Internet.
  • ;emplacement = emplacement où le fichier téléchargé sera enregistré.
  • ;Par défaut, le snippet analyse le type de données (binaire ou texte) du fichier à télécharger afin d'écrire avec le type de données le plus approprié au fichier. Vous pouvez forcer le snippet à écrire les données en binaire ou en texte normal en mettant comme propriété : bin (binaire)ou txt (texte normal).
  • ;/vdownload <name|wildcard> <== pour annuler un ou plusieurs téléchargements.
  • ;Exemples d'utilisation inclus à la fin du code.
  • alias vdownload {
  • ;Si l'alias a été exécuté sous la forme d'un $identifeur...
  • if ($isid) {
  • if ($0 < 5) return Manque des paramètres
  • if ($1 == _) var %u = $r(a,z) $+ $r(1,9999) $+ $r(a,z) $+ $r(a,z) $+ $r(1,99) $+ $r(a,z)
  • else { if ($sockopen(download_ $+ $1)) return Erreur! Socket déja ouvert! | var %u = $1 }
  • ;Ecriture dans la hashtable
  • if ($2 != _) hadd -m vdownload %u $+ _progs $2
  • if ($3 != _) hadd -m vdownload %u $+ _fin $3
  • hadd -m vdownload %u $+ _host $gettok($iif($mid($4,1,7) == http:// && $len($4) > 7,$mid($4,8),$4),1,47)
  • hadd vdownload %u $+ _file / $+ $gettok($iif($mid($4,1,7) == http:// && $len($4) > 7,$mid($4,8),$4),2-,47)
  • hadd vdownload %u $+ _dest $5-
  • hadd vdownload %u $+ _tm $iif($findtok(bin txt,$prop,32),$prop,auto)
  • ;Ouverture du socket
  • sockopen vdownload_ $+ %u $hget(vdownload,%u $+ _host) 80
  • return OK
  • }
  • ;L'alias a été exécuté sous la forme d'une /commande...
  • else {
  • if (!$1) goto end
  • sockclose vdownload_ $+ $1-
  • if (* !isin $1-) $iif($fopen(vdownload_ $+ $1-),.fclose vdownload_ $+ $1-) | else .fclose vdownload_ $+ $1-)
  • if ($hget(vdownload)) {
  • hdel -w vdownload $1- $+ _*
  • ;Si aucun item n'est présent dans la hashtable, autant la supprimer.
  • if (!$hget(vdownload,0).item) .hfree vdownload
  • }
  • .timervdownload_ $+ $1- off
  • }
  • :end
  • }
  • on *:sockopen:vdownload_*:{
  • var %u = $gettok($sockname,2-,95)
  • ;Vérification d'erreur..
  • if ($sockerr) { echo $color(info) Erreur ! (1) | vdownload %u | halt }
  • sockwrite -n $sockname GET $hget(vdownload,%u $+ _file) HTTP/1.0
  • sockwrite -n $sockname HOST: $hget(vdownload,%u $+ _host)
  • sockwrite -n $sockname $crlf
  • hadd vdownload %u $+ _header no
  • hadd vdownload %u $+ _prog 0 | hadd vdownload %u $+ _tt 0
  • hadd vdownload %u $+ _taux 0
  • }
  • on *:sockread:vdownload_*:{
  • var %u = $gettok($sockname,2,95)
  • if ($hget(vdownload,%u $+ _header) == no) {
  • ;Donc si on est ici, ça veut dire qu'on s'apprête à recevoir les headers, et donc des informations utiles sur le fichier..
  • var %a
  • sockread %a
  • ;Analyse et détéction du type de fichier pour permettre au snippet de choisir la méthode d'écriture (binaire ou texte) ..
  • if (Content-Type: * iswm %a) {
  • hadd vdownload %u $+ _type $gettok(%a,2-,58)
  • if ($hget(vdownload,%u $+ _tm) == auto) {
  • if (text/plain isin $hget(vdownload,%u $+ _type)) || (text/html isin $hget(vdownload,%u $+ _type)) hadd vdownload %u $+ _tm txt
  • else hadd vdownload %u $+ _tm bin
  • }
  • }
  • if (Content-Length: * iswm %a) hadd vdownload %u $+ _taille $gettok(%a,2-,58)
  • ;Fin des headers, signalons donc que les headers ont été reçus.
  • if (!%a) { hadd vdownload %u $+ _header yes | .timervdownload_ $+ %u 0 1 vdownloadtimer %u }
  • }
  • else {
  • if (!$fopen(vdownload_ $+ %u)) .fopen -no vdownload_ $+ %u " $+ $hget(vdownload,%u $+ _dest) $+ "
  • ;Incrémentation du nombre de bits reçus.
  • hinc vdownload %u $+ _prog $sock($sockname).rq
  • hinc vdownload %u $+ _tt $sock($sockname).rq
  • ;Exécution de l'alias de progression (si il y en a un) défini par l'utilisateur
  • if ($hget(vdownload,%u $+ _progs)) $hget(vdownload,%u $+ _progs) $hget(vdownload,%u $+ _taille) $hget(vdownload,%u $+ _prog) $round($calc(($hget(vdownload,%u $+ _prog) / $hget(vdownload,%u $+ _taille)) *100) ,1) $+ % $hget(vdownload,%u $+ _taux)
  • if ($hget(vdownload,%u $+ _tm) == txt) {
  • var %b
  • ;Utilisation de $sockbr pour lire toute les informations...
  • :reading | sockread -f %b | if (!$sockbr) return | .fwrite vdownload_ $+ %u %b $crlf | goto reading
  • }
  • else { sockread &a | .fwrite -b vdownload_ $+ %u &a }
  • }
  • }
  • ;Pour obtenir le nombre de bits reçus en 1 seconde
  • alias -l vdownloadtimer {
  • if ($hget(vdownload,0).item) {
  • hadd vdownload $1 $+ _taux $hget(vdownload,$1 $+ _tt) | hadd vdownload $1 $+ _tt 0
  • }
  • }
  • on *:sockclose:vdownload_*:{
  • ;Fermeture des accès fichiers, et suppresion des données, timer...
  • if ($fopen($sockname)) .fclose $sockname
  • var %u = $gettok($sockname,2,95) , %fin = $hget(vdownload,$gettok($sockname,2-,95) $+ _fin)
  • if ($hget(vdownload)) hdel -w vdownload %u $+ _*
  • if (!$hget(vdownload,0).item) .hfree -w vdownload
  • .timervdownload_ $+ %u off
  • ;Fait la commande de fin rentré par l'utilisateur
  • if (%fin) %fin
  • }
  • ;Exemples
  • ;-Télécharge simplement le logo de Google France et l'ouvre à la fin du téléchargement.
  • ;//var %i = $vdownload(google,_,run google.gif,http://www.google.fr/intl/fr_fr/images/logo.gif,google.gif)
  • ;-Télécharge mIRC 6.12 en affichant la progression et indiquant à la fin que le téléchargement est terminé.
  • ;//var %i = $vdownload(_,progtmp-01-,Echo 4 -s Téléchargement de mIRC Terminé.,http://webperso.easynet.fr/mirc/mirc612.exe,download\\mIRC612.exe)
;vdownload - Créé le vendredi 16 Janvier 2004 par Had`S - Version 1.0


;$vdownload(name|_,AP|_,AF|_,url,emplacement).[bin|txt]

;name = Nom du téléchargement. Il est évidemment préférable de mettre des noms différents (ou de mettre _) si vous faites plusieurs téléchargement en même temps. Si vous mettez _ le nom sera généré aléatoirement. Le nom du socket sera toujours vdownload_S  où S est le nom du socket défini ou le nom du socket généré aléatoirement.
;AP = Alias de progression. Le snippet renvoi à l'alias que vous mettez: $1=taille total du fichier, $2=bits-copiés, $3=pourcentage, $4=taux de transfert en bits/s, si vous mettez _ alors le snippet ne renverra pas les informations de progression à un alias.
;AF  = Alias de fin. Le snippet exécute l'alias que vous mettez quand le téléchargement est fini.
;url  = adresse du fichier à télécharger sur Internet.
;emplacement = emplacement où le fichier téléchargé sera enregistré.
;Par défaut, le snippet analyse le type de données (binaire ou texte) du fichier à télécharger afin d'écrire avec le type de données le plus approprié au fichier. Vous pouvez forcer le snippet à écrire les données en binaire ou en texte normal en mettant comme propriété : bin (binaire)ou txt (texte normal).

;/vdownload <name|wildcard>  <== pour annuler un ou plusieurs téléchargements.

;Exemples d'utilisation inclus à la fin du code.

alias vdownload {
  ;Si l'alias a été exécuté sous la forme d'un $identifeur...
  if ($isid) {
    if ($0 <  5) return Manque des paramètres
    if ($1 == _) var %u = $r(a,z) $+ $r(1,9999) $+ $r(a,z) $+ $r(a,z) $+ $r(1,99) $+ $r(a,z)
    else { if ($sockopen(download_ $+ $1)) return Erreur! Socket déja ouvert! | var %u = $1 }
    ;Ecriture dans la hashtable
    if ($2 != _) hadd -m vdownload %u $+ _progs $2
    if ($3 != _) hadd -m vdownload %u $+ _fin $3
    hadd -m vdownload %u $+ _host $gettok($iif($mid($4,1,7) == http:// && $len($4) > 7,$mid($4,8),$4),1,47)
    hadd  vdownload %u $+ _file / $+ $gettok($iif($mid($4,1,7) == http:// && $len($4) > 7,$mid($4,8),$4),2-,47)
    hadd vdownload %u $+ _dest $5-
    hadd vdownload %u $+ _tm $iif($findtok(bin txt,$prop,32),$prop,auto)
    ;Ouverture du socket
    sockopen vdownload_ $+ %u  $hget(vdownload,%u $+ _host) 80
    return OK
  }
  ;L'alias a été exécuté sous la forme d'une /commande...
  else {
    if (!$1) goto end
    sockclose vdownload_ $+ $1-
    if (* !isin $1-) $iif($fopen(vdownload_  $+ $1-),.fclose vdownload_ $+ $1-) | else .fclose vdownload_ $+ $1-)
    if ($hget(vdownload)) {
      hdel -w vdownload $1- $+ _*
      ;Si aucun item n'est présent dans la hashtable, autant la supprimer.
      if (!$hget(vdownload,0).item) .hfree vdownload
    }
    .timervdownload_ $+ $1- off
  }
  :end
}
on *:sockopen:vdownload_*:{
  var %u = $gettok($sockname,2-,95)
  ;Vérification d'erreur..
  if ($sockerr) { echo $color(info)  Erreur ! (1) | vdownload %u | halt }
  sockwrite -n $sockname GET $hget(vdownload,%u $+ _file) HTTP/1.0
  sockwrite -n $sockname  HOST: $hget(vdownload,%u $+ _host)
  sockwrite -n $sockname $crlf
  hadd vdownload %u $+ _header no
  hadd vdownload %u $+ _prog 0 | hadd vdownload %u $+ _tt 0
  hadd vdownload %u $+ _taux 0
}
on *:sockread:vdownload_*:{
  var %u = $gettok($sockname,2,95)
  if ($hget(vdownload,%u $+ _header) == no) {
    ;Donc si on est ici, ça veut dire qu'on s'apprête à recevoir les headers, et donc des informations utiles sur le fichier..
    var %a
    sockread  %a
    ;Analyse et détéction du type de fichier pour permettre au snippet de choisir la méthode d'écriture (binaire ou texte) ..
    if (Content-Type: * iswm %a) {
      hadd vdownload %u $+ _type $gettok(%a,2-,58)
      if ($hget(vdownload,%u $+ _tm) == auto) {
        if (text/plain isin $hget(vdownload,%u $+ _type)) || (text/html isin $hget(vdownload,%u $+ _type)) hadd vdownload %u $+ _tm txt
        else hadd vdownload %u $+ _tm bin
      }
    }
    if (Content-Length: * iswm %a) hadd vdownload %u $+ _taille $gettok(%a,2-,58)
    ;Fin des headers, signalons donc que les headers ont été reçus.
    if (!%a) { hadd vdownload %u $+ _header yes | .timervdownload_ $+ %u 0 1 vdownloadtimer %u }
  }
  else {
    if (!$fopen(vdownload_ $+ %u)) .fopen -no vdownload_ $+ %u " $+ $hget(vdownload,%u $+ _dest) $+ "
    ;Incrémentation du nombre de bits reçus.
    hinc vdownload  %u $+ _prog $sock($sockname).rq
    hinc vdownload  %u $+ _tt $sock($sockname).rq
    ;Exécution de l'alias de progression (si il y en a un) défini par l'utilisateur
    if ($hget(vdownload,%u $+ _progs)) $hget(vdownload,%u $+ _progs) $hget(vdownload,%u $+ _taille) $hget(vdownload,%u $+ _prog) $round($calc(($hget(vdownload,%u $+ _prog) / $hget(vdownload,%u $+ _taille)) *100) ,1) $+ % $hget(vdownload,%u $+ _taux)
    if ($hget(vdownload,%u $+ _tm) == txt) {
      var %b
    ;Utilisation de $sockbr pour lire toute les informations...
      :reading | sockread  -f  %b | if (!$sockbr) return | .fwrite  vdownload_ $+ %u %b $crlf | goto reading
    }
    else { sockread &a | .fwrite -b vdownload_ $+ %u &a }
  }
}
;Pour obtenir le nombre de bits reçus en 1 seconde
alias -l vdownloadtimer {
  if ($hget(vdownload,0).item) {
    hadd vdownload $1 $+ _taux $hget(vdownload,$1 $+ _tt) | hadd vdownload $1 $+ _tt 0
  }
}
on *:sockclose:vdownload_*:{
  ;Fermeture des accès fichiers, et suppresion des données, timer...
  if ($fopen($sockname)) .fclose $sockname
  var %u = $gettok($sockname,2,95) , %fin = $hget(vdownload,$gettok($sockname,2-,95) $+ _fin)
  if ($hget(vdownload)) hdel -w vdownload %u $+ _*
  if (!$hget(vdownload,0).item) .hfree -w vdownload
  .timervdownload_ $+ %u off
  ;Fait la commande de fin rentré par l'utilisateur
  if (%fin) %fin
}

;Exemples
;-Télécharge simplement le logo de Google France et l'ouvre à la fin du téléchargement.
;//var %i = $vdownload(google,_,run google.gif,http://www.google.fr/intl/fr_fr/images/logo.gif,google.gif)

;-Télécharge mIRC 6.12 en affichant la progression et indiquant à la fin que le téléchargement est terminé.
;//var %i = $vdownload(_,progtmp-01-,Echo 4 -s Téléchargement de mIRC Terminé.,http://webperso.easynet.fr/mirc/mirc612.exe,download\\mIRC612.exe)



 Sources du même auteur

$WAV
Source avec une capture GÉNÉRATEUR D'AIDE CONTEXTUELLE
$ID3V1 /ID3V1 $ID3V2
$WMA
$PGCD,$PPCM,$PREMIER

 Sources de la même categorie

Source avec une capture QUOTES BASH ET BASHFR par Flyswat
Source avec Zip Source avec une capture FIREWALL par Bestdoud
ASPIRATEUR DE GALERIES INTERNET par PaDa
Source avec Zip MSN MESSENGER SUR IRC SCRIPT POUR COMPRENDRE LE FONCTIONEMEN... par synsun
Source avec Zip Source avec une capture PROGRAMME TV (PICWIN) par AgoRa_ScripT

Commentaires et avis

Commentaire de Kerrigan le 19/01/2004 19:09:15

pas mal du tout

Commentaire de JStaline le 30/01/2006 22:46:54

Chez moi ca ne marche pas avec certaines images, elle ne veulent plus s'ouvrir.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,746 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales