Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Array.au3>
- #include <String.au3>
- $title = "Imgur Downloader"
- $folder = InputBox($title, "Folder", "Folder")
- $url = InputBox($title, "Thread url", "http://imgur.com/a/abcde")
- $choice = False
- If Not ($folder Or $url) Then
- ConsoleWrite("Canceling"&@CRLF)
- Exit
- EndIf
- If $choice = 6 Then
- $spamit = True
- Else
- $spamit = False
- EndIf
- If StringInStr($url, "#") > 0 Then
- $url = _StringBetween($url, "", "#")
- $url = $url[0]
- EndIf
- $albumID = _StringBetween($url, "/a/", "")
- $albumID = $albumID[0]
- $url = $url&"/all"
- ConsoleWrite("$url: "&$url&@CRLF)
- ConsoleWrite("$albumID: "&$albumID&@CRLF)
- If Not FileExists($folder) Then
- DirCreate($folder)
- EndIf
- $picture_old = 0
- Dim $empty[1]
- Dim $picture[2]
- Func getFileName($string)
- $string = _StringReverse($string)
- Return _StringReverse(StringMid($string, 1, StringInStr($string, "/")-1))&".jpg"
- EndFunc
- Func displayDownloading($bool)
- If $bool Then
- TraySetState(4)
- TraySetIcon("downloading.png")
- Else
- TraySetState(8)
- TraySetIcon("stopped.png")
- EndIf
- EndFunc
- Func FindString($str)
- If StringInStr($page, $str) > 0 Then
- return True
- Else
- return False
- EndIf
- EndFunc
- Func DownloadPics()
- $id = 0
- For $i=0 To UBound($picture)-1
- ;~ $filename = getFileName($picture[$i])
- $id = $id+1
- $filename = $albumID&"_"&$id&".jpg"
- ConsoleWrite($picture[$i]&" ==> "&$filename&@CRLF)
- If FileExists($folder&"\"&$filename) Then
- ConsoleWrite("Name conflict"&@CRLF)
- If FileGetSize($folder&"\"&$filename) = InetGetSize($picture[$i]) Then
- ConsoleWrite("-> Same size"&@CRLF)
- Else
- displayDownloading(True)
- InetGet($picture[$i], $folder&"\"&$filename)
- displayDownloading(False)
- EndIf
- Else
- displayDownloading(True)
- InetGet($picture[$i], $folder&"\"&$filename)
- displayDownloading(False)
- EndIf
- Next
- $picture = $empty
- EndFunc
- Func GetPicsUrl()
- $picture = _StringBetween($page, '<a href="/a/'&$albumID&"#", '">')
- For $i=0 To UBound($picture)-1
- $picture[$i] = "http://imgur.com/download/"&$picture[$i]
- Next
- EndFunc
- $pagename = Random(0, 2147483647, 1)
- InetGet($url, $pagename, 1)
- $h = FileOpen($pagename, 0)
- $page = FileRead($h)
- FileClose($h)
- If FindString("<h1>Zoinks! You've taken a wrong turn.</h1>") Then
- MsgBox(0, "", "The page has 404'd")
- Exit
- EndIf
- GetPicsUrl()
- DownloadPics()
- Func quitting()
- FileDelete($pagename)
- EndFunc
- OnAutoItExitRegister("quitting")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement