Logging downloads

I am running CB 2.8.3
I would like to log download activity and store IPaddress, time, videoid and resolution.
I have created a separate database and php files. By opening phpfile1 I can trigger phpfile2 to get credentials from a third file and obtain the data and insert it into the database. How can I trigger it with the download action?
I assume I need to attach the code to the watch_video.php page, but what is my trigger? I have not found a way to trigger from the downloadMenu1 in the html file.

Any help would be appreciated or even offers to supply working code for a price would be considered.
Thanks. Dave