Commit 82205233 authored by mitshel's avatar mitshel
Browse files

Исправлена ошибка лишнего тега <entry>

Исправлены ошибки назначения идентификаторов для entry
parent 6e4f4f94
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -50,3 +50,39 @@ INFO [2014-04-14 21:25:34,937] Time estimated:0 hours, 3 minutes, 43 seconds
2014-04-16 01:03:09,792 INFO     Archives skipped : 127
2014-04-16 01:03:09,792 INFO     Bad archives     : 0
2014-04-16 01:03:09,792 INFO     Time estimated:0 hours, 3 minutes, 6 seconds.
2014-04-16 20:46:00,223 INFO      ***** Starting sopds-scan...
2014-04-16 20:49:32,500 INFO     Books added      : 0
2014-04-16 20:49:32,520 INFO     Books skipped    : 5569
2014-04-16 20:49:32,520 INFO     Books DB entries deleted : 0
2014-04-16 20:49:32,521 INFO     Books in archives: 0
2014-04-16 20:49:32,521 INFO     Archives scanned : 35
2014-04-16 20:49:32,521 INFO     Archives skipped : 127
2014-04-16 20:49:32,522 INFO     Bad archives     : 0
2014-04-16 20:49:32,522 INFO     Time estimated:0 hours, 3 minutes, 32 seconds.
2014-04-16 21:10:36,116 INFO      ***** Starting sopds-scan...
2014-04-16 21:13:31,660 INFO     Books added      : 0
2014-04-16 21:13:31,660 INFO     Books skipped    : 5569
2014-04-16 21:13:31,661 INFO     Books DB entries deleted : 0
2014-04-16 21:13:31,661 INFO     Books in archives: 0
2014-04-16 21:13:31,662 INFO     Archives scanned : 35
2014-04-16 21:13:31,662 INFO     Archives skipped : 127
2014-04-16 21:13:31,662 INFO     Bad archives     : 0
2014-04-16 21:13:31,663 INFO     Time estimated:0 hours, 2 minutes, 55 seconds.
2014-04-17 01:00:03,900 INFO      ***** Starting sopds-scan...
2014-04-17 01:03:08,967 INFO     Books added      : 0
2014-04-17 01:03:08,982 INFO     Books skipped    : 5569
2014-04-17 01:03:08,982 INFO     Books DB entries deleted : 0
2014-04-17 01:03:08,982 INFO     Books in archives: 0
2014-04-17 01:03:08,982 INFO     Archives scanned : 35
2014-04-17 01:03:08,983 INFO     Archives skipped : 127
2014-04-17 01:03:08,983 INFO     Bad archives     : 0
2014-04-17 01:03:08,983 INFO     Time estimated:0 hours, 3 minutes, 5 seconds.
2014-04-18 01:00:05,077 INFO      ***** Starting sopds-scan...
2014-04-18 01:03:07,394 INFO     Books added      : 0
2014-04-18 01:03:07,419 INFO     Books skipped    : 5569
2014-04-18 01:03:07,419 INFO     Books DB entries deleted : 0
2014-04-18 01:03:07,419 INFO     Books in archives: 0
2014-04-18 01:03:07,420 INFO     Archives scanned : 35
2014-04-18 01:03:07,420 INFO     Archives skipped : 127
2014-04-18 01:03:07,420 INFO     Bad archives     : 0
2014-04-18 01:03:07,420 INFO     Time estimated:0 hours, 3 minutes, 2 seconds.
+59 −62
Original line number Diff line number Diff line
@@ -10,71 +10,9 @@ import sopdscfg
import base64
import zipf
import logging

##########################################################################
# Считываем параметры командной строки
# пример возможных параметров
# sopds-scan.py <--scanfull | --scanlast | --scan | -s> [ [-c <configfile>]
#
# -s, --scan, --scanfull  - Полное пересканирование всех файлов библиотеки (по умолчанию)
# --scanlast              - Обрабатываются только файлы с датой поздней, чем дата последнего сканирования (не сделано)
# -v, --verbose           - Включить вывод отладочной информации
# -c <configfile>         - Указывается путь к файлу конфигурации

from optparse import OptionParser
from sys import argv

t1=datetime.timedelta(seconds=time.time())

parser=OptionParser(conflict_handler="resolve", version="sopds-scan.py. Version 0.17", add_help_option=True, usage='sopds-scan.py [options]', description='sopds-scan.py: Simple OPDS Scanner - programm for scan your e-books directory and store data to MYSQL database.')
parser.add_option('-v','--verbose', action='store_true', dest='verbose', default=False, help='Enable verbose output')
parser.add_option('-c','--config',dest='configfile',default='',help='Config file pargh')
(options,arguments)=parser.parse_args()

