Daniel S
5543177e5d
Update license to GPL because the used libraries are also GPL Signed-off-by: Daniel S. <earthnuker@noreply.gitdab.com> initial commit
38 lines
No EOL
1.1 KiB
Python
38 lines
No EOL
1.1 KiB
Python
import cffi
|
|
import os
|
|
import sys
|
|
import time
|
|
from dvdnav import DVDNav
|
|
from dvdread import DVDRead
|
|
import subprocess as SP
|
|
import json
|
|
from vob_demux import demux
|
|
from ff_d2v import make_d2v
|
|
def loadlib(dll_path,*includes,**kwargs):
|
|
ffi = cffi.FFI()
|
|
for include in includes:
|
|
ffi.cdef(open(include).read(),kwargs)
|
|
return ffi,ffi.dlopen(dll_path)
|
|
|
|
os.environ["DVDCSS_VERBOSE"]="2"
|
|
os.environ["DVDCSS_METHOD"]="disc"
|
|
|
|
r=DVDRead(sys.argv[1])
|
|
out_folder=os.path.join("out","_".join([r.disc_id,r.udf_disc_name or r.iso_disc_name]).replace(" ","_"))
|
|
del r
|
|
os.makedirs(out_folder,exist_ok=True)
|
|
d=DVDNav(sys.argv[1])
|
|
for k,v in d.titles.items():
|
|
v['duration']=v['duration'].total_seconds()
|
|
v['chapters']=[c.total_seconds() for c in v['chapters']]
|
|
d.titles[k]=v
|
|
with open(os.path.join(out_folder,f"{k}.json"),"w") as fh:
|
|
json.dump(v,fh)
|
|
for a in range(v['angles']):
|
|
a+=1
|
|
outfile=os.path.join(out_folder,f"{k}_{a}.vob")
|
|
with open(outfile,"wb") as fh:
|
|
for block in d.get_blocks(k,a):
|
|
fh.write(block)
|
|
demux(outfile)
|
|
os.unlink(outfile) |