Commit 320726c1 authored by mitshel's avatar mitshel
Browse files

В конфигурацию добавлен параметр title_as_filename - на сонвоании которого...

В конфигурацию добавлен параметр title_as_filename - на сонвоании которого формируется имя скачиваемого файла (реальное имя файла или транслитерация title)
parent 50d48c60
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,3 +8,4 @@ py/*.log
fb2toepub/*
!fb2toepub/*.zip
testinfo/*
speed
+5 −0
Original line number Diff line number Diff line
@@ -94,6 +94,11 @@ temp_dir=/tmp
# По умолчанию будет считаться что single_commit=no
single_commit = yes

# Установка параметра title_as_filename = yes приведет к тому, что при скачивании книги имя файла будет изменено
# на транслитерацию заголовка (title) книги
# По умолчанию считается что title_as_filename = no
title_as_filename = yes

[site]
id=http://sopds.ru/
title=SOPDS.RU | OPDS Catalog
+8 −5
Original line number Diff line number Diff line
@@ -484,9 +484,10 @@ elif type_value==90:
elif type_value==91:
   (book_name,book_path,reg_date,format,title,annotation,cat_type,cover,cover_type,fsize)=opdsdb.getbook(slice_value)
   full_path=os.path.join(cfg.ROOT_LIB,book_path)
   transname=translit(book_name)
   if cfg.TITLE_AS_FN: transname=translit(title+'.'+format)
   else: transname=translit(book_name)
   # HTTP Header
   enc_print('Content-Type:application/octet-stream; name="'+book_name+'"')
   enc_print('Content-Type:application/octet-stream; name="'+transname+'"')
   enc_print("Content-Disposition: attachment; filename="+transname)
   enc_print('Content-Transfer-Encoding: binary')
   if cat_type==sopdsdb.CAT_NORMAL:
@@ -517,9 +518,10 @@ elif type_value==91:
elif type_value==92:
   (book_name,book_path,reg_date,format,title,annotation,cat_type,cover,cover_type,fsize)=opdsdb.getbook(slice_value)
   full_path=os.path.join(cfg.ROOT_LIB,book_path)
   transname=translit(book_name)
   if cfg.TITLE_AS_FN: transname=translit(title+'.'+format)
   else: transname=translit(book_name)
   # HTTP Header
   enc_print('Content-Type:application/zip; name="'+book_name+'"')
   enc_print('Content-Type:application/zip; name="'+transname+'"')
   enc_print("Content-Disposition: attachment; filename="+transname+'.zip')
   enc_print('Content-Transfer-Encoding: binary')
   if cat_type==sopdsdb.CAT_NORMAL:
@@ -558,7 +560,8 @@ elif type_value==93:
   (book_name,book_path,reg_date,format,title,annotation,cat_type,cover,cover_type,fsize)=opdsdb.getbook(slice_value)
   full_path=os.path.join(cfg.ROOT_LIB,book_path)
   (n,e)=os.path.splitext(book_name)
   transname=translit(n)+'.epub'
   if cfg.TITLE_AS_FN: transname=translit(title)+'.epub'
   else: transname=translit(n)+'.epub'
   if cat_type==sopdsdb.CAT_NORMAL:
      tmp_fb2_path=None
      file_path=os.path.join(full_path,book_name)
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ class cfgreader:
       self.DELETE_LOGICAL=config.getboolean(CFG_S_GLOBAL,'delete_logical')
       self.ZIPFILE_PATCH=config.getboolean_default(CFG_S_GLOBAL,'zipfile_patch',False)
       self.SINGLE_COMMIT=config.getboolean_default(CFG_S_GLOBAL,'single_commit',False)
       self.TITLE_AS_FN=config.getboolean_default(CFG_S_GLOBAL,'title_as_filename',False)
       fb2hsize=config.get(CFG_S_GLOBAL,'fb2hsize')
       maxitems=config.get(CFG_S_GLOBAL,'maxitems')
       splitauthors=config.get(CFG_S_GLOBAL,'splitauthors')