Remove brotli dependency
Fixes #88
@jbhul could you test this for me, as I don't use ProgressSync and I can't easily replicate your setup.
Awesome! I hope this works :) Do you need to reconfigure ProgressSync to avoid encoding in this case?
Awesome! I hope this works :) Do you need to reconfigure
ProgressSyncto avoid encoding in this case?
No, this change is entirely transparent. It just changes the ProgressSync client so that it no longer tells the server that it can accept gzip, deflate or br(otli) encoded data. The ProgressSync server will just fall back to sending uncompressed data.
Can confirm this works! Thank you @wfdewith for taking the initiative on this and frankly I love this solution, it just makes everything better.
Few tweaks:
-
Remove except brotli.error as e
-
Update the status and percent read key check to save the keys instead of fetching multiple times
status_key = CONFIG['column_status']
read_percent_key = CONFIG['column_percent_read_int'] or CONFIG['column_percent_read']
if status_key == '' or read_percent_key == '':
error_dialog(
self.gui,
'Failure',
'This feature needs a KOReader Progress (int or float) and Status Text column.\n'
'Add those in plugin settings and try again.',
show=True,
show_copy_button=False
)
return None
- Updating no-PS-Entry handling for the new change
for book_id in books_with_md5:
metadata = db.get_metadata(book_id)
md5_value = metadata.get(md5_column)
book_uuid = metadata.get('uuid')
title = metadata.get('title')
# Only get sync status if curr progress < 100 and status = reading
if metadata.get(status_key) == 'reading' and metadata.get(read_percent_key) < 100:
try:
url = f'{CONFIG["progress_sync_url"]}/syncs/progress/{md5_value}'
request = Request(url, headers=headers)
with urlopen(request, timeout=20) as response:
response_data = response.read()
progress_data = json.loads(response_data.decode('utf-8'))
# If no PS entry for MD5 then skip
if len(progress_data) == 0:
results.append({
'title': metadata.get('title'),
'book_uuid': book_uuid,
'md5_value': md5_value,
'error': 'No ProgressSync entry for md5 hash'
})
num_skip += 1
continue
# List of keys to check
ProgressSync_Columns = [
'column_percent_read', 'column_percent_read_int', 'column_last_read_location']
Can confirm this works! Thank you @wfdewith for taking the initiative on this and frankly I love this solution, it just makes everything better.
Thanks!
Few tweaks:
- Remove except brotli.error as e
Good point, I completely missed this one.
- Update the status and percent read key check to save the keys instead of fetching multiple times
status_key = CONFIG['column_status'] read_percent_key = CONFIG['column_percent_read_int'] or CONFIG['column_percent_read'] if status_key == '' or read_percent_key == '': error_dialog( self.gui, 'Failure', 'This feature needs a KOReader Progress (int or float) and Status Text column.\n' 'Add those in plugin settings and try again.', show=True, show_copy_button=False ) return None
- Updating no-PS-Entry handling for the new change
for book_id in books_with_md5: metadata = db.get_metadata(book_id) md5_value = metadata.get(md5_column) book_uuid = metadata.get('uuid') title = metadata.get('title') # Only get sync status if curr progress < 100 and status = reading if metadata.get(status_key) == 'reading' and metadata.get(read_percent_key) < 100: try: url = f'{CONFIG["progress_sync_url"]}/syncs/progress/{md5_value}' request = Request(url, headers=headers) with urlopen(request, timeout=20) as response: response_data = response.read() progress_data = json.loads(response_data.decode('utf-8')) # If no PS entry for MD5 then skip if len(progress_data) == 0: results.append({ 'title': metadata.get('title'), 'book_uuid': book_uuid, 'md5_value': md5_value, 'error': 'No ProgressSync entry for md5 hash' }) num_skip += 1 continue # List of keys to check ProgressSync_Columns = [ 'column_percent_read', 'column_percent_read_int', 'column_last_read_location']
I'll do these in a new PR to land this one as soon as possible.