Skip converting already converted books
This commit is contained in:
parent
3edfd24181
commit
e2552db1be
@ -17,6 +17,7 @@ class AudibleBook(object):
|
||||
self.filePath = filePath
|
||||
self.activationBytes = activationBytes
|
||||
self.targetDir = targetDir
|
||||
self.convertedFilePath=''
|
||||
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 \
|
||||
@ -68,6 +69,10 @@ class AudibleBook(object):
|
||||
os.system('ffmpeg -i {} -an -vcodec copy {}'.
|
||||
format(self.convertedFilePath, outFilePath))
|
||||
|
||||
def deleteConverted(self):
|
||||
if self.convertedFilePath is not '' and os.path.exists(self.configFilePath):
|
||||
os.remove(self.convertedFilePath)
|
||||
|
||||
|
||||
# getHash() returns the hash of a given file.
|
||||
def getHash(filePath):
|
||||
@ -94,7 +99,7 @@ def createConfig(configFilePath, filePath):
|
||||
configFilePath='./settings.conf'
|
||||
audibleBookPath=sys.argv[1]
|
||||
serverURL=sys.argv[2]
|
||||
targetDir='.'
|
||||
targetDir='./audiobooks'
|
||||
|
||||
# Check if config file exists and creates one if needed.
|
||||
if not os.path.exists(configFilePath):
|
||||
@ -114,9 +119,12 @@ if not os.path.exists(outputDir):
|
||||
os.makedirs(outputDir)
|
||||
book.setTargetDir(outputDir)
|
||||
|
||||
book.removeDRM(name)
|
||||
book.splitChapters()
|
||||
book.getCover()
|
||||
rssFilePath='{}/rss.xml'.format(outputDir)
|
||||
|
||||
if not os.path.exists(rssFilePath):
|
||||
book.removeDRM(name)
|
||||
book.splitChapters()
|
||||
book.getCover()
|
||||
|
||||
fg = FeedGenerator()
|
||||
fg.id(name)
|
||||
@ -139,6 +147,5 @@ for c in book.getChapters():
|
||||
count += 1
|
||||
|
||||
rssfeed = fg.rss_str(pretty=True)
|
||||
fg.rss_file('{}/rss.xml'.format(outputDir))
|
||||
|
||||
print()
|
||||
fg.rss_file(rssFilePath)
|
||||
book.deleteConverted()
|
||||
|
Loading…
x
Reference in New Issue
Block a user