номер книги в серии
9 years 4 months ago #227
by dentra
dentra created the topic: номер книги в серии
Очень хотелось бы видеть не только серию (кстати выводится как "серии"), но и номер книги в ней. Можно отдельным полем, а можно как, например, в каталоге флибусты в том же поле, в формате "название_серии #номер_серии". Ну и сортировку по номеру серии, когда мы зашли в нее.
И спасибо за отличную софтину
И спасибо за отличную софтину

Please Войти or Create an account to join the conversation.
- dentra
-
Topic Author
- Visitor
-
9 years 4 months ago #231
by rpin
rpin replied the topic: номер книги в серии
Поддерживаю - номера серии сильно не хватает. Особенно с незнакомыми авторами и сериями - приходится по сети лазить, выяснять номер по названиям книги или тупо загружать и смотреть...
Please Войти or Create an account to join the conversation.
- rpin
-
- Offline
- Осваиваюсь на форуме
-
Less
More
- Posts: 36
- Karma: 1
9 years 4 months ago #233
by mitshel
mitshel replied the topic: номер книги в серии
Вероятно добавлю номер книги в серии, но позднее.
Please Войти or Create an account to join the conversation.
- mitshel
-
- Offline
- Администратор
-
Less
More
- Posts: 297
- Karma: 8
9 years 4 months ago #234
by dentra
dentra replied the topic: номер книги в серии
в общем добавил такую возможность, требует пересоздания БД и пересканирования, патч ниже:
diff --git a/db/tables.sql b/db/tables.sql
index 771697d..c61ffb7 100644
--- a/db/tables.sql
+++ b/db/tables.sql
@@ -87,6 +87,7 @@ drop table if exists bseries;
create table bseries(
ser_id INT not NULL,
book_id INT not NULL,
+ser_no TINYINT UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY(book_id,ser_id),
INDEX(ser_id));
commit;
diff --git a/py/sopds.cgi b/py/sopds.cgi
index 17175a8..371a82d 100755
--- a/py/sopds.cgi
+++ b/py/sopds.cgi
@@ -207,10 +207,12 @@ def entry_genres(db,book_id):
def entry_series(db,book_id):
series=""
- for (ser,) in opdsdb.getseries(book_id):
+ for (ser,ser_no) in opdsdb.getseries(book_id):
if len(series)>0:
series+=', '
series+=ser
+ if ser_no > 0:
+ series += ' #' + str(ser_no)
return series
def entry_covers(cover,cover_type,book_id):
@@ -246,7 +248,7 @@ def entry_content2(annotation='',title='',authors='',genres='',filename='',files
if filename!='':
enc_print('<b>Файл:</b> '+websym(filename)+'<br/>')
if filesize>0:
- enc_print('<b>Размер файла:</b> '+str(fsize//1000)+'Кб.<br/>')
+ enc_print('<b>Размер файла:</b> '+str(fsize//1024)+'Кб.<br/>')
if docdate!='':
enc_print('<b>Дата правки:</b> '+docdate+'<br/>')
if annotation!='':
diff --git a/py/sopdscan.py b/py/sopdscan.py
index d5d50d8..85ac081 100644
--- a/py/sopdscan.py
+++ b/py/sopdscan.py
@@ -174,8 +174,12 @@ class opdsScanner:
idx+=1
for l in self.fb2parser.genre.getvalue():
self.opdsdb.addbgenre(book_id,self.opdsdb.addgenre(l.lower().strip(' \'\"')))
- for l in self.fb2parser.series.getattrs('name'):
- self.opdsdb.addbseries(book_id,self.opdsdb.addseries(l.strip()))
+ for l in self.fb2parser.series.attrss:
+ ser_id=self.opdsdb.addseries(l.get('name').strip())
+ try:
+ self.opdsdb.addbseries(book_id,ser_id,int(l.get('number')))
+ except (ValueError, TypeError):
+ self.opdsdb.addbseries(book_id,ser_id,0)
if not self.cfg.SINGLE_COMMIT: self.opdsdb.commit()
else:
diff --git a/py/sopdsdb.py b/py/sopdsdb.py
index 5684640..0b6f78a 100644
--- a/py/sopdsdb.py
+++ b/py/sopdsdb.py
@@ -292,9 +292,9 @@ class opdsDatabase:
cursor.close()
return ser_id
- def addbseries(self, book_id, ser_id):
- sql=("insert into "+TBL_BSERIES+"(book_id,ser_id) VALUES(%s,%s)")
- data=(book_id,ser_id)
+ def addbseries(self, book_id, ser_id, ser_no):
+ sql=("insert into "+TBL_BSERIES+"(book_id,ser_id,ser_no) VALUES(%s,%s,%s)")
+ data=(book_id,ser_id,ser_no)
cursor=self.cnx.cursor()
try:
cursor.execute(sql,data)
@@ -421,7 +421,7 @@ class opdsDatabase:
return rows
def getseries(self,book_id):
- sql=("select ser from "+TBL_SERIES+" a, "+TBL_BSERIES+" b where b.ser_id=a.ser_id and b.book_id="+str(book_id))
+ sql=("select a.ser, b.ser_no from "+TBL_SERIES+" a, "+TBL_BSERIES+" b where b.ser_id=a.ser_id and b.book_id="+str(book_id))
cursor=self.cnx.cursor()
cursor.execute(sql)
rows=cursor.fetchall()
@@ -646,7 +646,7 @@ class opdsDatabase:
else: dstr=' and a.doublicat=0 '
if new_period==0: period=''
else: period=" and (registerdate>now()-INTERVAL %s DAY)"%new_period
- sql="select SQL_CALC_FOUND_ROWS a.book_id,a.filename,a.path,a.registerdate,a.title,a.annotation,a.docdate,a.format,a.filesize,a.cover,a.cover_type from "+TBL_BOOKS+" a, "+TBL_BSERIES+" b where a.book_id=b.book_id and b.ser_id="+str(ser_id)+" and a.avail!=0 "+dstr+period+" order by a.title "+limitstr
+ sql="select SQL_CALC_FOUND_ROWS a.book_id,a.filename,a.path,a.registerdate,a.title,a.annotation,a.docdate,a.format,a.filesize,a.cover,a.cover_type from "+TBL_BOOKS+" a, "+TBL_BSERIES+" b where a.book_id=b.book_id and b.ser_id="+str(ser_id)+" and a.avail!=0 "+dstr+period+" order by b.ser_no, a.title "+limitstr
cursor=self.cnx.cursor()
cursor.execute(sql)
rows=cursor.fetchall()
Please Войти or Create an account to join the conversation.
- dentra
-
Topic Author
- Visitor
-
9 years 4 months ago #236
by dentra
dentra replied the topic: номер книги в серии
@mitshel а на второй?
уже работает на моем сервере


Please Войти or Create an account to join the conversation.
- dentra
-
Topic Author
- Visitor
-
9 years 4 months ago - 9 years 4 months ago #237
by mitshel
mitshel replied the topic: номер книги в серии
Вообще поторопился я вынести вердикт. Просто подзабыл код парсера немного. А так как Ваш код читал на мобильнике, то не получилось сразу проверить.
Спасибо за помощь. В ближайшее время (сегодня-завтра) выложу новую версию пока без Вашего патча, т.к. было очень много изменений. Ваш патч будет в версии v0.20
Спасибо за помощь. В ближайшее время (сегодня-завтра) выложу новую версию пока без Вашего патча, т.к. было очень много изменений. Ваш патч будет в версии v0.20
Last Edit: 9 years 4 months ago by mitshel.
Please Войти or Create an account to join the conversation.
- mitshel
-
- Offline
- Администратор
-
Less
More
- Posts: 297
- Karma: 8
Time to create page: 0.122 seconds