VERBOSE=options.verbose
CFG_FILE=options.configfile

if CFG_FILE=='': cfg=sopdscfg.cfgreader()
else: cfg=sopdscfg.cfgreader(CFG_FILE)

zipf.ZIP_CODEPAGE=cfg.ZIP_CODEPAGE

if cfg.LOGLEVEL!=logging.NOTSET:
    # Создаем обработчик для записи логов в файл
    fh = logging.FileHandler(cfg.LOGFILE)
    fh.setLevel(cfg.LOGLEVEL)

if VERBOSE:
   # Создадим обработчик для вывода логов на экран с максимальным уровнем вывода
   ch = logging.StreamHandler()
   ch.setLevel(logging.DEBUG)

logformat='%(asctime)s %(levelname)-8s %(message)s'
if VERBOSE:
   logging.basicConfig(format = logformat, level = logging.DEBUG, handlers=(fh,ch))
else:
   logging.basicConfig(format = logformat, level = logging.INFO, handlers=(fh,))

logging.info(' ***** Starting sopds-scan...')
logging.debug('OPTIONS SET')
if cfg.CONFIGFILE!=None:     logging.debug('configfile = '+cfg.CONFIGFILE)
if cfg.ROOT_LIB!=None:       logging.debug('root_lib = '+cfg.ROOT_LIB)
if cfg.FB2TOEPUB_PATH!=None: logging.debug('fb2toepub = '+cfg.FB2TOEPUB_PATH)
if cfg.FB2TOMOBI_PATH!=None: logging.debug('fb2tomobi = '+cfg.FB2TOMOBI_PATH)
if cfg.TEMP_DIR!=None:       logging.debug('temp_dir = '+cfg.TEMP_DIR)

#############################################################################
#
# Переменные для сбора статистики
#
books_added   = 0
books_skipped = 0
books_deleted = 0
arch_scanned = 0
arch_skipped = 0
bad_archives = 0
books_in_archives = 0

#############################################################################
#
# Вспомогательные функции
@@ -211,6 +149,61 @@ def processzip(db,fb2,name,full_path,file):
       arch_skipped+=1
       logging.debug('Skip ZIP archive '+rel_file+'. Already scanned.')

#############################################################################
# Инициализируем переменные для сбора статистики
#
t1=datetime.timedelta(seconds=time.time())
books_added   = 0
books_skipped = 0
books_deleted = 0
arch_scanned = 0
arch_skipped = 0
bad_archives = 0
books_in_archives = 0

###########################################################################
# Разбираем опции командной строки и конфиг файла
#
parser=OptionParser(conflict_handler="resolve", version="sopds-scan.py. Version "+sopdscfg.VERSION, add_help_option=True, usage='sopds-scan.py [options]', description='sopds-scan.py: Simple OPDS Scanner - programm for scan your e-books directory and store data to MYSQL database.')
parser.add_option('-v','--verbose', action='store_true', dest='verbose', default=False, help='Enable verbose output')
parser.add_option('-c','--config',dest='configfile',default='',help='Config file pargh')
(options,arguments)=parser.parse_args()
VERBOSE=options.verbose
CFG_FILE=options.configfile

if CFG_FILE=='': cfg=sopdscfg.cfgreader()
else: cfg=sopdscfg.cfgreader(CFG_FILE)

zipf.ZIP_CODEPAGE=cfg.ZIP_CODEPAGE


###########################################################################
# Инициализруем logger
#
if cfg.LOGLEVEL!=logging.NOTSET:
    # Создаем обработчик для записи логов в файл
    fh = logging.FileHandler(cfg.LOGFILE)
    fh.setLevel(cfg.LOGLEVEL)

if VERBOSE:
   # Создадим обработчик для вывода логов на экран с максимальным уровнем вывода
   ch = logging.StreamHandler()
   ch.setLevel(logging.DEBUG)

logformat='%(asctime)s %(levelname)-8s %(message)s'
if VERBOSE:
   logging.basicConfig(format = logformat, level = logging.DEBUG, handlers=(fh,ch))
else:
   logging.basicConfig(format = logformat, level = logging.INFO, handlers=(fh,))

