Accueil > > > VDOWNLOAD - MULTIPLE TÉLÉCHARGEUR DE FICHIERS
VDOWNLOAD - MULTIPLE TÉLÉCHARGEUR DE FICHIERS
Information sur la source
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
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Forum
RE : AIDERE : AIDE par Nico26000
Cliquez pour lire la suite par Nico26000 RE : AIDERE : AIDE par WorldDMT
Cliquez pour lire la suite par WorldDMT AIDEAIDE par Nico26000
Cliquez pour lire la suite par Nico26000
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|