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