Remove backblaze leftovers
This commit is contained in:
parent
55c0bb6d34
commit
f9b1e84704
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -32,4 +32,3 @@ gdrive_credentials
|
|||
|
||||
vendor
|
||||
client_secrets.json
|
||||
b2_secrets.json
|
||||
|
|
38
cps/kobo.py
38
cps/kobo.py
|
@ -8,19 +8,14 @@ import os
|
|||
from datetime import datetime, tzinfo, timedelta
|
||||
from time import gmtime, strftime
|
||||
|
||||
from b2sdk.account_info.in_memory import InMemoryAccountInfo
|
||||
from b2sdk.api import B2Api
|
||||
from jsonschema import validate, exceptions
|
||||
from flask import Blueprint, request, make_response, jsonify, json, send_file
|
||||
from flask_login import login_required
|
||||
from sqlalchemy import func
|
||||
|
||||
from . import config, logger, kobo_auth, ub, db, helper
|
||||
from .constants import CONFIG_DIR as _CONFIG_DIR
|
||||
from .web import download_required
|
||||
|
||||
B2_SECRETS = os.path.join(_CONFIG_DIR, "b2_secrets.json")
|
||||
|
||||
kobo = Blueprint("kobo", __name__)
|
||||
kobo_auth.disable_failed_auth_redirect_for_blueprint(kobo)
|
||||
|
||||
|
@ -215,39 +210,6 @@ def get_download_url_for_book(book, book_format):
|
|||
)
|
||||
|
||||
|
||||
def get_download_url_for_book_b2(book, book_format):
|
||||
if not data:
|
||||
log.info(u"Book %s does have a kepub format", book_uuid)
|
||||
return None
|
||||
|
||||
file_name = data.name + ".kepub"
|
||||
file_path = os.path.join(book.path, file_name)
|
||||
|
||||
if not os.path.isfile(B2_SECRETS):
|
||||
log.error(u"b2 secret file not found")
|
||||
return None
|
||||
with open(B2_SECRETS, "r") as filedata:
|
||||
secrets = json.load(filedata)
|
||||
|
||||
info = InMemoryAccountInfo()
|
||||
b2_api = B2Api(info)
|
||||
b2_api.authorize_account(
|
||||
"production", secrets["application_key_id"], secrets["application_key"]
|
||||
)
|
||||
bucket = b2_api.get_bucket_by_name(secrets["bucket_name"])
|
||||
if not bucket:
|
||||
log.error(u"b2 bucket not found")
|
||||
return None
|
||||
|
||||
download_url = b2_api.get_download_url_for_file_name(
|
||||
secrets["bucket_name"], file_path
|
||||
)
|
||||
download_authorization = bucket.get_download_authorization(
|
||||
file_path, valid_duration_in_seconds=600
|
||||
)
|
||||
return download_url + "?Authorization=" + download_authorization
|
||||
|
||||
|
||||
def create_book_entitlement(book):
|
||||
book_uuid = book.uuid
|
||||
return {
|
||||
|
|
|
@ -32,6 +32,3 @@ rarfile>=2.7
|
|||
# other
|
||||
natsort>=2.2.0
|
||||
git+https://github.com/OzzieIsaacs/comicapi.git@5346716578b2843f54d522f44d01bc8d25001d24#egg=comicapi
|
||||
|
||||
# Unsupported/Experimental backblaze integration for Kobo endpoint.
|
||||
b2sdk>=1.0.2,<2.0.0
|
||||
|
|
Loading…
Reference in New Issue
Block a user