|
|
@ -5,7 +5,7 @@ import logging
|
|
|
|
from logging.handlers import RotatingFileHandler
|
|
|
|
from logging.handlers import RotatingFileHandler
|
|
|
|
import textwrap
|
|
|
|
import textwrap
|
|
|
|
from flask import Flask, render_template, request, Response, redirect, url_for, send_from_directory, \
|
|
|
|
from flask import Flask, render_template, request, Response, redirect, url_for, send_from_directory, \
|
|
|
|
make_response, g, flash, abort
|
|
|
|
make_response, g, flash, abort, Markup
|
|
|
|
from flask import __version__ as flaskVersion
|
|
|
|
from flask import __version__ as flaskVersion
|
|
|
|
import ub
|
|
|
|
import ub
|
|
|
|
from ub import config
|
|
|
|
from ub import config
|
|
|
@ -673,9 +673,9 @@ def get_opds_download_link(book_id, format):
|
|
|
|
file_name = book.title
|
|
|
|
file_name = book.title
|
|
|
|
if len(book.authors) > 0:
|
|
|
|
if len(book.authors) > 0:
|
|
|
|
file_name = book.authors[0].name + '-' + file_name
|
|
|
|
file_name = book.authors[0].name + '-' + file_name
|
|
|
|
# file_name = helper.get_valid_filename(file_name)
|
|
|
|
file_name = helper.get_valid_filename(file_name)
|
|
|
|
response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format))
|
|
|
|
response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format))
|
|
|
|
response.headers["Content-Disposition"] = "attachment; filename=\"%s.%s\"" % (data.name, format)
|
|
|
|
response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (urllib.quote(file_name.encode('utf8')), format)
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1033,7 +1033,7 @@ def stats():
|
|
|
|
categorys = len(db.session.query(db.Tags).all())
|
|
|
|
categorys = len(db.session.query(db.Tags).all())
|
|
|
|
series = len(db.session.query(db.Series).all())
|
|
|
|
series = len(db.session.query(db.Series).all())
|
|
|
|
versions = uploader.book_formats.get_versions()
|
|
|
|
versions = uploader.book_formats.get_versions()
|
|
|
|
vendorpath = os.path.join(config.get_main_dir + "vendor" + os.sep)
|
|
|
|
vendorpath = os.path.join(config.get_main_dir, "vendor")
|
|
|
|
if sys.platform == "win32":
|
|
|
|
if sys.platform == "win32":
|
|
|
|
kindlegen = os.path.join(vendorpath, u"kindlegen.exe")
|
|
|
|
kindlegen = os.path.join(vendorpath, u"kindlegen.exe")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -1283,7 +1283,7 @@ def get_download_link(book_id, format):
|
|
|
|
response.headers["Content-Type"] = mimetypes.types_map['.' + format]
|
|
|
|
response.headers["Content-Type"] = mimetypes.types_map['.' + format]
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
response.headers["Content-Disposition"] = "attachment; filename=\"%s.%s\"" % (file_name.encode('utf-8'), format)
|
|
|
|
response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (urllib.quote(file_name.encode('utf-8')), format)
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
abort(404)
|
|
|
|
abort(404)
|
|
|
@ -2209,16 +2209,39 @@ def upload():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
db_author = db.Authors(author, helper.get_sorted_author(author), "")
|
|
|
|
db_author = db.Authors(author, helper.get_sorted_author(author), "")
|
|
|
|
db.session.add(db_author)
|
|
|
|
db.session.add(db_author)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#add language actually one value in list
|
|
|
|
|
|
|
|
input_language = meta.languages
|
|
|
|
|
|
|
|
db_language = None
|
|
|
|
|
|
|
|
if input_language != "":
|
|
|
|
|
|
|
|
input_language = isoLanguages.get(name=input_language).part3
|
|
|
|
|
|
|
|
hasLanguage = db.session.query(db.Languages).filter(db.Languages.lang_code == input_language).first()
|
|
|
|
|
|
|
|
if hasLanguage:
|
|
|
|
|
|
|
|
db_language = hasLanguage
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
db_language = db.Languages(input_language)
|
|
|
|
|
|
|
|
db.session.add(db_language)
|
|
|
|
# combine path and normalize path from windows systems
|
|
|
|
# combine path and normalize path from windows systems
|
|
|
|
path = os.path.join(author_dir, title_dir).replace('\\','/')
|
|
|
|
path = os.path.join(author_dir, title_dir).replace('\\','/')
|
|
|
|
db_book = db.Books(title, "", db_author.sort, datetime.datetime.now(), datetime.datetime(101, 01, 01), 1,
|
|
|
|
db_book = db.Books(title, "", db_author.sort, datetime.datetime.now(), datetime.datetime(101, 01, 01), 1,
|
|
|
|
datetime.datetime.now(), path, has_cover, db_author, [])
|
|
|
|
datetime.datetime.now(), path, has_cover, db_author, [], db_language)
|
|
|
|
db_book.authors.append(db_author)
|
|
|
|
db_book.authors.append(db_author)
|
|
|
|
|
|
|
|
if db_language is not None:
|
|
|
|
|
|
|
|
db_book.languages.append(db_language)
|
|
|
|
db_data = db.Data(db_book, meta.extension.upper()[1:], file_size, data_name)
|
|
|
|
db_data = db.Data(db_book, meta.extension.upper()[1:], file_size, data_name)
|
|
|
|
db_book.data.append(db_data)
|
|
|
|
db_book.data.append(db_data)
|
|
|
|
|
|
|
|
|
|
|
|
db.session.add(db_book)
|
|
|
|
db.session.add(db_book)
|
|
|
|
|
|
|
|
db.session.flush()# flush content get db_book.id avalible
|
|
|
|
|
|
|
|
#add comment
|
|
|
|
|
|
|
|
upload_comment = Markup(meta.description).unescape()
|
|
|
|
|
|
|
|
db_comment = None
|
|
|
|
|
|
|
|
if upload_comment != "":
|
|
|
|
|
|
|
|
db_comment = db.Comments(upload_comment, db_book.id)
|
|
|
|
|
|
|
|
db.session.add(db_comment)
|
|
|
|
db.session.commit()
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
if db_language is not None: #display Full name instead of iso639.part3
|
|
|
|
|
|
|
|
db_book.languages[0].language_name = _(meta.languages)
|
|
|
|
author_names = []
|
|
|
|
author_names = []
|
|
|
|
for author in db_book.authors:
|
|
|
|
for author in db_book.authors:
|
|
|
|
author_names.append(author.name)
|
|
|
|
author_names.append(author.name)
|
|
|
|