|
@@ -1,22 +1,31 @@
|
|
|
#coding=utf-8
|
|
|
from _execute import *
|
|
|
+import concurrent.futures
|
|
|
+
|
|
|
+clickvideo = 2 # set to 1 to alert if video is found (DOES NOT CLICK!), requires whitelist
|
|
|
+# ^ set to 2 to click the video when found, requires whitelist
|
|
|
+# ^ any other value will only search for videos based on termlist
|
|
|
+savefile = 0 # set to 1 to save screenshot and ranking to file
|
|
|
+sec = 1
|
|
|
+client = "信義房屋"
|
|
|
|
|
|
def addvids(target):
|
|
|
pwhitelist = ['https://csr.sinyi.com.tw/governance/index.php','https://www.facebook.com/SinyiRealtyInc.HR/','https://csr.sinyi.com.tw/interactive/video.php','https://www.youtube.com/playlist?list=PLftfxwJcQDUCL8v2oB_jHWHue4I6vHyBz','https://hr.sinyi.com.tw/events/tvc/','https://hr.sinyi.com.tw/video','https://www.youtube.com/watch?v=rGQqegE8rbc','https://www.facebook.com/sinyifans/','https://www.youtube.com/channel/UCU76s7FGtDvDta2mf2Zdn4Q','https://csr.sinyi.com.tw/','https://events.sinyi.com.tw/20190828_webintro/','https://www.youtube.com/user/sinyicity','https://events.sinyi.com.tw/tvc2018-forhome/','https://hr.sinyi.com.tw/events/1/','https://hr.sinyi.com.tw/events/recommend/','https://events.sinyi.com.tw/sinyi40/','https://csr.sinyi.com.tw/interactive/video-employee.php','https://csr.sinyi.com.tw/interactive/video-environment.php','https://csr.sinyi.com.tw/interactive/video-society.php','https://csr.sinyi.com.tw/society/culture.php','https://csr.sinyi.com.tw/employee/index.php','https://www.youtube.com/watch?v=FqiKpqgB-bU','https://www.youtube.com/watch?v=UkxtlJAaqP8','https://www.youtube.com/watch?v=A5GuB3Enw9U','https://www.youtube.com/watch?v=fx4fTBh9PFo','https://events.sinyi.com.tw/tvc/''https://csr.sinyi.com.tw/interactive/video-enterprise.php','https://www.youtube.com/watch?v=GDYKd3cvEXk','https://www.youtube.com/watch?v=tEY5HCqs9oY','https://www.youtube.com/watch?v=7UGiKEc2JEU','https://www.youtube.com/watch?v=7Ay7ZQdV1Gw','https://www.youtube.com/watch?v=QzyTD949cVk','https://www.youtube.com/watch?v=4-sJLbMLP-0']
|
|
|
-
|
|
|
for v in pwhitelist:
|
|
|
if v not in target:
|
|
|
target.append(v)
|
|
|
|
|
|
return target
|
|
|
|
|
|
-clickvideo = 2 # set to 1 to alert if video is found (DOES NOT CLICK!), requires whitelist
|
|
|
-# ^ set to 2 to click the video when found, requires whitelist
|
|
|
-# ^ any other value will only search for videos based on termlist
|
|
|
-savefile = 0 # set to 1 to save screenshot and ranking to file
|
|
|
-sec = 1
|
|
|
-client = "信義房屋"
|
|
|
-target=[]
|
|
|
+def exe():
|
|
|
+ start_time = time.time()
|
|
|
+ target=[]
|
|
|
+ kw = pickterm(client)
|
|
|
+ target = addvids(target)
|
|
|
+ print(len(target))
|
|
|
+ process_one(kw, target, clickvideo, savefile, sec)
|
|
|
+ duration = time.time()-start_time
|
|
|
+ print("Runs: " + str(runcount) + " | Duration: " + str(duration))
|
|
|
|
|
|
if clickvideo == 1 or clickvideo == 2:
|
|
|
runcount=0
|
|
@@ -24,13 +33,13 @@ if clickvideo == 1 or clickvideo == 2:
|
|
|
while True:
|
|
|
try:
|
|
|
runcount+=1
|
|
|
- start_time = time.time()
|
|
|
- kw = pickterm(client)
|
|
|
- target = addvids(target)
|
|
|
- print(len(target))
|
|
|
- process_one(kw, target, clickvideo, savefile, sec)
|
|
|
- duration = time.time()-start_time
|
|
|
- print("Runs: " + str(runcount) + " | Duration: " + str(duration))
|
|
|
+ with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
|
|
|
+ future = executor.submit(exe)
|
|
|
+ try:
|
|
|
+ result = future.result(timeout=120)
|
|
|
+ print("Function completed")
|
|
|
+ except concurrent.futures.TimeoutError:
|
|
|
+ print("Function execution timed out")
|
|
|
except:
|
|
|
print('Runtime Error')
|
|
|
traceback.print_exc()
|