openmedialibrary/oml/media/cbr.py

30 lines
626 B
Python
Raw Normal View History

2015-03-14 07:35:15 +00:00
# -*- coding: utf-8 -*-
import os
2019-01-29 10:20:43 +00:00
import ox
2015-03-14 07:35:15 +00:00
def cover(path):
data = None
#open rar file and extract first page here
2019-01-29 10:20:43 +00:00
try:
from unrar import rarfile
rar = rarfile.RarFile(path)
for cover in ox.sorted_strings(rar.namelist()):
try:
data = rar.read(cover)
except:
data = None
finally:
return data
except:
data = None
2015-03-14 07:35:15 +00:00
return data
def info(path):
data = {}
data['title'] = os.path.splitext(os.path.basename(path))[0]
#data['pages'] = fixme read rar to count pages
return data