Python Script to Check Movie Runtimes - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116) +--- Thread: Python Script to Check Movie Runtimes (/showthread.php?tid=89877) |
Python Script to Check Movie Runtimes - count_zero - 2011-01-07 I just installed xbmc a few months ago and use it to view all of my movies. I've had a couple of handbrake movie rips fail silently--that is, the movie runs fine the first 45 minutes, and then stops because the file is incomplete. I had this happen to me twice in the last month, which is very frustrating (and embarrassing) if you want to see the end of a movie. So, I wanted to check my video library (+1000 files) without having to play each file to the end. I wrote a small python script to automate this process for me. This very short script requires mplayer (to calculate runtimes) and IMDbPY (a python module API for IMDb, http://imdbpy.sourceforge.net/). I wrote it on Linux, but it *might* work on other OSes if you change the location of the mplayer executable in the script. Code: #!/usr/bin/env python I was able to search my entire collection (m4v and mkv files) with this command (on Linux): Code: find . \( -iname \*m4v -o -iname \*mkv \) -exec cklength.py '{}' \; > movie_runtimes.txt The output for each movie looks like this: Code: Action/Bourne Ultimatum.m4v (IMDb name: The Bourne Ultimatum) - 115 min (local) / 115 min (IMDb) The IMDb matches were not always perfect (the script searches IMDb based on the filename), but most were good enough. This could probably be integrated into an xbmc script for a better presentation (things like flagging a file if the times differed significantly, etc.), but I haven't had the time to study the xbmc API for doing this. (anyone with more knowledge than I have is welcome to it) Maybe this is not a problem for many people, but this script helped me immensely and I wanted to share it. Let me know if it's useful. Enjoy! |