openmedialibrary/oml/media/cbr.py
2019-01-29 16:47:48 +05:30

29 lines
626 B
Python

# -*- coding: utf-8 -*-
import os
import ox
def cover(path):
data = None
#open rar file and extract first page here
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
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