logging.info(' ***** Starting sopds-scan...')
logging.debug('OPTIONS SET')
if cfg.CONFIGFILE!=None:     logging.debug('configfile = '+cfg.CONFIGFILE)
if cfg.ROOT_LIB!=None:       logging.debug('root_lib = '+cfg.ROOT_LIB)
if cfg.FB2TOEPUB_PATH!=None: logging.debug('fb2toepub = '+cfg.FB2TOEPUB_PATH)
if cfg.FB2TOMOBI_PATH!=None: logging.debug('fb2tomobi = '+cfg.FB2TOMOBI_PATH)
if cfg.TEMP_DIR!=None:       logging.debug('temp_dir = '+cfg.TEMP_DIR)

###########################################################################
# Основной код программы
#
@@ -245,6 +238,10 @@ else:
opdsdb.update_double()
opdsdb.closeDB()


###########################################################################
# Вывод статистической информации по окончании программы сканирования
#
t2=datetime.timedelta(seconds=time.time())
logging.info('Books added      : '+str(books_added))
logging.info('Books skipped    : '+str(books_skipped))
+15 −16
Original line number Diff line number Diff line
@@ -156,7 +156,6 @@ def authors_submenu(author_id):
   enc_print('<title>Книги по алфавиту</title>')
   enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=33'+str(author_id)+'"/>')
   enc_print('<id>id:33:authors</id></entry>')
   enc_print('<entry>')

def entry_start():
   enc_print('<entry>')
@@ -357,7 +356,7 @@ elif type_value==1:
   header('id:catalogs','Сортировка по каталогам хранения')
   for (item_type,item_id,item_name,item_path,reg_date,item_title,annotation,docdate,format,fsize,cover,cover_type) in opdsdb.getitemsincat(slice_value,cfg.MAXITEMS,page_value):
       entry_start()
       entry_head(item_title, reg_date, id_value)
       entry_head(item_title, reg_date, 'item:'+str(item_id))
       if item_type==1:
          id='01'+str(item_id)
          entry_link_subsection(id)
@@ -403,7 +402,7 @@ elif type_value==2:
         id='02'+id

       entry_start()
       entry_head(letters, None, id_value)
       entry_head(letters, None, id)
       entry_link_subsection(id)
       entry_content('Всего: '+str(cnt)+' автора(ов).')
       entry_finish()
@@ -431,7 +430,7 @@ elif type_value==6:
         id='06'+id

       entry_start()
       entry_head(letters, None, id_value)
       entry_head(letters, None, id)
       entry_link_subsection(id)
       entry_content('Всего: '+str(cnt)+' серий.')
       entry_finish()
@@ -460,7 +459,7 @@ elif type_value==3:
         id='03'+id
  
       entry_start()
       entry_head(letters, None, id_value)
       entry_head(letters, None, id)
       entry_link_subsection(id)
       entry_content('Всего: '+str(cnt)+' наименований.')
       entry_finish()
@@ -484,7 +483,7 @@ if type_value==13 or type_value==71:
   for (book_id,book_name,book_path,reg_date,book_title,annotation,docdate,format,fsize,cover,cover_type) in opdsdb.getbooksfortitle(letter,cfg.MAXITEMS,page_value,cfg.DUBLICATES_SHOW,np):
       id='90'+str(book_id)
       entry_start()
       entry_head(book_title, reg_date, id_value)
       entry_head(book_title, reg_date, 'book:'+str(book_id))
       entry_link_book(book_id,format)
       entry_covers(cover,cover_type,book_id)
       authors=entry_authors(opdsdb,book_id,True)
@@ -503,7 +502,7 @@ elif type_value==4:
   for (genre_id,genre_section,cnt) in opdsdb.getgenres_sections(cfg.DUBLICATES_SHOW,np):
       id='14'+str(genre_id)
       entry_start()
       entry_head(genre_section, None, id_value)
       entry_head(genre_section, None, 'genre:'+str(genre_id))
       entry_link_subsection(id)
       entry_content('Всего: '+str(cnt)+' книг.')
       entry_finish()
@@ -518,7 +517,7 @@ elif type_value==14:
       id='24'+str(genre_id)
       if cfg.ALPHA: id='30'+id
       entry_start()
       entry_head(genre_subsection, None, id_value)
       entry_head(genre_subsection, None, 'genre:'+str(genre_id))
       entry_link_subsection(id)
       entry_content('Всего: '+str(cnt)+' книг.')
       entry_finish()
@@ -532,7 +531,7 @@ if type_value==24:
   for (book_id,book_name,book_path,reg_date,book_title,annotation,docdate,format,fsize,cover,cover_type) in opdsdb.getbooksforgenre(slice_value,cfg.MAXITEMS,page_value,cfg.DUBLICATES_SHOW,alpha,np):
       id='90'+str(book_id)
       entry_start()
       entry_head(book_title, reg_date, id_value)
       entry_head(book_title, reg_date, 'book:'+str(book_id))
       entry_link_book(book_id,format)
       entry_covers(cover,cover_type,book_id)
       authors=entry_authors(opdsdb,book_id,True)
