DEFLNG a-z FUNCTION PBMAIN() STDOUT "camthief v0.1" STDOUT "by glider@bmezine.com" STDOUT "c 2001 monolith media" STDOUT cmd$ = COMMAND$ url$ = TRIM$(PARSE$(cmd$, " ", 1)) prefix$ = TRIM$(PARSE$(cmd$, " ", 2)) timing = VAL(PARSE$(cmd$, " ", 3)) IF INSTR(url$, "http://") <> 1 OR prefix$ = "" OR timing < 1 THEN STDOUT "usage: camthief url prefix timing" STDOUT " url is the exact url of the cam image" STDOUT " prefix is the file prefix (ie. jojo would output jojo001.jpg)" STDOUT " timing is the number of seconds between checks" STDOUT EXIT FUNCTION END IF firstslash = INSTR(8, url$, "/") IF firstslash = 0 OR firstslash >= LEN(url$) THEN STDOUT "error: urls need to be complete." EXIT FUNCTION END IF site$ = MID$(url$, 8, firstslash - 8) file$ = MID$(url$, firstslash) previous$ = "": fileat = 0 x$ = DIR$(prefix$ & "????.jpg") IF x$ <> "" THEN 'the file must exist -- scan for the last one, and suck it in DO INCR fileat x$ = DIR$(prefix$ & FORMAT$(fileat, "0000") & ".jpg") IF x$ = "" THEN DECR fileat EXIT DO END IF LOOP IF DIR$(prefix$ & FORMAT$(fileat, "0000") & ".jpg") <> "" THEN 'try and suck it fu$ = prefix$ & FORMAT$(fileat, "0000") & ".jpg" OPEN fu$ FOR BINARY LOCK SHARED AS #1 GET$ #1, LOF(1), previous$ CLOSE #1 END IF END IF STDOUT "Firing up camthief (press ^C to quit):" STDOUT " url/site: " & site$ STDOUT " url/file: " & file$ STDOUT " filename: " & prefix$ & FORMAT$(fileat, "0000") & ".jpg"; IF previous$ <> "" THEN STDOUT " [preloaded]" ELSE STDOUT " [fresh]" END IF STDOUT " timing: every " & FORMAT$(timing) & " seconds" STDOUT DO TCP OPEN PORT 80 AT site$ AS #1 TIMEOUT 30 IF ERR THEN STDOUT TIME$ & " Could not connect [" & FORMAT$(ERR) & "]." ELSE TCP PRINT #1, "GET " & file$ & " HTTP/1.0" TCP PRINT #1, "" thisone$ = "" DO TCP RECV #1, 4096, buffer$ thisone$ = thisone$ & buffer$ LOOP WHILE LEN(buffer$) TCP CLOSE #1 END IF IF INSTR(thisone$, "JFIF") > 0 OR INSTR(thisone$, "Exif") > 0THEN IF INSTR(thisone$, "JFIF") > 0 THEN thisone$ = MID$(thisone$, INSTR(thisone$, "JFIF") - 6) ELSE thisone$ = MID$(thisone$, INSTR(thisone$, "Exif") - 6) END IF IF thisone$ <> previous$ THEN previous$ = thisone$ thisone$ = "" INCR fileat STDOUT TIME$ & " New file: " & prefix$ & FORMAT$(fileat, "0000") & ".jpg " & FORMAT$(LEN(previous$)) & " bytes" OPEN prefix$ & FORMAT$(fileat, "0000") & ".jpg" FOR OUTPUT AS #1 PRINT #1, previous$; CLOSE #1 ELSE STDOUT TIME$ & " (file is the same)" END IF ELSE STDOUT TIME$ & " File is not a JPEG" END IF CLOSE SLEEP timing * 1000 LOOP END FUNCTION