DEV Community

Cover image for Reading metadata of media files using Python
Enis Habul
Enis Habul

Posted on • Edited on

Reading metadata of media files using Python

Hello there my name is Enis and this is my first post here :D

So where to start, i am IT Enthusiast and i am eager to learn different stuff. Lately i started with Python and i wanted to experiment with it. I am learning stuff from a lot of sources like books, yt tutorials and Udemy courses. When i am at home where i have good internet speed i watch courses on my Udemy account but sometimes when i am out of town i usually download course for offline use. I came to idea that it would be good to make python script to read metadata of videos to calculate my progress so i made this little terminal program.
I am using MediaInfo to read metadata of files. (more info you can find in my github repo README file)

Steps

  • Download course you want and save it in some folder

Pic 1

  • Open your favorite terminal (i am using cmder) and navigate to folder where you placed this script

  • Call this script and pass path to it (place where you saved your course)

    Example
     python VideoLength.py "D:\Udemy\Beginner Python and Coding Intro - Scripting a Virtual Car" 
Enter fullscreen mode Exit fullscreen mode

There is some arguments you can pass into it, if you don't pass anything you get this

Pic 2

Argument Usage Example
-s length of specified section VideoLength.py "path" -s 1
-v open folder location of course VideoLength.py "path" -s 1 -v
-p play all section videos with video player VideoLength.py "path" -s 1 -v -p
-t get course progress VideoLength.py "path" -s 1 -v -p -t

Argument -t must be used with -s argument

If you pass -s with combination of -t you can get how long of course you watched

Pic 3

You can also open location of course folder with argument -v and with argument -p you can play all of your videos with media player.

Alt Text

Top comments (0)