Jump to content



Photo

StanceWorks Image Downloader


  • Please log in to reply
8 replies to this topic

#1 Maffe811

Maffe811

    Sir Longbottle

  • Active Members
  • PipPipPipPipPipPip
  • 644 posts

Posted 01 July 2012 - 01:53 PM

This is a basic version.

Things i'll fix:
- The blacklist is hardcoded and not in an external file.
- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)
- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it. :P



AutoIt         
#include #include #include #include #include Global $HorizontalPlacement = 1 Global $HorizontalSpacing = 10 Global $ArrayImages[1] Global $ArrayDownload[1] Global $DropdownBlacklistText = "Select blacklist" Global $SaveFolderLocation = "XXX" ;@DesktopDir & "\Temp\" ;~ <a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/</a> $GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 120) ;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $InputLink = GUICtrlCreateInput("<a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/"</a>, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 3 $DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 3 $ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80) $ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80) _WriteSWBlacklist() _BlacklistDropdownUpdater() GUISetState(@SW_SHOW) Func _WriteSWBlacklist() Global $SWBlacklist[1] Local $ArrayCounter = 0 _ArrayAdd($SWBlacklist, "StanceWorks.com") _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a>) $ArrayCounter += 1 _ArrayInsert($SWBlacklist, 0, $ArrayCounter) _ArrayDelete($SWBlacklist, 1) ;~ _ArrayDisplay($SWBlacklist) ;~ MsgBox("","", $ArrayCounter) EndFunc ;==>_WriteSWBlacklist Func _BlacklistDropdownUpdater() _GUICtrlComboBox_AddString($DropdownBlacklist, $SWBlacklist[1]) EndFunc ;==>_BlacklistDropdownUpdater Func _BlacklistUpdater() Global $ArrayBlacklist;[1] ;~ MsgBox("", "", GUICtrlRead($DropdownBlacklist)) Select Case GUICtrlRead($DropdownBlacklist) = "StanceWorks.com" $ArrayBlacklist = $SWBlacklist EndSelect ;~ _ArrayDisplay($ArrayBlacklist) EndFunc ;==>_BlacklistUpdater Func _ImageFilter($SiteLink) _BlacklistUpdater() Local $oIE = _IECreate($SiteLink) _IELoadWait($oIE) Local $sTags = _IETagNameGetCollection($oIE, "img") Local $ImageCount = @extended Local $iCounter1 Local $iCounter2 Local $ArrayDownloadCounter = 0 ;~ MsgBox("", "", $ImageCount) $ArrayImages[0] = $ImageCount For $tag In $sTags ;~ MsgBox("", "", $tag.src) _ArrayAdd($ArrayImages, $tag.src) Next ;~ _ArrayDisplay($ArrayImages) ;~ _ArrayDisplay($ArrayBlacklist) ;~ _ArrayDisplay($ArrayDownload) For $iCounter1 = 1 To $ArrayImages[0] Step 1 ;~ ConsoleWrite("-Image to check " & $ArrayImages[$iCounter1] & @CRLF) For $iCounter2 = 2 To $ArrayBlacklist[0] + 1 Step 1 ;~ ConsoleWrite("!Checking against " & $ArrayBlacklist[$iCounter2] & @CRLF) If $ArrayImages[$iCounter1] = $ArrayBlacklist[$iCounter2] Then ExitLoop ElseIf $iCounter2 = ($ArrayBlacklist[0] + 1) Then ;~ ConsoleWrite("+Match found, adding to array " & $ArrayImages[$iCounter1] & @CRLF) _ArrayAdd($ArrayDownload, $ArrayImages[$iCounter1]) $ArrayDownloadCounter += 1 EndIf Next Next ProcessClose("iexplore.exe") _ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter) _ArrayDelete($ArrayDownload, 1) ;~ _ArrayDisplay($ArrayDownload) _ImageDownloader() EndFunc ;==>_ImageFilter Func _ImageDownloader() Local $DLCounter Local $iDeleteCounter ;~ MsgBox("", "", $SaveFolderLocation) If Not FileExists($SaveFolderLocation) Then DirCreate($SaveFolderLocation) If @error = 0 Then ConsoleWrite("!Error creating directory" & @CRLF) Else ConsoleWrite("+No error creating directory" & @CRLF) EndIf EndIf For $DLCounter = 1 To $ArrayDownload[0] Step 1 $DownloadName = _Stringifier($ArrayDownload[$DLCounter]) InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName) ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF) ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF) ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF) Next ;~ _ArrayDisplay($ArrayDownload) For $iDeleteCounter = $ArrayDownload[0] to 0 step -1 _ArrayDelete($ArrayDownload,$iDeleteCounter) Next Global $ArrayDownload[1] ;~ _ArrayDisplay($ArrayDownload) MsgBox("", "", "Download completed!") GUICtrlSetData($InputLink,"Link") $SaveFolderLocation = "XXX" EndFunc ;==>_ImageDownloader Func _Stringifier($Link) Local $Counter Local $Feedback Local $ArraySize Local $Array[2] Local $CutValue Local $String ;~ $Link = "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a> $Pattern = "(/*.)?" $Array = StringRegExp($Link,$Pattern,3) ;~ _ArrayDisplay($Array) $ArraySize = (UBound($Array)-1) ;~ MsgBox("","",$ArraySize ) For $Counter = $ArraySize to 0 step -1 $Feedback = StringInStr($Array[$Counter],"/") ;~ ConsoleWrite("!" & $Counter & "-" & $Array[$Counter] & ": " & $Feedback & @CRLF) If $Feedback = 1 then ExitLoop Next ;~ MsgBox("","",$Feedback) ;~ MsgBox("","",$Counter) $CutValue = $ArraySize - $Counter ;~ MsgBox("","",$CutValue) $String = StringRight($Link,$CutValue) ;~ MsgBox("","",$String) Return $String EndFunc ;~ <a href='http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/</a> While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $ButtonBrowse If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then MsgBox("", "", "Please select a blacklist!") Else $SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "\pictures", "Folder(*.*)", -1, "Images") & "\") MsgBox("", "", $SaveFolderLocation) _BlacklistUpdater() EndIf Case $ButtonDownload If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then MsgBox("", "", "Please select a blacklist!") ElseIf $SaveFolderLocation = "XXX" Then MsgBox("", "", "Please select a save folder" & @CRLF & "(Click browse)") Else _ImageFilter(GUICtrlRead($InputLink)) EndIf EndSwitch WEnd

Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.Scripts:
Spoiler





