Compare commits

...

5 Commits

Author SHA1 Message Date
1MalcolmS
e23157eee3 fixed copy names 2026-03-29 01:26:44 -07:00
1MalcolmS
bd9bf5c6cc cleanup 2026-03-29 01:22:56 -07:00
1MalcolmS
359709c82a multithreaded 2026-03-29 01:21:08 -07:00
1MalcolmS
7305d667ef improved video naming 2026-03-27 16:42:13 -07:00
1MalcolmS
a574a77a4b improved video naming 2026-03-27 16:39:54 -07:00
6 changed files with 122 additions and 92 deletions

View File

@@ -21,6 +21,7 @@ os.mkdir("Terminal dock")
os.mkdir("Vanterm Alliance Grain Terminal crossing")
os.mkdir("Vanterm in gate")
os.mkdir("Waterfront_road Centerm crossing")
os.mkdir("Convention Centre East")
os.mkdir("Videos")

View File

@@ -21,5 +21,6 @@ shutil.rmtree("Terminal dock")
shutil.rmtree("Vanterm Alliance Grain Terminal crossing")
shutil.rmtree("Vanterm in gate")
shutil.rmtree("Waterfront_road Centerm crossing")
shutil.rmtree("Convention Centre East")
subprocess.run(["python", "folder_create.txt"])

View File

