A Python library for syncing and managing Pinboard bookmarks
Project description
pinboard-tools
A Python library for syncing and managing Pinboard bookmarks.
Features
- Efficient incremental sync with Pinboard.in API
- SQLite database for local bookmark storage
- Tag analysis and similarity detection
- Smart conflict resolution for sync operations
- Rate limiting and optimized API usage
- Chunking utilities for LLM processing
Installation
pip install pinboard-tools
Quick Start
from pinboard_tools import (
init_database,
get_session,
BidirectionalSync,
)
# Initialize database
init_database("bookmarks.db")
# Create sync engine
db = get_session()
sync = BidirectionalSync(db=db, api_token="your-pinboard-api-token")
# Perform efficient incremental sync
stats = sync.sync()
print(f"Local to remote: {stats['local_to_remote']}")
print(f"Remote to local: {stats['remote_to_local']}")
print(f"Conflicts resolved: {stats['conflicts_resolved']}")
Core Components
Database Models
Bookmark- Bookmark entity with all Pinboard fieldsTag- Tag entity with normalizationBookmarkTag- Many-to-many relationshipSyncStatus- Track sync state
Sync Engine
PinboardAPI- API client with rate limiting and incremental fetchingBidirectionalSync- Efficient incremental sync with conflict resolution
Tag Analysis
TagSimilarityDetector- Find similar tagsTagConsolidator- Merge duplicate tags
Utilities
chunk_bookmarks_for_llm- Prepare data for LLM processing- DateTime helpers for Pinboard format
Database Schema
The library uses a normalized SQLite schema:
-- See schema.sql for complete structure
bookmarks (url, title, description, tags, time, ...)
tags (name, normalized_name)
bookmark_tags (bookmark_id, tag_id)
sync_status (last_sync, last_update)
API Reference
Initialization
# Initialize database with schema
init_database(db_path: str)
# Get database session
with get_session() as session:
# Use session for queries
Syncing
# Create sync client
sync = BidirectionalSync(db=session, api_token="your-token")
# Efficient incremental sync (only fetches changed bookmarks)
stats = sync.sync()
# Sync only local changes to remote
stats = sync.sync(direction=SyncDirection.LOCAL_TO_REMOTE)
# Sync only remote changes to local
stats = sync.sync(direction=SyncDirection.REMOTE_TO_LOCAL)
Tag Analysis
# Find similar tags
detector = TagSimilarityDetector(session)
similar_groups = detector.find_similar_tags(threshold=0.8)
# Consolidate tags
consolidator = TagConsolidator(session)
consolidator.consolidate_tags(old_tag="python3", new_tag="python")
License
Apache License 2.0 - see LICENSE file for details
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pinboard_tools-0.1.9.tar.gz.
File metadata
- Download URL: pinboard_tools-0.1.9.tar.gz
- Upload date:
- Size: 95.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e3c5f5851c1f871d331723df38ce89df6fb69afe01a0fe2504f120d109c60b1
|
|
| MD5 |
530eadcc3a8e70a36dca23662c0266e1
|
|
| BLAKE2b-256 |
241f85660b70ccff7b5e75633df7ad7588e562d75593aeab058c2934f005348c
|
Provenance
The following attestation bundles were made for pinboard_tools-0.1.9.tar.gz:
Publisher:
publish.yml on kevinmcmahon/pinboard-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pinboard_tools-0.1.9.tar.gz -
Subject digest:
2e3c5f5851c1f871d331723df38ce89df6fb69afe01a0fe2504f120d109c60b1 - Sigstore transparency entry: 246695703
- Sigstore integration time:
-
Permalink:
kevinmcmahon/pinboard-tools@184de987770db932fabac710bfeb5bb21b5100dc -
Branch / Tag:
refs/tags/v0.1.9 - Owner: https://github.com/kevinmcmahon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@184de987770db932fabac710bfeb5bb21b5100dc -
Trigger Event:
release
-
Statement type:
File details
Details for the file pinboard_tools-0.1.9-py3-none-any.whl.
File metadata
- Download URL: pinboard_tools-0.1.9-py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d99895e93cb85e1e9c598aa025dc3ffc3bc4f1ab7f91029f04c6f8b185c45f9a
|
|
| MD5 |
82eb9a7d5b72e8023c3a763c6818c926
|
|
| BLAKE2b-256 |
16baf5bbe3d9c547b8e6f4a0c9033e4bfa81f6ceb9ba8cb3ac46d0aee0abfb8b
|
Provenance
The following attestation bundles were made for pinboard_tools-0.1.9-py3-none-any.whl:
Publisher:
publish.yml on kevinmcmahon/pinboard-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pinboard_tools-0.1.9-py3-none-any.whl -
Subject digest:
d99895e93cb85e1e9c598aa025dc3ffc3bc4f1ab7f91029f04c6f8b185c45f9a - Sigstore transparency entry: 246695708
- Sigstore integration time:
-
Permalink:
kevinmcmahon/pinboard-tools@184de987770db932fabac710bfeb5bb21b5100dc -
Branch / Tag:
refs/tags/v0.1.9 - Owner: https://github.com/kevinmcmahon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@184de987770db932fabac710bfeb5bb21b5100dc -
Trigger Event:
release
-
Statement type: