File hash

This commit is contained in:
Christian Colglazier 2021-08-14 09:52:54 -04:00
parent a35f9d05d4
commit aa7c0fb106

View File

@ -1,3 +1,4 @@
import configparser
import os
import json
import sys
@ -19,8 +20,22 @@ class AudibleBook(object):
# getChapters() returns chapter metadata for a given filepath.
def getChapters(self):
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])
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))
print(book.getMetadata())
print(book.getTitle())
print(configParser.get('Settings', 'activationBytes'))
print(getHash(sys.argv[1]))