| 1 | #Region ;**** Directives created by AutoIt3Wrapper_GUI **** |
|---|
| 2 | #AutoIt3Wrapper_Outfile=asd.exe |
|---|
| 3 | #AutoIt3Wrapper_Compression=4 |
|---|
| 4 | #AutoIt3Wrapper_Change2CUI=y |
|---|
| 5 | #AutoIt3Wrapper_Run_Tidy=y |
|---|
| 6 | #AutoIt3Wrapper_Tidy_Stop_OnError=n |
|---|
| 7 | #AutoIt3Wrapper_Run_Obfuscator=y |
|---|
| 8 | #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** |
|---|
| 9 | |
|---|
| 10 | ;Initialise Variables |
|---|
| 11 | $size = -1 |
|---|
| 12 | $lastsize = 0 |
|---|
| 13 | $count = 0000 |
|---|
| 14 | $date = @MON & "-" & @MDAY & "-" & StringTrimLeft(@YEAR, 2) |
|---|
| 15 | $name = "trance.fm " & $date & " " & StringFormat("%04u", $count) & ".aac" |
|---|
| 16 | ;Start Loop |
|---|
| 17 | While 1 |
|---|
| 18 | If FileExists($name) Then |
|---|
| 19 | ;We Dont want to overwrite the last music segment we got |
|---|
| 20 | $count += 1 |
|---|
| 21 | $date = @MON & "-" & @MDAY & "-" & StringTrimLeft(@YEAR, 2) |
|---|
| 22 | $name = "trance.fm " & $date & " " & StringFormat("%04u", $count) & ".aac" |
|---|
| 23 | Else |
|---|
| 24 | ;The Data for today's date dosent exist |
|---|
| 25 | |
|---|
| 26 | ;Start Watcher 'Thread' |
|---|
| 27 | AdlibRegister("Status", 500) |
|---|
| 28 | |
|---|
| 29 | ;Start WGet |
|---|
| 30 | RunWait(@ScriptDir & '\bin\wget.exe --tries=1 --retry-connrefused --read-timeout=30 -nc -q --output-document="' & $name & '" "http://uk01.dj.trance.fm/32.aac"', @ScriptDir, @SW_HIDE) |
|---|
| 31 | AdlibUnRegister("Status"); Possibly Not Needed |
|---|
| 32 | ; Make sure wget is closed |
|---|
| 33 | Do |
|---|
| 34 | $PID = ProcessExists("wget.exe") |
|---|
| 35 | If $PID Then ProcessClose($PID) |
|---|
| 36 | Until ProcessExists("wget.exe") = False |
|---|
| 37 | ; If the filesize is not worth getting; waste it |
|---|
| 38 | If FileGetSize($name) / 1024 < 256 Then |
|---|
| 39 | FileDelete($name) |
|---|
| 40 | $count -= 1 |
|---|
| 41 | EndIf |
|---|
| 42 | EndIf |
|---|
| 43 | Sleep(1000) |
|---|
| 44 | WEnd |
|---|
| 45 | |
|---|
| 46 | Func Status() |
|---|
| 47 | ;Make windows dump cache and update the filesize |
|---|
| 48 | $test = FileOpen($name, 1) |
|---|
| 49 | FileFlush($test) |
|---|
| 50 | FileClose($test) |
|---|
| 51 | ;------Format the output filesize data, Byte, KB, MB------- |
|---|
| 52 | If Not FileGetSize($name) > $lastsize Then Return |
|---|
| 53 | $lastsize = FileGetSize($name) |
|---|
| 54 | If FileGetSize($name) > 0 And Round(FileGetSize($name) / 1024, 2) < 0.99 Then |
|---|
| 55 | $size = FileGetSize($name) & " Bytes" |
|---|
| 56 | Else |
|---|
| 57 | If Round(FileGetSize($name) / 1024, 2) > 0.99 And Round(FileGetSize($name) / 1048576, 2) < 0.99 Then |
|---|
| 58 | $size = Round(FileGetSize($name) / 1024, 2) & " KB" |
|---|
| 59 | Else |
|---|
| 60 | If Round(FileGetSize($name) / 1048576, 2) > 0.99 And Round(FileGetSize($name) / 1048576, 0) <= 50 Then |
|---|
| 61 | $size = Round(FileGetSize($name) / 1048576, 2) & " MB" |
|---|
| 62 | Else |
|---|
| 63 | If Round(FileGetSize($name) / 1048576, 0) >= 50 Then |
|---|
| 64 | ; It the file is over 50MB stop download |
|---|
| 65 | Do |
|---|
| 66 | $PID = ProcessExists("wget.exe") |
|---|
| 67 | If $PID Then ProcessClose($PID) |
|---|
| 68 | Until ProcessExists("wget.exe") = False |
|---|
| 69 | EndIf |
|---|
| 70 | EndIf |
|---|
| 71 | EndIf |
|---|
| 72 | EndIf |
|---|
| 73 | ; Display Current File and Size |
|---|
| 74 | ConsoleWrite($name & "= " & $size & @CRLF) |
|---|
| 75 | EndFunc ;==>Status |
|---|