Jump to content



Photo

Fonts Fetcher


  • Please log in to reply
18 replies to this topic

#1 Jex

Jex

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 17 November 2007 - 11:00 AM

That script downloads all fonts in www.dafonts.com or http://cooltext.com/Fonts links, extracts zip files and moves fonts to Windows/Fonts folder.

Posted Image

Download ( $Link, $Downloadtype, $Directorytype, $Directoryname )

$Link examples :
http://www.dafont.com/top.php?page=1&nb_ppp=50
http://www.dafont.com/top.php?page=2&nb_ppp=50
http://cooltext.com/Fonts-3D
http://cooltext.com/Fonts-Modern

$Downloadtype examples :
1 = Download fonts and automatic extract zip files or copy tff files to Windows/Fonts/ folder.
2 = Just download fonts. ( Not extract or copy. )

$Directorytype examples :
1 = Installing all fonts in "Fonts" directory.
2 = Installing dafonts fonts in "Fonts" directory and cooltext fonts in "Fonts2" directory.
3 = Installing fonts in your choiced directory. ( $Directoryname )

Example : Download ("http://cooltext.com/Fonts-3D", 1, 2)

AutoIt         
#include <GUIConstants.au3> #include <GuiEdit.au3> #include <INet.au3> #include <String.au3> #include <_ZipPlugin.au3> PluginOpen(@ScriptDir & "\Au3Zip.dll") $Form = GUICreate("Fonts Fetcher", 305, 385, 358, 329, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS)) $Input1 = GUICtrlCreateInput("www.dafont.com/top.php?page=1&nb_ppp=50", 48, 16, 241, 21) $Radio1 = GUICtrlCreateRadio("Download and install fonts.", 16, 48, 145, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetTip(-1, "Download fonts and automatic extract zip files or copy tff files to Windows/Fonts/ folder.") $Radio2 = GUICtrlCreateRadio("Just download fonts.", 176, 48, 113, 17) GUICtrlSetTip(-1, "Just download fonts. ( Not extract or copy. )") $Input2 = GUICtrlCreateInput("Fonts", 88, 96, 201, 21) GUICtrlSetState(-1, $GUI_DISABLE) $Button = GUICtrlCreateButton("Start", 8, 128, 289, 25) GUIStartGroup() $Label1 = GUICtrlCreateLabel("Link :", 16, 24, 30, 17) $Label2 = GUICtrlCreateLabel("Folder name :", 16, 104, 68, 17) GUIStartGroup() $Radio3 = GUICtrlCreateRadio("Dir type 1", 16, 72, 65, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetTip(-1, 'Installing all fonts in "Fonts" directory.') $Radio4 = GUICtrlCreateRadio("Dir type 2", 96, 72, 65, 17) GUICtrlSetTip(-1, 'Installing dafonts fonts in "Fonts" directory and cooltext fonts in "Fonts2" directory.') $Radio5 = GUICtrlCreateRadio("Dir type 3", 176, 72, 65, 17) GUICtrlSetTip(-1, 'Installing fonts in your choiced directory.') $Progress1 = GUICtrlCreateProgress(8, 360, 289, 17) $Edit = GUICtrlCreateEdit("", 8, 160, 289, 169) $Label3 = GUICtrlCreateLabel("", 8, 336, 289, 17) GUISetState(@SW_SHOW) While 1     $msg = GUIGetMsg()     Switch $msg         Case $GUI_EVENT_CLOSE             Exit         Case $Button             GUICtrlSetState($Button, $GUI_DISABLE)             $Par3 = ""             If GUICtrlRead($Radio1) = $GUI_CHECKED Then                 $Par1 = 1             Else                 $Par1 = 2             EndIf             If GUICtrlRead($Radio3) = $GUI_CHECKED Then                 $Par2 = 1             ElseIf GUICtrlRead($Radio4) = $GUI_CHECKED Then                 $Par2 = 2             Else                 $Par2 = 3                 $Par3 = GUICtrlRead($Input2)             EndIf             $Var = Download(GUICtrlRead($Input1), $Par1, $Par2, $Par3)             Write($Var[0] & " Fonts downloaded and installed in " & $Var[1] & " seconds.")             GUICtrlSetState($Button, $GUI_ENABLE)         Case $Radio3             GUICtrlSetState($Input2, $GUI_DISABLE)         Case $Radio4             GUICtrlSetState($Input2, $GUI_DISABLE)         Case $Radio5             GUICtrlSetState($Input2, $GUI_ENABLE)     EndSwitch WEnd Func Download($Url, $Method = 1, $Dirtype = 1, $Dirtype3 = "")     If $Dirtype = 3 Then $Dir = "\" & $Dirtype3 & "\"     GUICtrlSetData($Label3, "Download starting...")     Write("Download starting from " & $Url)     $Timer = TimerInit()     $Source = _INetGetSource($Url)     If StringInStr($Url, "dafont.com") Then         $String = _StringBetween($Source, 'href="http://img.dafont.com/download/?file=', '">Download<br>')         $Urltype = 1         If $Dirtype <> 3 Then $Dir = "\Fonts\"     ElseIf StringInStr($Url, "cooltext.com") Then         $String = _StringBetween($Source, 'Download:<a href=Download/Font/', '>Click Here</a><br />')         $Urltype = 2         If $Dirtype = 1 Then             $Dir = "\Fonts\"         ElseIf $Dirtype = 2 Then             $Dir = "\Fonts2\"         EndIf     EndIf     If Not FileExists(@ScriptDir & $Dir) Then DirCreate(@ScriptDir & $Dir)     Dim $Var[UBound($String) + 1]     For $i = 0 To UBound($String) - 1         If $Urltype = 1 Then             If Not FileExists(@ScriptDir & $Dir & $String[$i] & ".zip") Then                 $Download = 'http://img.dafont.com/download/?file=' & $String[$i]                 InetGet($Download, @ScriptDir & $Dir & $String[$i] & ".zip")                 Write(@ScriptDir & $Dir & $String[$i] & ".zip downloaded.")             EndIf         ElseIf $Urltype = 2 Then             If Not FileExists(@ScriptDir & $Dir & $String[$i]) Then                 $Download = 'http://cooltext.com/Download/Font/' & $String[$i]                 InetGet($Download, @ScriptDir & $Dir & $String[$i])                 Write(@ScriptDir & $Dir & $String[$i] & " downloaded.")             EndIf         EndIf         $Var[$i + 1] = $String[$i]         $Calculate = Round((($i + 1) / UBound($String)) * 100, 0)         GUICtrlSetData($Label3, "Downloading fonts (" & $i + 1 & " / " & UBound($String) & ") " & $Calculate & "%")         GUICtrlSetData($Progress1, $Calculate)     Next     If $Method = 1 Then         For $i = 1 To UBound($String)             If $Urltype = 1 Then                 _ZipUnZip (@ScriptDir & $Dir & $Var[$i] & ".zip", @WindowsDir & "\Fonts\")             ElseIf $Urltype = 2 Then                 If StringInStr($Var[$i], ".zip") Then                     _ZipUnZip (@ScriptDir & $Dir & $Var[$i], @WindowsDir & "\Fonts\")                 ElseIf StringInStr($Var[$i], ".ttf") Then                     FileCopy(@ScriptDir & $Dir & $Var[$i], @WindowsDir & "\Fonts\" & $Var[$i])                 EndIf             EndIf         Next     EndIf     $Timerdiff = TimerDiff($Timer)     GUICtrlSetData($Label3, "Download completed (" & UBound($String) & " / " & UBound($String) & ") " & $Calculate & "%")     Dim $Var[2] = [UBound($String), Round($Timerdiff, 0) / 1000 ]     Return $Var EndFunc   ;==>Download Func Write($Data)     If GUICtrlRead($Edit) = "" Then         GUICtrlSetData($Edit, $Data)     Else         GUICtrlSetData($Edit, GUICtrlRead($Edit) & @CRLF & $Data)     EndIf     _GUICtrlEdit_LineScroll ($Edit, 0, _GUICtrlEdit_GetLineCount ($Edit)) EndFunc   ;==>Write