#2 Maffe811

Maffe811

    Sir Longbottle

  • Active Members
  • PipPipPipPipPipPip
  • 644 posts

Posted 02 July 2012 - 12:52 AM

Did anyone test the last version? :P
I guess not, since no one mentioned that the includes we're gone.

Anyways i remembered them this time.

Todolist:
- The blacklist is hardcoded and not in an external file.
- A way to create the blacklist if it doesn't exist.
- Change from a combobox to a dropdown
- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)
- Remove the msgbox'es that apear after download complete, when a blacklist isn't selected and when a file directory isn't chosen.
- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it. :P
- Try to make the timer thing for the label and the progressbar better in someway.
- Create a label with "Blacklist" and then remove the "select blacklist" from the combobox


If anyone can point me to an UDF or if i missed something in the helpfile about standard dropdownboxes (not comboboxes) then i would apreciate it.
The other option is to do some dark magics and make the combobox look and act like a drop down.

Ask if you wonder about anything and i'll try to answear as best as i can.

AutoIt         
#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <IE.au3> #include <Array.au3> #include <GuiComboBox.au3> #include <File.au3> Global $HorizontalPlacement = 1 Global $HorizontalSpacing = 10 Global $ArrayImages[1] Global $ArrayDownload[1] Global $DropdownBlacklistText = "Select blacklist" Global $SaveFolderLocation = "XXX" ;@DesktopDir & "\Temp\" Global $ClearTimer Global $ProgressEmptied = 1 ;~ <a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/</a> $GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 160) ;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $InputLink = GUICtrlCreateInput("<a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/"</a>, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 3 $DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 3 $ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80) $ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80) $HorizontalPlacement += 3 $ProgressBar = GUICtrlCreateProgress(10, ($HorizontalPlacement * $HorizontalSpacing), 210, -1,$PBS_SMOOTH) $HorizontalPlacement += 3 $ProgressName = GUICtrlCreateLabel("Ready",10,($HorizontalPlacement * $HorizontalSpacing), 210, 20,$SS_SUNKEN) _WriteSWBlacklist() _BlacklistDropdownUpdater() GUISetState(@SW_SHOW) Func _WriteSWBlacklist() Global $SWBlacklist[1] Local $ArrayCounter = 0 _ArrayAdd($SWBlacklist, "StanceWorks.com") _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a>) $ArrayCounter += 1 _ArrayInsert($SWBlacklist, 0, $ArrayCounter) _ArrayDelete($SWBlacklist, 1) ;~ _ArrayDisplay($SWBlacklist) ;~ MsgBox("","", $ArrayCounter) EndFunc ;==>_WriteSWBlacklist Func _BlacklistDropdownUpdater() _GUICtrlComboBox_AddString($DropdownBlacklist, $SWBlacklist[1]) EndFunc ;==>_BlacklistDropdownUpdater Func _BlacklistUpdater() Global $ArrayBlacklist;[1] ;~ MsgBox("", "", GUICtrlRead($DropdownBlacklist)) Select Case GUICtrlRead($DropdownBlacklist) = "StanceWorks.com" $ArrayBlacklist = $SWBlacklist EndSelect ;~ _ArrayDisplay($ArrayBlacklist) EndFunc ;==>_BlacklistUpdater Func _ImageFilter($SiteLink) _BlacklistUpdater() Local $oIE = _IECreate($SiteLink) _IELoadWait($oIE) Local $sTags = _IETagNameGetCollection($oIE, "img") Local $ImageCount = @extended Local $iCounter1 Local $iCounter2 Local $ArrayDownloadCounter = 0 ;~ MsgBox("", "", $ImageCount) $ArrayImages[0] = $ImageCount For $tag In $sTags ;~ MsgBox("", "", $tag.src) _ArrayAdd($ArrayImages, $tag.src) Next ;~ _ArrayDisplay($ArrayImages) ;~ _ArrayDisplay($ArrayBlacklist) ;~ _ArrayDisplay($ArrayDownload) For $iCounter1 = 1 To $ArrayImages[0] Step 1 ;~ ConsoleWrite("-Image to check " & $ArrayImages[$iCounter1] & @CRLF) For $iCounter2 = 2 To $ArrayBlacklist[0] + 1 Step 1 ;~ ConsoleWrite("!Checking against " & $ArrayBlacklist[$iCounter2] & @CRLF) If $ArrayImages[$iCounter1] = $ArrayBlacklist[$iCounter2] Then ExitLoop ElseIf $iCounter2 = ($ArrayBlacklist[0] + 1) Then ;~ ConsoleWrite("+Match found, adding to array " & $ArrayImages[$iCounter1] & @CRLF) _ArrayAdd($ArrayDownload, $ArrayImages[$iCounter1]) $ArrayDownloadCounter += 1 EndIf Next Next ProcessClose("iexplore.exe") _ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter) _ArrayDelete($ArrayDownload, 1) ;~ _ArrayDisplay($ArrayDownload) _ImageDownloader() EndFunc ;==>_ImageFilter Func _ImageDownloader() Local $DLCounter Local $iDeleteCounter ;~ MsgBox("", "", $SaveFolderLocation) If Not FileExists($SaveFolderLocation) Then DirCreate($SaveFolderLocation) If @error = 0 Then ConsoleWrite("!Error creating directory" & @CRLF) Else ConsoleWrite("+No error creating directory" & @CRLF) EndIf EndIf For $DLCounter = 1 To $ArrayDownload[0] Step 1 $DownloadName = _Stringifier($ArrayDownload[$DLCounter]) InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName) GUICtrlSetData($ProgressBar, ($DLCounter/$ArrayDownload[0]*100)) GUICtrlSetData($ProgressName,$DownloadName) ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF) ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF) ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF) Next ;~ _ArrayDisplay($ArrayDownload) For $iDeleteCounter = $ArrayDownload[0] To 0 Step -1 _ArrayDelete($ArrayDownload, $iDeleteCounter) Next Global $ArrayDownload[1] ;~ _ArrayDisplay($ArrayDownload) ;~ MsgBox("", "", "Download completed!") ;~ GUICtrlSetData($ProgressBar, 0) GUICtrlSetData($ProgressName,"Download complete!") GUICtrlSetData($InputLink, "Link") $SaveFolderLocation = "XXX" $ProgressEmptied = 0 $ClearTimer = TimerInit() EndFunc ;==>_ImageDownloader Func _Stringifier($Link) Local $Counter Local $Feedback Local $ArraySize Local $Array[2] Local $CutValue Local $String ;~ $Link = "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a> $Pattern = "(/*.)?" $Array = StringRegExp($Link, $Pattern, 3) ;~ _ArrayDisplay($Array) $ArraySize = (UBound($Array) - 1) ;~ MsgBox("","",$ArraySize ) For $Counter = $ArraySize To 0 Step -1 $Feedback = StringInStr($Array[$Counter], "/") ;~ ConsoleWrite("!" & $Counter & "-" & $Array[$Counter] & ": " & $Feedback & @CRLF) If $Feedback = 1 Then ExitLoop Next ;~ MsgBox("","",$Feedback) ;~ MsgBox("","",$Counter) $CutValue = $ArraySize - $Counter ;~ MsgBox("","",$CutValue) $String = StringRight($Link, $CutValue) ;~ MsgBox("","",$String) Return $String EndFunc ;==>_Stringifier ;~ <a href='http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/</a> While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $ButtonBrowse ;~ If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then ;~ MsgBox("", "", "Please select a blacklist!") ;~ Else $SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "\pictures", "Folder(*.*)", -1, "Images") & "\") ;~ MsgBox("", "", $SaveFolderLocation) _BlacklistUpdater() ;~ EndIf Case $ButtonDownload If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then ;~ MsgBox("", "", "Please select a blacklist!") GUICtrlSetData($ProgressName,"Please select a blacklist!") $ClearTimer = TimerInit() $ProgressEmptied = 0 ElseIf $SaveFolderLocation = "XXX" Then ;~ MsgBox("", "", "Please select a save folder" & @CRLF & "(Click browse)") GUICtrlSetData($ProgressName,"Please select a save folder(Click browse)") $ClearTimer = TimerInit() $ProgressEmptied = 0 Else _ImageFilter(GUICtrlRead($InputLink)) EndIf EndSwitch If (TimerDiff($ClearTimer)/1000) > "3" and $ProgressEmptied = 0 Then GUICtrlSetData($ProgressBar, 0) GUICtrlSetData($ProgressName,"Ready") $ProgressEmptied = 1 EndIf ;~ $TimerDifference = (TimerDiff($ClearTimer)/1000) ;~ ConsoleWrite($TimerDifference & @Crlf) WEnd

Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.Scripts:
Spoiler

