Skip to content

wayback.py: Fix undefined names discovered by ruff #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions server/api/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,10 @@ def librivox(ocaid):
if 'librivox.org/' in a['href'] and not a['href'].endswith('.org/'):
return a['href']
return None
html = requests.get(url).content
soup = BeautifulSoup(html, 'html.parser')
table = soup.findAll('table', {'class': 'metatable'})[0]
# The following code is unreachable.
# html = requests.get(url).content
# soup = BeautifulSoup(html, 'html.parser')
# table = soup.findAll('table', {'class': 'metatable'})[0]


def download(iid, filename, headers=None):
Expand Down
2 changes: 1 addition & 1 deletion server/api/books.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def create_pre_hook(self):
self.cover_url = 'https://archive.org/services/img/' + self.archive_id


def add_metadata(d):
def add_metadata(self, d):
self.data.update(d)
flag_modified(self, 'data')

Expand Down
3 changes: 2 additions & 1 deletion server/views/apis/v1/books.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def get(self, archive_id, page):
return redirect(tts_url(archive_id, plaintext))

def post(self, archive_id, page):
data = request.get_json() or request.form or {'access': None, 'secret': None}
data = request.get_json() or request.form or {}
access, secret = data.get('access'), secret=data.get('secret')
pageocr = get_bookpage_ocr(archive_id, page, access=access, secret=secret)
pagenum = request.args.get('page', '')
plaintext = '\n'.join([block[0] for block in pageocr])
Expand Down
2 changes: 1 addition & 1 deletion server/views/apis/v1/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get(self, page=1, limit=100):
query=query, cursor=cursor, version=version)

@rest_api
def post(self):
def post(self, iid):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes the API calling convention!

"""For Upload API"""
# f = request.files['file']
# ia.upload(name, f)
Expand Down
1 change: 1 addition & 0 deletions server/views/apis/v1/wayback.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:license: see LICENSE for more details.
"""

import requests
from flask import request
from flask.views import MethodView
from api.archive import wayback_snapshot, wayback_search
Expand Down