2

I am currently implementing a django project to help me with my studies. I would like to be able to monitor videos I watched (ie when? where I stopped if I did not watch it in full? how many times I watched it? ...). I don't plan to upload the videos to the database as it is several Gb of size, but to call with their path on my hard drive.

Basically the features I'm looking for are similar to the ones present in Kodi for those of you which know it.

I Googled for that question and could for instance found the following: How to check a user watched the full video in html5 video player

But the solutions suggested make use of Javascript which I am not very familiar with. Would there be a django/python way to get the event and then just save it to the database with the videos?

[EDIT: 25/09/2018 - Attempt to use Javascript]

Should I want to go with a Javascript/Django solution, may I ask for guidance on how to proceed?

I created a foo.html file in my django project as per the below:

[foo.html]

<video id="video1" width="240" height="200" controls="true" poster="">
    <source type="video/mp4" src="{% static 'my/path/my_video.mp4' %}"></source>
</video>

<script>
    document.getElementById('video1').addEventListener('ended', function(e) {
        // TO COMPLETE
    });
</script>

But then, I'd like to put something like

video = Video(name=name, is_watched=True, end_time=now())  # The Video class being defined in models.py as per Django paradigm.
video.save()

instead of the // TO COMPLETE, but I suspect only javascript can be used at this place. Is that correct? If so, would you know how I can close the gap between javascript and django so as to be able to update my database?

Thanks, Sophie

soso23
  • 83
  • 1
  • 8
  • Well the problem is that you can not guarantee that the video is watched with Django. A person could use a tool like `wget` to *download* the movie instead, but never watch it. So you need some programming at the browser to check that (that being said, even then a programmer can let the browser send fake requests that "verify" that the user sees the movie). – Willem Van Onsem Sep 22 '18 at 10:08
  • @WillemVanOnsem Thanks for the advice. But actually I will be the only one watching the videos and have no intention to "cheat" by downloading them... All I'm looking for now is a quick solution as I cannot invest time learning javascript script because of the exams I have to prepare for school. I will definitely look for a better solution later on. – soso23 Sep 22 '18 at 11:56

0 Answers0