Need _ZipPlugin.au3 and Au3Zip.dll for extract zip files. http://www.autoitscript.com/forum/index.ph...p;hl=_zipplugin

Attached Files


Edited by Jex, 18 November 2007 - 06:22 AM.








#2 ashley

ashley

    Universalist

  • Banned (NOT IN USE)
  • 1,044 posts

Posted 17 November 2007 - 11:10 AM

nice idea....

But im not going to check it.

#3 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 17 November 2007 - 11:18 AM

Trying it now... Not to bad :P The progress is good. Easy to keep an eye on it. Overall, good job!

@Ashley- If your not gonna try it, then why say anything? Sure its a nice idea, why not see how nice an idea it actually is?

#4 Jex

Jex

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 17 November 2007 - 11:21 AM

Very thanks for your comment Bert :P

#5 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 17 November 2007 - 11:29 AM

You could easily add a GUI to say, I want this font and not that one... You could also poll the font folder to see if there are duplicates, as not to download the same one. There is endless possibilities with this :P

#6 Kreatorul

Kreatorul

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 357 posts

Posted 17 November 2007 - 12:30 PM

Also you could preview it in the GUI :P Wow this has a lot of potential as I'm too lazy to search for fonts on the net...

#7 Jex

Jex

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 17 November 2007 - 12:35 PM

