1

I'm trying to build a local video streaming web application with Django as its backend. I'm not looking to host the application online, its always going to remain in localhost. Now the problem I'm facing is Django only detects video files that are inside static files directory. But I can't have all my videos under static files directory and so not all files can be inside static files directory(preferably I don't want any video files to be inside it).

Sorry if I'm dumb but how do I make Django to scan my whole system for media files (or preferably only the directories I provide to it which is not necessarily from the frontend of that web app) without putting video files inside static directory? If its not possible, then how should I build such application?

And also I noticed that the video tag from HTML can't play x265 .mkv videos by default, is there a way to make them play it or should I settle with other formats like .mp4 alone?

Thanks in advance.

pyDdev
  • 97
  • 7

1 Answers1

0

Welcome to Stack Overflow (SO) :D. Please read https://stackoverflow.com/help/how-to-ask

The following code, will create a list of all the files


file_extensions = ['mp4',...'avi'] # create a list with all file extensions that you want

for f in file_extension: # directory holds the path to the folder in which the search will occur 
    media_files = [i for i in glob.glob(os.path.join(directory,'*.{}'.format(extension)))]`
Volpym
  • 161
  • 1
  • 1
  • 14
  • Your answer doesn't relate with my problem as my question was mainly about Django discovering directories that are not included in static files directory which clearly says its not about retrieving all media files in a directory. – pyDdev May 28 '20 at 17:15
  • To my knowledge there isn't a "Django way" to achieve what you want, that's why I suggested a pure pythonic way. Maybe someone with more experience can provide a better solution. – Volpym May 28 '20 at 17:41