Files
autoDvdRipper/main.py
2025-08-13 20:02:21 +01:00

44 lines
1.5 KiB
Python

import openDrive
import time
import os
from imdb import Cinemagoer
DVD_DEVICE = "/dev/sr0"
def ripDvd(driveName):
print("- DVD has been detected")
print("- Searching IMDB for " + driveName)
ia = Cinemagoer()
try:
movie = ia.get_movie(ia.search_movie(driveName)[0].getID())
movieName = movie['title'] + " (" + str(movie["year"]) + ")"
print("- Movie has been identified as " + movieName)
print("- Movie has been found, will now procede to ripping DVD")
except IndexError:
print("- Movie could not be found, will use name " + driveName)
print("- Will now procede to ripping DVD")
movieName = driveName
os.system('HandBrakeCLI -i /dev/sr0 -o "' + movieName + '.mp4" --preset-import-file preset.json')
def waitForDvd():
print("- Insert a DVD into drive")
time.sleep(3)
dvdfound = False
while (dvdfound == False):
fh = open ("/etc/mtab", "r")
for i in fh:
if i.split(" ", 1)[0] == DVD_DEVICE:
dvdfound = True
driveName = i.split(" ", 1)[1].split("/")[-1].split(" ")[0]
ripDvd(driveName)
fh.close()
time.sleep(1)
print("-----------------------------------------------")
print("- Auto DVD Ripper -")
print("-----------------------------------------------")
input("-------- Press enter to open dvd drive --------\n-----------------------------------------------\n")
openDrive.open()
waitForDvd()