summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2009-06-24 11:36:03 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2009-06-24 11:36:03 -0400
commit46ff6617da1c3917cadf937b2bb75e2c4652c46b (patch)
tree6eaa7d1366c4c9887725ea73e9a09d314fac6a68
downloadOldSchoolRipper-46ff6617da1c3917cadf937b2bb75e2c4652c46b.tar.xz
OldSchoolRipper-46ff6617da1c3917cadf937b2bb75e2c4652c46b.zip
Initial commit.
-rwxr-xr-xrip.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/rip.py b/rip.py
new file mode 100755
index 0000000..4a0b448
--- /dev/null
+++ b/rip.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+import threading
+import ftplib
+import os
+import sys
+import time
+import string
+from random import choice
+
+def makeRandomString(length=8, chars=string.letters + string.digits):
+ return ''.join([choice(chars) for i in range(length)])
+
+class Rip(threading.Thread):
+ def run(self):
+ while True:
+ os.system("zenity --warning --text=\"Insert a DVD and press OK.\"")
+ logEvent("DVD Rip Begin")
+ os.system("dvdbackup -o./ripping -F")
+ logEvent("DVD Rip End")
+ os.system("eject /dev/dvd")
+ os.system("mv ./ripping/* ./toencode/")
+
+class Encode(threading.Thread):
+ def run(self):
+ while True:
+ listing = os.listdir("./toencode")
+ for i in range(len(listing)):
+ os.system("nautilus ./toencode/" + listing[i] + "/VIDEO_TS/")
+ os.system("zenity --warning --text=\"A file browser has just appeared. Please delete any VOB files that are not part of the main feature of the film. Do not touch non VOB files. When you are done, close the file browser window, press OK and the encoding will begin.\"")
+ logEvent("Encoding Begin", listing[i])
+ os.system("cat ./toencode/" + listing[i] + "/VIDEO_TS/*.VOB | ffmpeg -y -i - -pass 1 -vcodec libx264 -deinterlace -vpre fastfirstpass -b 400k -bt 400k -threads 2 -f mp4 -an /dev/null")
+ os.system("cat ./toencode/" + listing[i] + "/VIDEO_TS/*.VOB | ffmpeg -i - -pass 2 -acodec libfaac -ab 96k -ac 2 -vcodec libx264 -deinterlace -vpre hq -b 400k -bt 400k -threads 2 -f mp4 " + listing[i] + ".mp4")
+ os.system("/home/anyclip/ffmpeg/tools/qt-faststart " + listing[i] + ".mp4 " + listing[i] + "_fast.mp4")
+ logEvent("Encoding End", listing[i])
+ os.system("rm *.log " + listing[i] + ".mp4")
+ os.rename(listing[i] + "_fast.mp4", "./toupload/" + listing[i] + ".mp4")
+ os.rename("./toencode/" + listing[i], "./encoded/" + listing[i])
+ time.sleep(4)
+
+class Upload(threading.Thread):
+ def run(self):
+ while True:
+ listing = os.listdir("./toupload")
+ if len(listing) > 0:
+ ftp = ftplib.FTP("ftp2.edgecastcdn.net")
+ ftp.login("chris@anyclip.com", "ChrisEdge1234")
+ ftp.cwd("movies")
+ for i in range(len(listing)):
+ movieFile = open("./toupload/" + listing[i], "rb")
+ print "Uploading " + listing[i]
+ randomString = makeRandomString()
+ correlation = open("correlation.csv", "a")
+ correlation.write(listing[i] + "," + randomString + "\n")
+ correlation.close()
+ logEvent("Uploading Begin", listing[i])
+ ftp.storbinary("STOR " + randomString + "_400.mp4", movieFile)
+ logEvent("Uploading End", listing[i])
+ movieFile.close()
+ os.rename("./toupload/" + listing[i], "./uploaded/" + listing[i])
+ if len(listing) > 0:
+ ftp.quit()
+ time.sleep(4)
+
+if not os.path.exists("./toupload"):
+ os.mkdir("./toupload")
+if not os.path.exists("./uploaded"):
+ os.mkdir("./uploaded")
+if not os.path.exists("./toencode"):
+ os.mkdir("./toencode")
+if not os.path.exists("./encoded"):
+ os.mkdir("./encoded")
+if not os.path.exists("./ripping"):
+ os.mkdir("./ripping")
+
+log = open("ripperlog.csv", "a")
+def logEvent(event, target="-"):
+ log.write(time.asctime() + "," + event + "," + target + "\n")
+ log.flush()
+logEvent("Program Start")
+
+Rip().start()
+Encode().start()
+Upload().start() \ No newline at end of file