You could also poll the font folder to see if there are duplicates, as not to download the same one.


Now script check for if that font downloaded before or not.

By the way im suggest that 2 links fonts for download ( Top 100 )

Download("http://www.dafont.com/top.php?page=1&nb_ppp=50")
Download("http://www.dafont.com/top.php?page=2&nb_ppp=50")

Edit : I'm added that 2 links in script.

Edited by Jex, 17 November 2007 - 01:12 PM.


#8 gamepin126

gamepin126

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 252 posts

Posted 17 November 2007 - 01:27 PM

Couldn't you just do
For $n = 1 to 2      Download("<a href='http://www.dafont.com/top.php?page=' class='bbc_url' title='External link' rel='nofollow external'>http://www.dafont.com/top.php?page="</a> & $n & "&nb_ppp=50") Next


?

Very nice script by the way :P

Edited by gamepin126, 17 November 2007 - 01:43 PM.


#9 MadBoy

MadBoy

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 829 posts

Posted 17 November 2007 - 01:31 PM

Very thanks for your comment Bert :P


Jex i am wondering will just copying the fonts into fonts directory install them in a system aswell? I've been reading somewhere you still have to go and install them from the windows explorer gui?

#10 gamepin126

gamepin126

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 252 posts

Posted 17 November 2007 - 01:32 PM

Yea, you can just drag n drop them into the fonts folder to install them.

#11 Jex

Jex

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 17 November 2007 - 01:49 PM

Jex i am wondering will just copying the fonts into fonts directory install them in a system aswell? I've been reading somewhere you still have to go and install them from the windows explorer gui?


I'm dont understand what you are asking but script extracting fonts in Windows/Fonts folder. That mean not need go and install them from the windows explorer gui.

@Gamepin126
Not need drag n drop. Script installing fonts automaticly.

Edited by Jex, 17 November 2007 - 01:54 PM.


#12 gamepin126

gamepin126

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 252 posts

Posted 17 November 2007 - 01:53 PM

I know, I was just answering his question.

Jex i am wondering will just copying the fonts into fonts directory install them in a system aswell?



#13 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 17 November 2007 - 04:04 PM

Nice! I'm Lovin' it! JEX, you keep adding great scripts to the forum.. Thanks!

#14 Gif

Gif

    Laikon Kafekoption

  • Active Members
  • PipPipPipPipPipPip
  • 1,117 posts

Posted 17 November 2007 - 07:09 PM

interesting, with many potentials for future use.

#15 Jex

Jex

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 17 November 2007 - 11:54 PM

I'm added cooltext.com fonts support and some parameters.

#16 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 17 November 2007 - 11:59 PM

I'm added cooltext.com fonts support and some parameters.

I think you should add a gui. It would be awesome if you did :P

#17 Jex

Jex

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 18 November 2007 - 12:11 AM

If i'm add fonts pictures in gui that will increase fonts download speed because first need install fonts images and that not good idea i think.
But i will create gui for write fonts links there or select parameters and that gui will be have progressbar etc?

#18 Jex

Jex

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 18 November 2007 - 01:58 AM

I'm added gui :

Posted Image

Edited by Jex, 18 November 2007 - 02:26 AM.


#19 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 18 November 2007 - 06:00 AM

I'm added gui :

Posted Image

Good Job! Looks great :P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users