@@ -583,7 +582,7 @@ if type_value==8:
   for (book_id,book_name,book_path,reg_date,book_title,annotation,docdate,format,fsize,cover,cover_type) in opdsdb.getbooksforuser(user,cfg.MAXITEMS,page_value):
       id='90'+str(book_id)
       entry_start()
       entry_head(book_title, reg_date, id_value)
       entry_head(book_title, reg_date, 'book:'+str(book_id))
       entry_link_book(book_id,format)
       entry_covers(cover,cover_type,book_id)
       authors=entry_authors(opdsdb,book_id,True)
@@ -612,7 +611,7 @@ if type_value==12 or type_value==72:
   for (author_id,first_name, last_name,cnt) in opdsdb.getauthorsbyl(letter,cfg.MAXITEMS,page_value,cfg.DUBLICATES_SHOW,np):
       id='22'+str(author_id)
       entry_start()
       entry_head(last_name+' '+first_name, None, id_value)
       entry_head(last_name+' '+first_name, None, 'author:'+str(author_id))
       entry_link_subsection(id)
       entry_content('Всего: '+str(cnt)+' книг.')
       entry_finish()
@@ -638,7 +637,7 @@ if type_value==16 or type_value==73:
   for (ser_id,ser,cnt) in opdsdb.getseriesbyl(letter,cfg.MAXITEMS,page_value,cfg.DUBLICATES_SHOW,np):
       id='26'+str(ser_id)
       entry_start()
       entry_head(ser, None, id_value)
       entry_head(ser, None, 'series:'+str(ser_id))
       entry_link_subsection(id)
       entry_content('Всего: '+str(cnt)+' книг.')
       entry_finish()
@@ -663,7 +662,7 @@ if type_value==31:
   for (ser_id,ser,cnt) in opdsdb.getseriesforauthor(slice_value,cfg.MAXITEMS,page_value,cfg.DUBLICATES_SHOW):
       id='34'+str(slice_value)+'&amp;ser='+str(ser_id)
       entry_start()
       entry_head(ser, None, id_value)
       entry_head(ser, None, 'series:'+str(ser_id))
       entry_link_subsection(id)
       entry_content('Всего: '+str(cnt)+' книг.')
       entry_finish()
@@ -679,7 +678,7 @@ if type_value==33 or (type_value==22 and np!=0):
   for (book_id,book_name,book_path,reg_date,book_title,annotation,docdate,format,fsize,cover,cover_type) in opdsdb.getbooksforautor(slice_value,cfg.MAXITEMS,page_value,cfg.DUBLICATES_SHOW,np):
       id='90'+str(book_id)
       entry_start()
       entry_head(book_title, reg_date, id_value)
       entry_head(book_title, reg_date, 'book:'+str(book_id))
       entry_link_book(book_id,format)
       entry_covers(cover,cover_type,book_id)
       authors=entry_authors(opdsdb,book_id,True)
@@ -699,7 +698,7 @@ if type_value==34:
   for (book_id,book_name,book_path,reg_date,book_title,annotation,docdate,format,fsize,cover,cover_type) in opdsdb.getbooksforautorser(slice_value,ser_value,cfg.MAXITEMS,page_value,cfg.DUBLICATES_SHOW):
       id='90'+str(book_id)
       entry_start()
       entry_head(book_title, reg_date, id_value)
       entry_head(book_title, reg_date, 'book:'+str(book_id))
       entry_link_book(book_id,format)
       entry_covers(cover,cover_type,book_id)
       authors=entry_authors(opdsdb,book_id,True)
@@ -719,7 +718,7 @@ if type_value==26:
   for (book_id,book_name,book_path,reg_date,book_title,annotation,docdate,format,fsize,cover,cover_type) in opdsdb.getbooksforser(slice_value,cfg.MAXITEMS,page_value,cfg.DUBLICATES_SHOW,np):
       id='90'+str(book_id)
       entry_start()
       entry_head(book_title, reg_date, id_value)
       entry_head(book_title, reg_date, 'book:'+str(book_id))
       entry_link_book(book_id,format)
       entry_covers(cover,cover_type,book_id)
       authors=entry_authors(opdsdb,book_id,True)
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import logging
##########################################################################
# Глобальные переменные
#
VERSION="0.18"
PY_PATH=os.path.dirname(os.path.abspath(__file__))
(ROOT_PATH,tmp)=os.path.split(PY_PATH)
CFG_FILENAME='sopds.conf'