Skip to content
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
1 change: 1 addition & 0 deletions crosspoint_reader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Default settings:
- Host fallback: 192.168.4.1
- Port: 81
- Upload path: /
- Upload template: blank, which uses Calibre's send-to-device template

Install:
1. Download the latest release from the [releases page](https://github.com/crosspoint-reader/calibre-plugins/releases) (or zip the contents of this directory).
Expand Down
9 changes: 8 additions & 1 deletion crosspoint_reader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,30 @@
PREFS.defaults['debug'] = False
PREFS.defaults['fetch_metadata'] = False
PREFS.defaults['send_to_root'] = False
PREFS.defaults['upload_template'] = ''


class CrossPointConfigWidget(QWidget):
def __init__(self):
super().__init__()
layout = QFormLayout(self)
layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)
self.host = QLineEdit(self)
self.port = QSpinBox(self)
self.port.setRange(1, 65535)
self.path = QLineEdit(self)
self.upload_template = QLineEdit(self)
self.chunk_size = QSpinBox(self)
self.chunk_size.setRange(512, 65536)
self.debug = QCheckBox('Enable debug logging', self)
self.fetch_metadata = QCheckBox('Fetch metadata (slower device list)', self)
self.send_to_root = QCheckBox('Send to root (ignore folder template)', self)
self.send_to_root = QCheckBox('Send to root (ignore any template)', self)

self.host.setText(PREFS['host'])
self.port.setValue(PREFS['port'])
self.path.setText(PREFS['path'])
self.upload_template.setText(PREFS['upload_template'])
self.upload_template.setPlaceholderText("Leave blank to use Calibre's send-to-device template")
self.chunk_size.setValue(PREFS['chunk_size'])
self.debug.setChecked(PREFS['debug'])
self.fetch_metadata.setChecked(PREFS['fetch_metadata'])
Expand All @@ -58,6 +63,7 @@ def __init__(self):
layout.addRow('', notice)

layout.addRow('Upload path', self.path)
layout.addRow('Upload template', self.upload_template)
layout.addRow('Chunk size', self.chunk_size)
layout.addRow('', self.debug)
layout.addRow('', self.fetch_metadata)
Expand All @@ -80,6 +86,7 @@ def save(self):
PREFS['host'] = self.host.text().strip() or PREFS.defaults['host']
PREFS['port'] = int(self.port.value())
PREFS['path'] = self.path.text().strip() or PREFS.defaults['path']
PREFS['upload_template'] = self.upload_template.text().strip()
PREFS['chunk_size'] = int(self.chunk_size.value())
PREFS['debug'] = bool(self.debug.isChecked())
PREFS['fetch_metadata'] = bool(self.fetch_metadata.isChecked())
Expand Down
8 changes: 5 additions & 3 deletions crosspoint_reader/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def free_space(self, end_session=True):
return 10 * 1024 * 1024 * 1024, 0, 0

def _format_upload_path(self, mi, original_name):
"""Format an upload path using the send-to-device template.
"""Format an upload path using the configured upload template.

Returns (subdirs, filename) where subdirs is a list of directory
components from the template (may be empty for flat templates).
Expand All @@ -219,9 +219,11 @@ def _format_upload_path(self, mi, original_name):
from calibre.library.save_to_disk import config as sconfig, get_components
from calibre.utils.filenames import ascii_filename

template = self.save_template()
template = PREFS['upload_template']
if not template:
template = sconfig().parse().send_template
template = self.save_template()
if not template:
template = sconfig().parse().send_template

components = get_components(
template, mi, -1, '%b %Y', 250,
Expand Down