From 87d7e314491b8751faa190bf098a7a0c1c028565 Mon Sep 17 00:00:00 2001 From: Hugo H Date: Wed, 13 Aug 2025 20:02:21 +0100 Subject: [PATCH] Added existing project --- main.py | 44 ++++++++++++++++++ openDrive.py | 32 +++++++++++++ preset.json | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 main.py create mode 100644 openDrive.py create mode 100644 preset.json diff --git a/main.py b/main.py new file mode 100644 index 0000000..ddc3154 --- /dev/null +++ b/main.py @@ -0,0 +1,44 @@ +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() \ No newline at end of file diff --git a/openDrive.py b/openDrive.py new file mode 100644 index 0000000..4bb3d8b --- /dev/null +++ b/openDrive.py @@ -0,0 +1,32 @@ +from platform import system as platform_name +from os import system + + +platforms_dictionary = { + "Windows": { # + "open" : 'ctypes.windll.WINMM.mciSendStringW(u"open L: type CDAudio alias L_drive", None, 0, None); ctypes.windll.WINMM.mciSendStringW(u"set L_drive door open", None, 0, None)', + "close": 'ctypes.windll.WINMM.mciSendStringW(u"open L: type CDAudio alias L_drive", None, 0, None); ctypes.windll.WINMM.mciSendStringW(u"set L_drive door closed", None, 0, None)' + }, + "Darwin": { + "open" : 'system("drutil tray open")', + "close": 'system("drutil tray closed")' + }, + "Linux": { + "open" : 'system("eject cdrom")', + "close": 'system("eject -t cdrom")' + }, + "NetBSD": { + "open" : 'system("eject cd")', + "close": 'system("eject -t cd")' + }, + "FreeBSD": { + "open" : 'system("sudo cdcontrol eject")', + "close": 'system("sudo cdcontrol close")' + } +} + +def open(): + if platform_name() in platforms_dictionary: + exec(platforms_dictionary[platform_name()]["open"]) + else: + print("OS not supported") \ No newline at end of file diff --git a/preset.json b/preset.json new file mode 100644 index 0000000..24beba2 --- /dev/null +++ b/preset.json @@ -0,0 +1,124 @@ +{ + "PresetList": [ + { + "AlignAVStart": true, + "AudioCopyMask": [ + "copy:aac" + ], + "AudioEncoderFallback": "av_aac", + "AudioLanguageList": [], + "AudioList": [ + { + "AudioBitrate": 160, + "AudioCompressionLevel": -1.0, + "AudioDitherMethod": "auto", + "AudioEncoder": "av_aac", + "AudioMixdown": "stereo", + "AudioNormalizeMixLevel": false, + "AudioSamplerate": "auto", + "AudioTrackDRCSlider": 0.0, + "AudioTrackGainSlider": 0.0, + "AudioTrackQuality": -1.0, + "AudioTrackQualityEnable": false + } + ], + "AudioSecondaryEncoderMode": true, + "AudioTrackSelectionBehavior": "first", + "ChapterMarkers": true, + "ChildrenArray": [], + "Default": true, + "FileFormat": "av_mp4", + "Folder": false, + "FolderOpen": false, + "InlineParameterSets": false, + "MetadataPassthru": true, + "Mp4iPodCompatible": false, + "Optimize": false, + "PictureAllowUpscaling": false, + "PictureAutoCrop": true, + "PictureBottomCrop": 0, + "PictureChromaSmoothCustom": "", + "PictureChromaSmoothPreset": "off", + "PictureChromaSmoothTune": "none", + "PictureColorspaceCustom": "", + "PictureColorspacePreset": "off", + "PictureCombDetectCustom": "", + "PictureCombDetectPreset": "default", + "PictureCropMode": 0, + "PictureDARWidth": 0, + "PictureDeblockCustom": "strength=strong:thresh=20:blocksize=8", + "PictureDeblockPreset": "off", + "PictureDeblockTune": "medium", + "PictureDeinterlaceCustom": "", + "PictureDeinterlaceFilter": "decomb", + "PictureDeinterlacePreset": "default", + "PictureDenoiseCustom": "", + "PictureDenoiseFilter": "off", + "PictureDenoisePreset": "light", + "PictureDenoiseTune": "none", + "PictureDetelecine": "off", + "PictureDetelecineCustom": "", + "PictureForceHeight": 0, + "PictureForceWidth": 0, + "PictureHeight": 1080, + "PictureItuPAR": false, + "PictureKeepRatio": true, + "PictureLeftCrop": 0, + "PictureModulus": 2, + "PicturePAR": "auto", + "PicturePARHeight": 720, + "PicturePARWidth": 853, + "PicturePadBottom": 0, + "PicturePadColor": "black", + "PicturePadLeft": 0, + "PicturePadMode": "none", + "PicturePadRight": 0, + "PicturePadTop": 0, + "PictureRightCrop": 0, + "PictureRotate": "angle=0:hflip=0", + "PictureSharpenCustom": "", + "PictureSharpenFilter": "off", + "PictureSharpenPreset": "medium", + "PictureSharpenTune": "none", + "PictureTopCrop": 0, + "PictureUseMaximumSize": true, + "PictureWidth": 1920, + "PresetDescription": "H.264 video (up to 1080p30) and AAC stereo audio, in an MP4 container.", + "PresetDisabled": false, + "PresetName": "Fast 1080p30", + "SubtitleAddCC": false, + "SubtitleAddForeignAudioSearch": true, + "SubtitleAddForeignAudioSubtitle": false, + "SubtitleBurnBDSub": false, + "SubtitleBurnBehavior": "foreign", + "SubtitleBurnDVDSub": false, + "SubtitleLanguageList": [], + "SubtitleTrackSelectionBehavior": "none", + "Type": 0, + "UsesPictureFilters": true, + "VideoAvgBitrate": 6000, + "VideoColorMatrixCodeOverride": 0, + "VideoEncoder": "x264", + "VideoFramerate": "30", + "VideoFramerateMode": "pfr", + "VideoGrayScale": false, + "VideoHWDecode": 0, + "VideoLevel": "4.0", + "VideoMultiPass": true, + "VideoOptionExtra": "", + "VideoPreset": "fast", + "VideoProfile": "main", + "VideoQSVDecode": false, + "VideoQualitySlider": 22.0, + "VideoQualityType": 2, + "VideoScaler": "swscale", + "VideoTune": "", + "VideoTurboMultiPass": true, + "x264Option": "", + "x264UseAdvancedOptions": false + } + ], + "VersionMajor": 59, + "VersionMicro": 0, + "VersionMinor": 0 +} \ No newline at end of file