@@ -3,6 +3,7 @@ from time import time
from time import sleep
from contextlib import chdir
import copy
from concurrent.futures import ThreadPoolExecutor
headerz = {'Accept' : 'image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5', 'Accept-Encoding' :
'gzip, deflate, br, zstd', 'Accept-Language' :
@@ -10,114 +11,82 @@ headerz = {'Accept' : 'image/avif,image/webp,image/png,image/svg+xml,image/*;q=0
'https://www.portvancouver.com/' }
milliseconds = int(time() * 1000)
x1 = requests.Response()
x2 = requests.Response()
x3 = requests.Response()
x4 = requests.Response()
x5 = requests.Response()
x6 = requests.Response()
x7 = requests.Response()
x8 = requests.Response()
x9 = requests.Response()
x10 = requests.Response()
x11 = requests.Response()
x12 = requests.Response()
x13 = requests.Response()
x14 = requests.Response()
x15 = requests.Response()
x16 = requests.Response()
x17 = requests.Response()
x18 = requests.Response()
x19 = requests.Response()
x = [requests.Response() for _ in range(20)]
str1 = "https://ehub.portvancouver.com/Webcams/Photos/CommOver?"
str2 = "https://ehub.portvancouver.com/webcams/Photos/DPWExitWest?"
str3 = "https://ehub.portvancouver.com/Webcams/Photos/CentermMainGates?"
str4 = "https://ehub.portvancouver.com/Webcams/Photos/VantermEntrance?"
str5 = "https://ehub.portvancouver.com/Webcams/Photos/VantermGates?"
str6 = "https://ehub.portvancouver.com/Webcams/Photos/ClarkEntrance?"
str7 = "https://ehub.portvancouver.com/Webcams/Photos/ColumbiaContainerCrossing?"
str8 = "https://ehub.portvancouver.com/webcams/Photos/TerminalDock?"
str9 = "https://ehub.portvancouver.com/Webcams/Photos/CommEntrance?"
str10 = "https://ehub.portvancouver.com/Webcams/Photos/CommOverMcGill?"
str11 = "https://ehub.portvancouver.com/Webcams/Photos/CameraDP_FS1?"
str12 = "https://ehub.portvancouver.com/Webcams/Photos/DeltaportGate1?"
str13 = "https://ehub.portvancouver.com/Webcams/Photos/DMSWest?"
str14 = "https://ehub.portvancouver.com/Webcams/Photos/FSMainIntersection?"
str15 = "https://ehub.portvancouver.com/Webcams/Photos/FSTruckInGate?"
str16 = "https://ehub.portvancouver.com/Webcams/Photos/FSVACSGates?"
str17 = "https://ehub.portvancouver.com/Webcams/Photos/FS5TrackCrossing?"
str18 = "https://ehub.portvancouver.com/Webcams/Photos/PortsideNo8?"
str19 = "https://ehub.portvancouver.com/Webcams/Photos/PortsideCoast2000?"
print(x)
i = [-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
astr = ["Hi!"] * 20
lastr = ["Hi!"] * 20
astr[0] = "https://ehub.portvancouver.com/Webcams/Photos/CommOver?"
astr[1] = "https://ehub.portvancouver.com/webcams/Photos/DPWExitWest?"
astr[2] = "https://ehub.portvancouver.com/Webcams/Photos/CentermMainGates?"
astr[3] = "https://ehub.portvancouver.com/Webcams/Photos/VantermEntrance?"
astr[4] = "https://ehub.portvancouver.com/Webcams/Photos/VantermGates?"
astr[5] = "https://ehub.portvancouver.com/Webcams/Photos/ClarkEntrance?"
astr[6] = "https://ehub.portvancouver.com/Webcams/Photos/ColumbiaContainerCrossing?"
astr[7] = "https://ehub.portvancouver.com/webcams/Photos/TerminalDock?"
astr[8] = "https://ehub.portvancouver.com/Webcams/Photos/CommEntrance?"
astr[9] = "https://ehub.portvancouver.com/Webcams/Photos/CommOverMcGill?"
astr[10] = "https://ehub.portvancouver.com/Webcams/Photos/CameraDP_FS1?"
astr[11] = "https://ehub.portvancouver.com/Webcams/Photos/DeltaportGate1?"
astr[12] = "https://ehub.portvancouver.com/Webcams/Photos/DMSWest?"
astr[13] = "https://ehub.portvancouver.com/Webcams/Photos/FSMainIntersection?"
astr[14] = "https://ehub.portvancouver.com/Webcams/Photos/FSTruckInGate?"
astr[15] = "https://ehub.portvancouver.com/Webcams/Photos/FSVACSGates?"
astr[16] = "https://ehub.portvancouver.com/Webcams/Photos/FS5TrackCrossing?"
astr[17] = "https://ehub.portvancouver.com/Webcams/Photos/PortsideNo8?"
astr[18] = "https://ehub.portvancouver.com/Webcams/Photos/PortsideCoast2000?"
astr[19] = "https://ehub.portvancouver.com/Webcams/Photos/CPCTruckRoute?"
folder = ["Commissioner entrance","Waterfront_road Centerm crossing","Centerm in gate",
"Vanterm Alliance Grain Terminal crossing", "Vanterm in gate", "Clark Drive overpass",
"Columbia Container - crossing", "Terminal dock","Commissioner truck staging",
"Commissioner street overpass", "Deltaport causeway", "Deltaport gate 1",
"Delta truck staging", "Fraser Surrey main intersection","Fraser Surrey in gate",
"Fraser Surrey VACS gates", "Fraser Surrey track crossing", "PortsideBlundellNo.8 road intersection",
"Portside road - westbound", "Convention Centre East"]
reference = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
i = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
image_name = "image"
def acquireImage(request_string, folder_name, response):
global image_check
def acquireImage(request_string, folder_name, response, number):
image_check = requests.Response()
image_check = copy.deepcopy(response)
response = requests.get(request_string, headers=headerz)
resp = requests.get(request_string, headers=headerz, timeout=(5,30))
response._content = resp.content
response.status_code = resp.status_code
if response.content != image_check.content:
global i
i[number] += 1
image_name = "image" + f"{i[number]:04}" + ".jpg"
print(response)
with chdir(folder_name):
if response.status_code == 200:
with open(image_name, 'wb') as f:
f.write(response.content)
else:
print("Copy detected and removed (folder_name)")
print(f"Copy detected and removed ({folder_name})")
def getTimeAndName(index):
def getName():
milliseconds = int(time() * 1000)
global image_name
image_name = "image" + f"{i[index]:04}" + ".jpg"
i[index] += 1
global lastr
lastr = [s + str(milliseconds) for s in astr]
while True:
getTimeAndName(1)
acquireImage(str1 + str(milliseconds), 'Commissioner entrance', x1)
getTimeAndName(2)
acquireImage(str2 + str(milliseconds), 'Waterfront_road Centerm crossing', x2)
getTimeAndName(3)
acquireImage(str3 + str(milliseconds), 'Centerm in gate', x3)
getTimeAndName(4)
acquireImage(str4 + str(milliseconds), 'Vanterm Alliance Grain Terminal crossing', x4)
getTimeAndName(5)
acquireImage(str5 + str(milliseconds), 'Vanterm in gate', x5)
getTimeAndName(6)
acquireImage(str6 + str(milliseconds), 'Clark Drive overpass', x6)
getTimeAndName(7)
acquireImage(str7 + str(milliseconds), 'Columbia Container - crossing', x7)
getTimeAndName(8)
acquireImage(str8 + str(milliseconds), 'Terminal dock', x8)
getTimeAndName(9)
acquireImage(str9 + str(milliseconds), 'Commissioner truck staging', x9)
getTimeAndName(10)
acquireImage(str10 + str(milliseconds), 'Commissioner street overpass', x10)
getTimeAndName(11)
acquireImage(str11 + str(milliseconds), 'Deltaport causeway', x11)
getTimeAndName(12)
acquireImage(str12 + str(milliseconds), 'Deltaport gate 1', x12)
getTimeAndName(13)
acquireImage(str13 + str(milliseconds), 'Delta truck staging', x13)
getTimeAndName(14)
acquireImage(str14 + str(milliseconds), 'Fraser Surrey main intersection', x14)
getTimeAndName(15)
acquireImage(str15 + str(milliseconds), 'Fraser Surrey in gate', x15)
getTimeAndName(16)
acquireImage(str16 + str(milliseconds), 'Fraser Surrey VACS gates', x16)
getTimeAndName(17)
acquireImage(str17 + str(milliseconds), 'Fraser Surrey track crossing', x17)
getTimeAndName(18)
acquireImage(str18 + str(milliseconds), 'PortsideBlundellNo.8 road intersection', x18)
getTimeAndName(19)
acquireImage(str19 + str(milliseconds), 'Portside road - westbound', x19)
getName()
with ThreadPoolExecutor() as executor:
results = executor.map(acquireImage, lastr, folder, x, reference)
print(i)
print("Scanned")

23
testingtemplate.txt Normal file
View File

@@ -0,0 +1,23 @@
import requests
from time import time
from time import sleep
headerz = {'Accept' : 'image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5', 'Accept-Encoding' :
'gzip, deflate, br, zstd', 'Accept-Language' :
'en-CA,en-US;q=0.9,en;q=0.8', 'Referer' :
'https://www.portvancouver.com/' }
while True:
seconds = int(time()* 1000)
print(seconds)
r = "https://ehub.portvancouver.com/Webcams/Photos/CPCTruckRoute?" + str(time)
response = requests.get(r, headers=headerz)
sleep(1)
image_name = "image" + str(seconds) + ".jpg"
if response.status_code == 200:
with open(image_name, 'wb') as f:
f.write(response.content)
print(response.status_code)

26
video-cleanup.txt Normal file
View File

@@ -0,0 +1,26 @@
import shutil
import os
shutil.rmtree("Videos")
os.mkdir("Videos")
os.mkdir(r"Videos\Centerm in gate - videos")
os.mkdir(r"Videos\Clark Drive overpass - videos")
os.mkdir(r"Videos\Columbia Container - crossing - videos")
os.mkdir(r"Videos\Commissioner entrance - videos")
os.mkdir(r"Videos\Commissioner street overpass - videos")
os.mkdir(r"Videos\Commissioner truck staging - videos")
os.mkdir(r"Videos\Delta truck staging - videos")
os.mkdir(r"Videos\Deltaport causeway - videos")
os.mkdir(r"Videos\Deltaport gate 1 - videos")
os.mkdir(r"Videos\Deltaport gate 3 - videos")
os.mkdir(r"Videos\Fraser Surrey in gate - videos")
os.mkdir(r"Videos\Fraser Surrey main intersection - videos")
os.mkdir(r"Videos\Fraser Surrey track crossing - videos")
os.mkdir(r"Videos\Fraser Surrey VACS gates - videos")
os.mkdir(r"Videos\Portside road - westbound - videos")
os.mkdir(r"Videos\PortsideBlundellNo.8 road intersection - videos")
os.mkdir(r"Videos\Terminal dock - videos")
os.mkdir(r"Videos\Vanterm Alliance Grain Terminal crossing - videos")
os.mkdir(r"Videos\Vanterm in gate - videos")
os.mkdir(r"Videos\Waterfront_road Centerm crossing - videos")

View File

@@ -1,5 +1,6 @@
import subprocess
import os
from datetime import datetime
video = ["Centerm in gate - videos", "Clark Drive overpass - videos", "Columbia Container - crossing - videos",
@@ -18,18 +19,27 @@ folder = ["Centerm in gate", "Clark Drive overpass", "Columbia Container - cross
"Terminal dock", "Vanterm Alliance Grain Terminal crossing", "Vanterm in gate", "Waterfront_road Centerm crossing"]
folderpair = list(zip(video, folder))
print(folderpair)
#increment video number
def imageToVideo(folder_name, videopath):
v = os.path.join("..", "Videos", videopath, "video.mp4")
v = str(v)
os.chdir(folder_name)
t = os.path.getmtime("image0001.jpg")
t = int(t)
dt = datetime.fromtimestamp(t)
print(dt)
name = dt.strftime("%Y-%m-%d %H.%M.%S")
name = name + ".mp4"
print(name)
v = os.path.join("..", "Videos", videopath, name)
v = str(v)
print(v)
subprocess.run(["ffmpeg",
"-f", "image2",
"-framerate", "2",
"-i", "image%04d.jpg",
"-c:v", "libx265",
"-c:v", "libx265",
v])
os.chdir("..")