#3 Maffe811

Maffe811

    Sir Longbottle

  • Active Members
  • PipPipPipPipPipPip
  • 644 posts

Posted 04 July 2012 - 06:40 PM

Todolist:
- The blacklist is hardcoded and not in an external file.
- A way to create the blacklist if it doesn't exist.
- Change from a combobox to a dropdown (Disallow text input)
- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)
- Remove the msgbox'es that apear after download complete, when a blacklist isn't selected and when a file directory isn't chosen.
- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it. :P
- Try to make the timer thing for the label and the progressbar better in someway.
- Create a label with "Blacklist" and then remove the "select blacklist" from the combobox, and also make Stanceworks the standard choice.
- Fix some bug where it report folder creation as unsuccessful when it is successful.
- Add points where the download stops if something breaks.


AutoIt         
#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <IE.au3> #include <Array.au3> #include <GuiComboBox.au3> #include <File.au3> Global $HorizontalPlacement = 1 Global $HorizontalSpacing = 10 Global $ArrayImages[1] Global $ArrayDownload[1] Global $DropdownBlacklistText = "" Global $SaveFolderLocation = "XXX" ;@DesktopDir & "\Temp\" Global $ClearTimer Global $ProgressEmptied = 1 ;~ <a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/</a> $GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 160) ;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $InputLink = GUICtrlCreateInput("<a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/"</a>, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 2.5 GUICtrlCreateLabel("Select blacklist:", 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 1.5 $DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 3 $ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80) $ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80) $HorizontalPlacement += 3 $ProgressBar = GUICtrlCreateProgress(10, ($HorizontalPlacement * $HorizontalSpacing), 210, -1, $PBS_SMOOTH) $HorizontalPlacement += 3 $ProgressName = GUICtrlCreateLabel("Ready", 10, ($HorizontalPlacement * $HorizontalSpacing), 210, 20, $SS_SUNKEN) _WriteSWBlacklist() _BlacklistDropdownUpdater() GUISetState(@SW_SHOW) Func _WriteSWBlacklist() Global $SWBlacklist[1] Local $ArrayCounter = 0 _ArrayAdd($SWBlacklist, "StanceWorks.com") _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png"</a>) $ArrayCounter += 1 _ArrayAdd($SWBlacklist, "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a>) $ArrayCounter += 1 _ArrayInsert($SWBlacklist, 0, $ArrayCounter) _ArrayDelete($SWBlacklist, 1) ;~ _ArrayDisplay($SWBlacklist) ;~ MsgBox("","", $ArrayCounter) EndFunc ;==>_WriteSWBlacklist Func _BlacklistDropdownUpdater() _GUICtrlComboBox_AddString($DropdownBlacklist, $SWBlacklist[1]) _GUICtrlComboBox_SetCurSel($DropdownBlacklist, 0) EndFunc ;==>_BlacklistDropdownUpdater Func _BlacklistUpdater() Global $ArrayBlacklist;[1] ;~ MsgBox("", "", GUICtrlRead($DropdownBlacklist)) Select Case GUICtrlRead($DropdownBlacklist) = "StanceWorks.com" $ArrayBlacklist = $SWBlacklist EndSelect ;~ _ArrayDisplay($ArrayBlacklist) EndFunc ;==>_BlacklistUpdater Func _ImageFilter($SiteLink) _BlacklistUpdater() _ProgressUpdater("Gathering info") Local $oIE = _IECreate($SiteLink) _IELoadWait($oIE) Local $sTags = _IETagNameGetCollection($oIE, "img") Local $ImageCount = @extended Local $iCounter1 Local $iCounter2 Local $ArrayDownloadCounter = 0 ;~ MsgBox("", "", $ImageCount) $ArrayImages[0] = $ImageCount For $tag In $sTags ;~ MsgBox("", "", $tag.src) _ArrayAdd($ArrayImages, $tag.src) Next ;~ _ArrayDisplay($ArrayImages) ;~ _ArrayDisplay($ArrayBlacklist) ;~ _ArrayDisplay($ArrayDownload) _ProgressUpdater("Blacklist check") For $iCounter1 = 1 To $ArrayImages[0] Step 1 ;~ ConsoleWrite("-Image to check " & $ArrayImages[$iCounter1] & @CRLF) For $iCounter2 = 2 To $ArrayBlacklist[0] + 1 Step 1 ;~ ConsoleWrite("!Checking against " & $ArrayBlacklist[$iCounter2] & @CRLF) If $ArrayImages[$iCounter1] = $ArrayBlacklist[$iCounter2] Then ExitLoop ElseIf $iCounter2 = ($ArrayBlacklist[0] + 1) Then ;~ ConsoleWrite("+Match found, adding to array " & $ArrayImages[$iCounter1] & @CRLF) _ArrayAdd($ArrayDownload, $ArrayImages[$iCounter1]) $ArrayDownloadCounter += 1 EndIf Next Next ProcessClose("iexplore.exe") _ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter) _ArrayDelete($ArrayDownload, 1) ;~ _ArrayDisplay($ArrayDownload) _ImageDownloader() EndFunc ;==>_ImageFilter Func _ImageDownloader() Local $DLCounter Local $iDeleteCounter _ProgressUpdater("Downloading") ;~ MsgBox("", "", $SaveFolderLocation) If Not FileExists($SaveFolderLocation) Then DirCreate($SaveFolderLocation) ;~ If @error = 0 Then ;~ ConsoleWrite("!Error creating directory, -> " & @extended & @CRLF) ;~ Else ;~ ConsoleWrite("+No error creating directory" & @CRLF) ;~ EndIf EndIf If Not FileExists($SaveFolderLocation) Then MsgBox("", "", "Error creating directory") Exit EndIf For $DLCounter = 1 To $ArrayDownload[0] Step 1 $DownloadName = _Stringifier($ArrayDownload[$DLCounter]) InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName) GUICtrlSetData($ProgressBar, ($DLCounter / $ArrayDownload[0] * 100)) GUICtrlSetData($ProgressName, $DownloadName) ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF) ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF) ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF) Next For $iDeleteCounter = $ArrayDownload[0] To 0 Step -1 _ArrayDelete($ArrayDownload, $iDeleteCounter) Next Global $ArrayDownload[1] $SaveFolderLocation = "XXX" _ProgressUpdater("Download complete!", "Link") EndFunc ;==>_ImageDownloader Func _ProgressUpdater($PUName, $PULink = "") ;~ GUICtrlSetData($ProgressBar, 0) GUICtrlSetData($ProgressName, $PUName) If Not $PULink = "" Then GUICtrlSetData($InputLink, $PULink) ;Timer stuff $ProgressEmptied = 0 $ClearTimer = TimerInit() EndFunc ;==>_ProgressUpdater Func _Stringifier($Link) Local $Pattern Local $Array Local $String ;~ $Link = "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a> ;~ MsgBox("", "", $Link) $Pattern = ".+/(.+\.png|.+\.jpg).*" $String = StringRegExp($Link, $Pattern, 1) ;~ ConsoleWrite(">" & "String:" & $String[0] & @CRLF) Return $String[0] EndFunc ;==>_Stringifier ;~ <a href='http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/</a> While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $ButtonBrowse $SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "\pictures", "Folder(*.*)", 16, "Images") & "\") If @error = 1 Then $SaveFolderLocation = "XXX" ;~ MsgBox("", "", $SaveFolderLocation) _BlacklistUpdater() Case $ButtonDownload If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then _ProgressUpdater("Please select a blacklist!") ElseIf $SaveFolderLocation = "XXX" Then _ProgressUpdater("Please select a save folder(Click browse)") Else _ImageFilter(GUICtrlRead($InputLink)) EndIf EndSwitch If (TimerDiff($ClearTimer) / 1000) > "3" And $ProgressEmptied = 0 Then GUICtrlSetData($ProgressBar, 0) GUICtrlSetData($ProgressName, "Ready") $ProgressEmptied = 1 EndIf ;~ $TimerDifference = (TimerDiff($ClearTimer)/1000) ;~ ConsoleWrite($TimerDifference & @Crlf) WEnd

Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.Scripts:
Spoiler

