File hash
This commit is contained in:
parent
a35f9d05d4
commit
aa7c0fb106
@ -1,3 +1,4 @@
|
|||||||
|
import configparser
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
@ -20,7 +21,21 @@ class AudibleBook(object):
|
|||||||
def getChapters(self):
|
def getChapters(self):
|
||||||
return self.chapters
|
return self.chapters
|
||||||
|
|
||||||
filePath=''
|
# getTitle() returns audiobook title.
|
||||||
|
def getTitle(self):
|
||||||
|
return self.getMetadata()['title']
|
||||||
|
|
||||||
|
# getHash() returns the hash of a given file.
|
||||||
|
def getHash(filePath):
|
||||||
|
with open(filePath, 'rb') as f:
|
||||||
|
f.seek(653)
|
||||||
|
data = f.read(20)
|
||||||
|
f.close()
|
||||||
|
return data.hex()
|
||||||
|
|
||||||
|
configString = '[Settings]\n' + open('./settings.conf').read()
|
||||||
|
configParser = configparser.RawConfigParser()
|
||||||
|
configParser.read_string(configString)
|
||||||
book = AudibleBook(sys.argv[1])
|
book = AudibleBook(sys.argv[1])
|
||||||
|
|
||||||
for c in book.getChapters():
|
for c in book.getChapters():
|
||||||
@ -31,4 +46,8 @@ for c in book.getChapters():
|
|||||||
#os.system('ffmpeg -i {} -acodec copy -vcodec copy -ss {} -t {} OUTFILE-{}.m4a'.format(filePath, start, end, title))
|
#os.system('ffmpeg -i {} -acodec copy -vcodec copy -ss {} -t {} OUTFILE-{}.m4a'.format(filePath, start, end, title))
|
||||||
|
|
||||||
|
|
||||||
print(book.getMetadata())
|
print(book.getTitle())
|
||||||
|
print(configParser.get('Settings', 'activationBytes'))
|
||||||
|
|
||||||
|
|
||||||
|
print(getHash(sys.argv[1]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user