Loading py/sopds.cgi +51 −2 Original line number Diff line number Diff line Loading @@ -83,6 +83,16 @@ def header_search(sstr='',charset='utf-8'): enc_print('<icon>'+cfg.SITE_ICON+'</icon>') enc_print('<link type="application/atom+xml" rel="start" href="'+cfg.CGI_PATH+'?id=00"/>') def header_authors(title,charset='utf-8'): enc_print('Content-Type: text/xml; charset='+charset) enc_print() enc_print('<?xml version="1.0" encoding="'+charset+'"?>') enc_print('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/" xmlns:opds="http://opds-spec.org/2010/catalog">') enc_print('<id>tag::authors submenu::</id>') enc_print('<title>%s</title>'%title) enc_print('<updated>'+time.strftime("%Y-%m-%dT%H:%M:%SZ")+'</updated>') enc_print('<icon>'+cfg.SITE_ICON+'</icon>') enc_print('<link type="application/atom+xml" rel="start" href="'+cfg.CGI_PATH+'?id=00"/>') def footer(): enc_print('</feed>') Loading Loading @@ -156,6 +166,21 @@ def new_menu(): enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id='+am+'06&news=1"/>') enc_print('<id>id:06:news</id></entry>') def authors_submenu(author_id): enc_print('<entry>') enc_print('<title>Книги по сериям</title>') enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=31'+str(author_id)+'"/>') enc_print('<id>id:31:authors</id></entry>') enc_print('<entry>') enc_print('<title>Книги вне серий</title>') enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=32'+str(author_id)+'"/>') enc_print('<id>id:32:authors</id></entry>') enc_print('<entry>') 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>') Loading Loading @@ -646,11 +671,35 @@ if type_value==16 or type_value==73: page_control(opdsdb,page_value,id_value) footer() ######################################################### # Выдача подменю вывода книг по автору - в случае флага новинок будет сразу переход к выдаче книг автора # if type_value==22 and np==0: (first_name,last_name)=opdsdb.getauthor_name(slice_value) header_authors('Книги автора %s %s'%(last_name,first_name)) authors_submenu(slice_value) footer() ######################################################### # Выдача серий по автору # if type_value==31: (first_name,last_name)=opdsdb.getauthor_name(slice_value) header_authors('Сериии книг автора %s %s'%(last_name,first_name)) for (ser_id,ser,cnt) in opdsdb.getseriesforauthor(slice_value,cfg.MAXITEMS,page_value): id='34'+str(slice_value)+'&ser='+str(ser_id) entry_start() entry_head(ser, None, id_value) entry_link_subsection(id) entry_content('Всего: '+str(cnt)+' книг.') entry_finish() page_control(opdsdb,page_value,id_value) footer() ######################################################### # Выдача списка книг по автору # Выдача списка книг по автору по алфавиту # if type_value==22: if type_value==33 or (type_value==22 and np!=0): header() 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) Loading py/sopdsdb.py +31 −0 Original line number Diff line number Diff line Loading @@ -395,6 +395,15 @@ class opdsDatabase: cursor.close return rows def getauthor_name(self, author_id): sql=("select first_name,last_name from "+TBL_AUTHORS+" where author_id=%s") data=(author_id,) cursor=self.cnx.cursor() cursor.execute(sql,data) row=cursor.fetchone() cursor.close return row def getgenres(self,book_id): sql=("select section, subsection from "+TBL_GENRES+" a, "+TBL_BGENRES+" b where b.genre_id=a.genre_id and b.book_id="+str(book_id)) cursor=self.cnx.cursor() Loading Loading @@ -539,6 +548,28 @@ class opdsDatabase: cursor.close return rows def getseriesforauthor(self,author_id,limit=0,page=0): if limit==0: limitstr="" else: limitstr="limit "+str(limit*page)+","+str(limit) sql=("select SQL_CALC_FOUND_ROWS a.ser_id, a.ser, count(*) from "+TBL_SERIES+" a " "left join "+TBL_BSERIES+" b on a.ser_id=b.ser_id " "left join "+TBL_BAUTHORS+" c on b.book_id=c.book_id " "where author_id="+str(author_id)+" group by 1,2 order by a.ser "+limitstr) cursor=self.cnx.cursor() cursor.execute(sql) rows=cursor.fetchall() cursor.execute("SELECT FOUND_ROWS()") found_rows=cursor.fetchone() if found_rows[0]>limit*page+limit: self.next_page=True else: self.next_page=False cursor.close return rows def getseriesbyl(self,letters,limit=0,page=0,doublicates=True,new_period=0): if limit==0: limitstr="" else: limitstr="limit "+str(limit*page)+","+str(limit) Loading Loading
py/sopds.cgi +51 −2 Original line number Diff line number Diff line Loading @@ -83,6 +83,16 @@ def header_search(sstr='',charset='utf-8'): enc_print('<icon>'+cfg.SITE_ICON+'</icon>') enc_print('<link type="application/atom+xml" rel="start" href="'+cfg.CGI_PATH+'?id=00"/>') def header_authors(title,charset='utf-8'): enc_print('Content-Type: text/xml; charset='+charset) enc_print() enc_print('<?xml version="1.0" encoding="'+charset+'"?>') enc_print('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/" xmlns:opds="http://opds-spec.org/2010/catalog">') enc_print('<id>tag::authors submenu::</id>') enc_print('<title>%s</title>'%title) enc_print('<updated>'+time.strftime("%Y-%m-%dT%H:%M:%SZ")+'</updated>') enc_print('<icon>'+cfg.SITE_ICON+'</icon>') enc_print('<link type="application/atom+xml" rel="start" href="'+cfg.CGI_PATH+'?id=00"/>') def footer(): enc_print('</feed>') Loading Loading @@ -156,6 +166,21 @@ def new_menu(): enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id='+am+'06&news=1"/>') enc_print('<id>id:06:news</id></entry>') def authors_submenu(author_id): enc_print('<entry>') enc_print('<title>Книги по сериям</title>') enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=31'+str(author_id)+'"/>') enc_print('<id>id:31:authors</id></entry>') enc_print('<entry>') enc_print('<title>Книги вне серий</title>') enc_print('<link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="'+cfg.CGI_PATH+'?id=32'+str(author_id)+'"/>') enc_print('<id>id:32:authors</id></entry>') enc_print('<entry>') 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>') Loading Loading @@ -646,11 +671,35 @@ if type_value==16 or type_value==73: page_control(opdsdb,page_value,id_value) footer() ######################################################### # Выдача подменю вывода книг по автору - в случае флага новинок будет сразу переход к выдаче книг автора # if type_value==22 and np==0: (first_name,last_name)=opdsdb.getauthor_name(slice_value) header_authors('Книги автора %s %s'%(last_name,first_name)) authors_submenu(slice_value) footer() ######################################################### # Выдача серий по автору # if type_value==31: (first_name,last_name)=opdsdb.getauthor_name(slice_value) header_authors('Сериии книг автора %s %s'%(last_name,first_name)) for (ser_id,ser,cnt) in opdsdb.getseriesforauthor(slice_value,cfg.MAXITEMS,page_value): id='34'+str(slice_value)+'&ser='+str(ser_id) entry_start() entry_head(ser, None, id_value) entry_link_subsection(id) entry_content('Всего: '+str(cnt)+' книг.') entry_finish() page_control(opdsdb,page_value,id_value) footer() ######################################################### # Выдача списка книг по автору # Выдача списка книг по автору по алфавиту # if type_value==22: if type_value==33 or (type_value==22 and np!=0): header() 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) Loading
py/sopdsdb.py +31 −0 Original line number Diff line number Diff line Loading @@ -395,6 +395,15 @@ class opdsDatabase: cursor.close return rows def getauthor_name(self, author_id): sql=("select first_name,last_name from "+TBL_AUTHORS+" where author_id=%s") data=(author_id,) cursor=self.cnx.cursor() cursor.execute(sql,data) row=cursor.fetchone() cursor.close return row def getgenres(self,book_id): sql=("select section, subsection from "+TBL_GENRES+" a, "+TBL_BGENRES+" b where b.genre_id=a.genre_id and b.book_id="+str(book_id)) cursor=self.cnx.cursor() Loading Loading @@ -539,6 +548,28 @@ class opdsDatabase: cursor.close return rows def getseriesforauthor(self,author_id,limit=0,page=0): if limit==0: limitstr="" else: limitstr="limit "+str(limit*page)+","+str(limit) sql=("select SQL_CALC_FOUND_ROWS a.ser_id, a.ser, count(*) from "+TBL_SERIES+" a " "left join "+TBL_BSERIES+" b on a.ser_id=b.ser_id " "left join "+TBL_BAUTHORS+" c on b.book_id=c.book_id " "where author_id="+str(author_id)+" group by 1,2 order by a.ser "+limitstr) cursor=self.cnx.cursor() cursor.execute(sql) rows=cursor.fetchall() cursor.execute("SELECT FOUND_ROWS()") found_rows=cursor.fetchone() if found_rows[0]>limit*page+limit: self.next_page=True else: self.next_page=False cursor.close return rows def getseriesbyl(self,letters,limit=0,page=0,doublicates=True,new_period=0): if limit==0: limitstr="" else: limitstr="limit "+str(limit*page)+","+str(limit) Loading