#4 Maffe811

Maffe811

    Sir Longbottle

  • Active Members
  • PipPipPipPipPipPip
  • 644 posts

Posted 09 July 2012 - 02:38 AM

Batch downloader

This now takes a site you input.
Gather all images within <img> tags
Check them against a blacklist you selected from a menu.
And downloads the ones not found

The bl

Todolist:

- Get the blacklist from an external file, instead of hardcoded.
- A way to create the blacklist if it doesn't exist.
- Change from a combobox to a dropdown (Disallow text input)
- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)
- Remove the msgbox'es that apear after download complete, when a blacklist isn't selected and when a file directory isn't chosen.
- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it. :P
- Try to make the timer thing for the label and the progressbar better in someway.
- Create a label with "Blacklist" and then remove the "select blacklist" from the combobox, and also make Stanceworks the standard choice.
- Fix some bug where it reports folder creation as unsuccessful when it is successful.
- Add points where the download stops if something breaks.
- Add "open folder after download" checkmark and make it happen
- Remove the Internet Explorer popup
- Fix blacklist importation.

- Fix blacklist setup, change the first line from title to blacklisted image (also add this to the code)

AutoIt         
#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <IE.au3> #include <Array.au3> #include <GuiComboBox.au3> #include <File.au3> Global $HorizontalPlacement = 1 Global $HorizontalSpacing = 10 Global $ArrayImages[1] Global $ArrayDownload[1] Global $DropdownBlacklistText = "" ;~ Global $SaveFolderLocation = "XXX" Global $SaveFolderLocation = @DesktopDir & "Temp" Global $ClearTimer Global $ProgressEmptied = 1 Global $ButtonsBlocked = 0 ;~ <a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/</a> ;~ $GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 172,(@DesktopWidth-240),(@DesktopHeight-74-170),-1,$WS_EX_TOPMOST) $GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 172, -1, -1, -1, $WS_EX_TOPMOST) ;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $InputLink = GUICtrlCreateInput("<a href='http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/"</a>, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 2.5 GUICtrlCreateLabel("Select blacklist:", 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 1.5 $DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 2 $CheckboxOpenDir = GUICtrlCreateCheckbox("Open image folder after downloading", 10, ($HorizontalPlacement * $HorizontalSpacing), 210) $HorizontalPlacement += 2 $ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80) $ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80,-1,$BS_DEFPUSHBUTTON) $HorizontalPlacement += 3 $ProgressBar = GUICtrlCreateProgress(10, ($HorizontalPlacement * $HorizontalSpacing), 210, -1, $PBS_SMOOTH) $HorizontalPlacement += 3 $ProgressName = GUICtrlCreateLabel("Ready", 10, ($HorizontalPlacement * $HorizontalSpacing), 210, 20, $SS_SUNKEN) _BlacklistImporter() ;~ _BlacklistDropdownUpdater() GUISetState(@SW_SHOW) Func _BlacklistImporter() ;~ Global $SWBlacklist[1] Global $BlacklistDatabase[1] Local $ArrayCounter = 0 Local $iBlacklistCounter = 2 FileChangeDir(@ScriptDir & "blacklist folder") $FirstFile = FileFindFirstFile("*.blk") Do $BlacklistFile = FileFindNextFile($FirstFile) $NextFileError = @error ;~ _ArrayDisplay($BlacklistDatabase) _GUICtrlComboBox_AddString($DropdownBlacklist, StringTrimRight($BlacklistFile, 4)) ;~ _GUICtrlComboBox_AddString($DropdownBlacklist, $BlacklistDatabase[1]) ;~ MsgBox("","", $ArrayCounter) Until $NextFileError = 1 _GUICtrlComboBox_SetCurSel($DropdownBlacklist, 0) $DropdownStringCount = _GUICtrlComboBox_GetCount($DropdownBlacklist) _GUICtrlComboBox_DeleteString($DropdownBlacklist, $DropdownStringCount - 1) EndFunc ;==>_BlacklistImporter Func _BlacklistActivator() Local $iActivatorCounter Local $ActivatorArrayCounter Global $CurrentBlacklist[1] $ActivatorCurrentBlacklist = _GUICtrlComboBox_GetEditText($DropdownBlacklist) ;~ ConsoleWrite("Current: " & $ActivatorCurrentBlacklist & @CRLF) FileChangeDir(@ScriptDir & "blacklist folder") $ActivatorFile = FileOpen($ActivatorCurrentBlacklist & ".blk") ;~ ConsoleWrite(@error & @CRLF) Do $iActivatorCounter += 1 $TempFileRead = FileReadLine($ActivatorFile, $iActivatorCounter) $FileReadError = @error If Not $FileReadError = -1 Or $FileReadError = 1 Then _ArrayAdd($CurrentBlacklist, $TempFileRead) ;~ ConsoleWrite("Current array entry: " & $TempFileRead & @CRLF) $ActivatorArrayCounter += 1 EndIf Until $FileReadError = -1 Or $FileReadError = 1 FileClose($ActivatorFile) ;~ ConsoleWrite("Read error: " & $FileReadError & @CRLF) ;~ ConsoleWrite("Activator Counter " & $ActivatorArrayCounter & @CRLF) _ArrayInsert($CurrentBlacklist, 0, $ActivatorArrayCounter) _ArrayDelete($CurrentBlacklist, 1) ;~ Global $BlacklistArray[1] ;~ $BlacklistArray = $CurrentBlacklist ;~ _ArrayDisplay($BlacklistArray) ;~ _ArrayDisplay($CurrentBlacklist) ;~ MsgBox("", "", $CurrentBlacklist[1]) ;~ _ArrayDisplay($CurrentBlacklist) Return ($CurrentBlacklist) EndFunc ;==>_BlacklistActivator Func _ImageFilter($SiteLink) ;~ _ArrayDisplay($BlacklistDatabase) ;~ _ArrayDisplay($BlacklistArray) Global $BlacklistArray[1] $BlacklistArray = _BlacklistActivator() ;~ _ArrayDisplay($BlacklistArray) ;~ MsgBox("", "*", $BlacklistArray[1]) _ProgressUpdater("Gathering info") Local $oIE = _IECreateEmbedded() Local $hGUI = GUICreate("Info gathering", 200, 200, -1, -1, BitOR(0x00010000, 0x00020000)) Local $InternetinGui = GUICtrlCreateObj($oIE, 0, 0) _IENavigate($oIE, $SiteLink) _IELoadWait($oIE) Local $sTags = _IETagNameGetCollection($oIE, "img") Local $ImageCount = @extended Local $iTotalImageCounter Local $iComparisonCounter Local $ArrayDownloadCounter = 0 ;~ MsgBox("", "", $ImageCount) $ArrayImages[0] = $ImageCount For $tag In $sTags ;~ MsgBox("", "", $tag.src) ;~ ConsoleWrite("Current image entry: " & $tag.src & @CRLF) _ArrayAdd($ArrayImages, $tag.src) Next ;~ _ArrayDisplay($ArrayImages) ;~ _ArrayDisplay($BlacklistArray) ;~ _ArrayDisplay($ArrayDownload) _ProgressUpdater("Blacklist check") ProcessClose("iexplore.exe") ;~ MsgBox("","",$ArrayImages[0]) = 28 ;~ $iTotalImageCounter ;~ $iComparisonCounter ;~ $BlacklistArray[0] ;~ $ArrayImages[0] For $iTotalImageCounter = 1 To $ArrayImages[0] Step 1 For $iComparisonCounter = 2 To $BlacklistArray[0] Step 1 ConsoleWrite("Counter: " & $iComparisonCounter & "/" & $BlacklistArray[0] & @CRLF) ConsoleWrite("+" & $ArrayImages[$iTotalImageCounter] & " - Images" & @CRLF) If $ArrayImages[$iTotalImageCounter] = $BlacklistArray[$iComparisonCounter] Then ConsoleWrite("-" & $BlacklistArray[$iComparisonCounter] & " - Blacklisted" & @CRLF) ExitLoop EndIf ConsoleWrite("Blacklist tester:" & $iTotalImageCounter & @CRLF) If $iComparisonCounter = $BlacklistArray[0] Then _ArrayAdd($ArrayDownload, $ArrayImages[$iTotalImageCounter]) $ArrayDownloadCounter += 1 EndIf ;~ ConsoleWrite($iComparisonCounter & @CRLF) ;~ ConsoleWrite(">-----" & @CRLF) Next Next ;~ ProcessClose("iexplore.exe") _ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter) _ArrayDelete($ArrayDownload, 1) ;~ _ArrayDisplay($ArrayDownload) ;~ MsgBox("","","Array: " & $ArrayDownload[1] & @CRLF & "IsString: " & IsString($ArrayDownload[1])) If IsString($ArrayDownload[1]) = 1 Then _ImageDownloader() Else _ProgressUpdater("No files found or all blacklisted") EndIf EndFunc ;==>_ImageFilter Func _ImageDownloader() Local $DLCounter Local $iDeleteCounter _ProgressUpdater("Downloading") ;~ MsgBox("", "", $SaveFolderLocation) If Not FileExists($SaveFolderLocation) Then DirCreate($SaveFolderLocation) ;~ If @error = 0 Then If Not FileExists($SaveFolderLocation) Then ConsoleWrite("!Error creating directory, -> " & @extended & @CRLF) Else ConsoleWrite("+No error creating directory" & @CRLF) EndIf EndIf For $DLCounter = 1 To $ArrayDownload[0] Step 1 $DownloadName = _Stringifier($ArrayDownload[$DLCounter]) InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName) GUICtrlSetData($ProgressBar, ($DLCounter / $ArrayDownload[0] * 100)) GUICtrlSetData($ProgressName, $DownloadName) ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF) ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF) ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF) Next For $iDeleteCounter = $ArrayDownload[0] To 0 Step -1 _ArrayDelete($ArrayDownload, $iDeleteCounter) Next Global $ArrayDownload[1] If GUICtrlRead($CheckboxOpenDir) = 1 then ShellExecute("Explorer.exe",$SaveFolderLocation) EndIf $SaveFolderLocation = "XXX" _ProgressUpdater("Download complete!", "Link") EndFunc ;==>_ImageDownloader Func _ProgressUpdater($PUName, $PULink = "") ;~ GUICtrlSetData($ProgressBar, 0) GUICtrlSetData($ProgressName, $PUName) If Not $PULink = "" Then GUICtrlSetData($InputLink, $PULink) ;Timer stuff $ProgressEmptied = 0 $ClearTimer = TimerInit() EndFunc ;==>_ProgressUpdater Func _Stringifier($Link) Local $Pattern Local $Array Local $String[1] ;~ $Link = "<a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"</a> ;~ MsgBox("", "", $Link) $Pattern = "(?i).+/(.+.png|.+.jpg).*" Local $String = StringRegExp($Link, $Pattern, 1) ;~ $String = _ArrayToString($String[0]) ;~ ConsoleWrite(">" & "String:" & $String & @CRLF) ConsoleWrite(">" & "String:" & $String[0] & @CRLF) Return $String[0] EndFunc ;==>_Stringifier ;~ <a href='http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/</a> While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $ButtonBrowse $SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "pictures", "Folder(*.*)", 16, "Images") & "") If @error = 1 Then $SaveFolderLocation = "XXX" ;~ MsgBox("", "", $SaveFolderLocation) Case $ButtonDownload If $SaveFolderLocation = "XXX" Then _ProgressUpdater("Please select a save folder(Click browse)") Else GUICtrlSetState($ButtonBrowse,$GUI_DISABLE) GUICtrlSetState($ButtonDownload,$GUI_DISABLE) $ButtonsBlocked = 1 _ImageFilter(GUICtrlRead($InputLink)) EndIf EndSwitch If (TimerDiff($ClearTimer) / 1000) > "3" And $ProgressEmptied = 0 Then GUICtrlSetData($ProgressBar, 0) GUICtrlSetData($ProgressName, "Ready") $ProgressEmptied = 1 EndIf If $ButtonsBlocked = 1 Then GUICtrlSetState($ButtonBrowse,$GUI_ENABLE) GUICtrlSetState($ButtonDownload,$GUI_ENABLE) $ButtonsBlocked = 0 EndIf WEnd


