diff --git a/audible-converter.py b/audible-converter.py index 053c9a7..4fdc498 100644 --- a/audible-converter.py +++ b/audible-converter.py @@ -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]))