Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Merged in new ripping code #9

Merged
merged 3 commits into from

1 participant

@beatgammit
Collaborator

I haven't been able to test this on a working DVD. There are a couple of TODOs:

  • driveLetter isn't used: makemkv uses disc numbers (0: first drive with disc, 1: second...)
  • makemkv can't read some DVDs (it didn't work with my copy of Gattaca)

We'll have to change this soon, but I think it's a good starting point.

@beatgammit beatgammit merged commit bdc3ba8 into brendonbeebe:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2013
  1. @beatgammit
  2. Merge branch 'master' into rip2

    T. Jameson Little authored
  3. Updated ripper

    T. Jameson Little authored
This page is out of date. Refresh to see the latest.
Showing with 42 additions and 74 deletions.
  1. +1 −5 README.md
  2. +2 −4 driveMonitor.py
  3. +0 −65 rip.py
  4. +39 −0 ripper.py
View
6 README.md
@@ -4,8 +4,4 @@ AutoMovieArchive
![Alt text](images/PertChart.png "Pert Chart")
-WMI support
------------
-
-WMI support is enabled by default on most recent versions of Windows. To get support in Python, install the [wrapper library](http://timgolden.me.uk/python/wmi/index.html).
-After that, *detector.py* should work as expected: run *detector.py* then insert or remove a drive.
+All python code included is designed to work with IronPython on Windows.
View
6 driveMonitor.py
@@ -16,10 +16,8 @@ def CDREventArrived(sender, e):
movieName = titleRetriever.getMovieName();
Console.WriteLine("Found: "+movieName)
- ##TODO: rip ths
- #cdRipper = ripper(titleRetriever.driveLetter, movieName)
-
- ##ripper.rip()
+ mkvFile = ripper.rip(titleRetriever.driveLetter, movieName)
+ ripper.transcode(mkvFile, movieName)
else:
Console.WriteLine("CD has been ejected")
View
65 rip.py
@@ -1,65 +0,0 @@
-#!/usr/bin/env python
-import subprocess
-import sys
-import re
-
-def parseMetadata(devicePath):
- args = ['HandBrakeCLI', '-i', devicePath, '-t', '0']
- print("Running:" + ' '.join(args))
- p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-# p = subprocess.Popen(['HandBrakeCLI', '-i', '/dev/sr0', '-o', 'strange--brew.mp4', '-f', 'mp4', '-e', 'x264'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-
- def byline():
- while p.poll() is None:
- yield p.stdout.readline().decode('utf-8')
-
- redvdtitle = re.compile('DVD Title: ([A-Z_]+)')
- retitle = re.compile('^\+ title (\d+):')
- reduration = re.compile('^\s+\+ duration: (\d+):(\d+):(\d+)')
-
-
- dvdtitle = None
- for line in byline():
- m = redvdtitle.search(line)
- if m:
- dvdtitle = m.group(1)
- break
-
- titles = list()
- tTitle = None
- for line in byline():
- if lookingForTitle:
- m = retitle.search(line)
- if m:
- tTitle = {'title': m.group(1)}
- lookingForTitle = False
- lookingForDuration = True
- continue
-
- if lookingForDuration:
- m = reduration.search(line)
- if m:
- hours, minutes, seconds = [int(x, 10) for x in m.group(1, 2, 3)]
- tTitle['duration'] = hours*3600 + minutes*60 + seconds
- titles.append(tTitle)
- lookingForDuration = False
- lookingForTitle = True
- continue
-
- feature = max(titles, key=lambda x: x['duration'])
-
- return dvdtitle, feature['title']
-
-def rip(out, src, track=1):
- ret = subprocess.call(['HandBrakeCLI', '-i', src, '-o', out, '-f', 'mp4', '-e', 'x264', '-t', str(track)], stdout=sys.stdout, stderr=sys.stderr)
- if ret != 0:
- print("Error ripping DVD")
- else:
- print("Done!")
-
-print('Getting info from disk')
-title, track = parseMetadata('/dev/sr0')
-
-title = title.replace("_", " ").title()
-print("Ripping %s. This may take a while:" % title)
-rip(title+".mp4", '/dev/sr0', track)
View
39 ripper.py
@@ -0,0 +1,39 @@
+from System.Diagnostics import Process
+from System.IO import Path, Directory
+
+def transcode(mkvFile, movieName):
+ p = Process()
+ p.StartInfo.UseShellExecute = False
+ #p.StartInfo.RedirectStandardOutput = True
+ p.StartInfo.FileName = "HandBrakeCLI"
+ p.StartInfo.Arguments = "-i %s -o %s.mp4 -f mp4 -e x264" % (mkvFile, movieName)
+ if p.Start():
+ print("Transcoding")
+ p.WaitForExit()
+ if p.ExitCode == 0:
+ print("Successfully transcoded %s" % movieName)
+ else:
+ print("Error: %d" % p.ExitCode)
+ else:
+ print("Error transcoding, quitting")
+
+def rip(driveLetter, movieName):
+ out = Path.Combine(Path.GetTempPath(), movieName)
+ p = Process()
+ p.StartInfo.UseShellExecute = False
+ #p.StartInfo.RedirectStandardOutput = True
+ p.StartInfo.FileName = "makemkvcon"
+ p.StartInfo.Arguments = "--minlength=300 mkv disc:0 all %s" % out
+ print("Saving to:", out)
+ print(p.StartInfo.Arguments)
+ if p.Start():
+ print("Ripping")
+ p.WaitForExit()
+ if p.ExitCode == 0:
+ print("Successfully ripped %s" % movieName)
+
+ return Directory.GetFiles(out)[0]
+ else:
+ print("Error: %d" % p.ExitCode)
+ else:
+ print("Error ripping, quitting")
Something went wrong with that request. Please try again.