Edit:

Most of the comments are, as in the previous versions, code that are there for debugging and therefore commented out so i got it if i need to re-debug.
If anyone shows any interest, i can explain it all

Edited by Maffe811, 09 July 2012 - 02:41 AM.

Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.Scripts:
Spoiler

#5 SX200

SX200

    Seeker

  • Normal Members
  • 3 posts

Posted 10 July 2012 - 06:37 AM

Hey there,

nice script! But i always get an error in the latest version.

C:UsersSX200Desktopdownload_img.au3 (189) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
If IsString($ArrayDownload[1]) = 0 Then
If IsString(^ ERROR

There are 26 Images in $ArrayImages but $ArrayDownload is always empty. I did nothing to the blacklist.
Maybe you want to have a look at it

#6 SX200

SX200

    Seeker

  • Normal Members
  • 3 posts

Posted 10 July 2012 - 07:24 AM

Okay I found the error. I created a blacklist and it starts checking the blacklist against the $ArrayDownload. But then it tolds me that all images are blacklisted. The console only shows a few blacklisted images.

#7 SX200

SX200

    Seeker

  • Normal Members
  • 3 posts

Posted 10 July 2012 - 07:33 AM

Somehow i'm not allowed to edit my last post.

It was my bad! I copied your Code again and it works like a charm now!

#8 JLogan3o13

JLogan3o13

    Down to 98

  • MVPs
  • 2,070 posts

Posted 10 July 2012 - 04:09 PM

Somehow i'm not allowed to edit my last post.


Just as an FYI, 5 is the magic number of posts before you're allowed to do some things, including edit old posts.
J.I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, SCCM 2007 Front End, Windows Firewall UDF

#9 Maffe811

Maffe811

    Sir Longbottle

  • Active Members
  • PipPipPipPipPipPip
  • 644 posts

Posted 14 July 2012 - 12:24 AM

It was my bad! I copied your Code again and it works like a charm now!

Awesome! :D


Dag nabbit, i just remembered that the script DOESN'T write its own blacklist if none is found :(

Crap.
Write this in your editor of choice and save as *Blacklistname*.blk (can be stanceworks.com)
StanceWorks.com <a href='http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png</a> <a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg</a> <a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg</a> <a href='http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png</a> <a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png</a> <a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png</a> <a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png</a> <a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png</a> <a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png</a> <a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png</a> <a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png</a> <a href='http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png' class='bbc_url' title='External link' rel='nofollow external'>http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png</a> <a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png</a> <a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png</a> <a href='http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png' class='bbc_url' title='External link' rel='nofollow external'>http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png</a>


Place this in a folder named "blacklist folder", if you change the folder name, you have to change the name in the script too.
I will fix this in the next release.

Edited by Maffe811, 14 July 2012 - 12:30 AM.

Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.Scripts:
Spoiler




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users