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)
|
2019-01-29 13:16:12 +00:00
|
|
|
files = rar.namelist()
|
|
|
|
if files:
|
|
|
|
cover = ox.sorted_strings(files)[0]
|
|
|
|
data = rar.read(cover)
|
2019-01-29 10:20:43 +00:00
|
|
|
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
|
|
|
|
|