Remove DRM from file
This commit is contained in:
parent
1aaa28d98d
commit
efdb203e2c
@ -6,14 +6,19 @@ import sys
|
||||
|
||||
class AudibleBook(object):
|
||||
|
||||
def __init__(self, filePath):
|
||||
def __init__(self, filePath, activationBytes):
|
||||
self.filePath = filePath
|
||||
self.activationBytes = activationBytes
|
||||
self.metadata = json.loads(os.popen('ffprobe -i {} -show_format \
|
||||
-print_format json'.format(filePath)).read())['format']['tags']
|
||||
self.chapters = json.loads(os.popen('ffprobe -i {} -print_format json \
|
||||
-show_chapters -loglevel error -sexagesimal'.format(self.filePath))
|
||||
.read())['chapters']
|
||||
|
||||
# getPath() returns path to origonal audible file.
|
||||
def getPath(self):
|
||||
return self.filePath
|
||||
|
||||
# getMetadata() returns audio metadata for a given filepath.
|
||||
def getMetadata(self):
|
||||
return self.metadata
|
||||
@ -26,6 +31,11 @@ class AudibleBook(object):
|
||||
def getTitle(self):
|
||||
return self.getMetadata()['title']
|
||||
|
||||
def removeDRM(self, fileName):
|
||||
os.system('ffmpeg -activation_bytes {} -i {} -c copy "{}.m4b"'
|
||||
.format(self.activationBytes, self.filePath, fileName))
|
||||
print('test')
|
||||
|
||||
# getHash() returns the hash of a given file.
|
||||
def getHash(filePath):
|
||||
with open(filePath, 'rb') as f:
|
||||
@ -59,9 +69,9 @@ if not os.path.exists(configFilePath):
|
||||
configString = '[Settings]\n' + open(configFilePath).read()
|
||||
configParser = configparser.RawConfigParser()
|
||||
configParser.read_string(configString)
|
||||
|
||||
activationBytes=configParser.get('Settings', 'activationBytes')
|
||||
|
||||
book = AudibleBook(audibleBookPath)
|
||||
book = AudibleBook(audibleBookPath, activationBytes)
|
||||
|
||||
for c in book.getChapters():
|
||||
start=c['start']
|
||||
@ -72,7 +82,6 @@ for c in book.getChapters():
|
||||
|
||||
|
||||
print(book.getTitle())
|
||||
print(configParser.get('Settings', 'activationBytes'))
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user