Open itinybad opened 2 years ago
There are 3 hooks supported:
Hook.task_about_to_start
Hook.task_about_to_download
Hook.task_finished
There are 3 hooks supported:
Hook.task_about_to_start Hook.task_about_to_download Hook.task_finished
Thanks for the reply, can you provide detailed documentation, or a sample script
Here is a sample:
from utils import Hook
import os
@Hook.task_about_to_start('test')
def hook(cw):
cw.print_('Hook: about_to_start')
cw.print_(f'type: {cw.type}')
@Hook.task_about_to_download('test')
def hook(cw):
cw.print_('Hook: about_to_download')
@Hook.task_finished('test')
def hook(cw):
cw.print_('Hook: finished')
if not cw.valid:
return
with open(os.path.join(cw.dir, 'hook_test.txt'), 'wb') as f:
f.write('url: {}'.format(cw.url).encode('utf8'))
I noticed the hook script, but only after the hook task is completed in the provided sample script, is there any related support?