A Python console application for reading and managing Instapaper articles.
The application is built with a modular design:
article_manager.py- Contains theArticleManagerclass with all Instapaper functionalityip_conductor.py- Console interface that uses theArticleManagerclassexample_usage.py- Demonstrates how to useArticleManagerin other programs
This design allows you to easily integrate Instapaper functionality into other Python applications by importing the ArticleManager class.
- Python 3.12 or higher
- pip and venv
-
Clone or download this repository:
cd /path/to/ip-conductor -
Create a virtual environment:
python3 -m venv .venv
-
Activate the virtual environment:
source .venv/bin/activate # On Linux/macOS/WSL # or .venv\Scripts\activate # On Windows
-
Install dependencies:
pip install -r requirements.txt
-
Download the spaCy language model:
python -m spacy download en_core_web_sm
-
Copy the example environment file:
cp .env.example .env
-
Edit
.envand add your Instapaper credentials:INSTAPAPER_USERNAME=your_email@example.com INSTAPAPER_PASSWORD=your_password INSTAPAPER_CONSUMER_KEY=your_consumer_key INSTAPAPER_CONSUMER_SECRET=your_consumer_secret
-
(Optional) Configure speak mode line width:
SPEAK_LINE_WIDTH=70 # Default is 70 charactersThis controls how text wraps in speak mode. Adjust based on your terminal width and reading preference.
Note: Never commit your .env file to version control. It's already included in .gitignore.
Activate the virtual environment (if not already active):
source .venv/bin/activateRun the application:
python ip_conductor.pyarticles/bookmarks/a- List all articles with numbers (up to 25 by default)add- Add a new article by entering a URLdelete/d- Delete the currently selected article (with confirmation)star/s- Star the currently selected articlearchive/c- Archive the currently selected articlehighlight- Create a highlight for the current article (multi-line text input)speak/k- Enter sentence-by-sentence reading mode with highlighting supportspeak <number>/k <number>- Navigate to and speak a specific article by its number
title- Show current article title<number>- Navigate to article by number and display its title (e.g.,5jumps to article 5)next/n- Move to next articleprev/previous/p- Move to previous articlefirst- Jump to first articlelast- Jump to last articleread/r- Read current article contentread <number>/r <number>- Navigate to and read a specific article by its number from the list
exit- Quit the application
For faster navigation, single-letter shortcuts are available for common commands:
a- Articles/bookmarks listn- Next articlep- Previous articled- Delete current articles- Star current articlec- Archive current articler- Read current articlek- Speak current article
With article numbers:
r 3- Read article 3k 5- Speak article 5
Speak mode provides an interactive sentence-by-sentence reading experience with intelligent sentence parsing powered by spaCy:
- Enter speak mode:
speak - Navigate and highlight using keyboard commands:
- SPACE - Display next sentence
- B - Go back to previous sentence
- H - Highlight current sentence (saves to Instapaper)
- Q - Quit speak mode
Each sentence displays with its position in the article:
[sentence_number/total_sentences]
Sentence text appears here.
When you highlight a sentence with H, a confirmation message appears, and you can continue navigating with SPACE or B.
- Environment-based configuration: Secure credential storage using
.envfiles - Virtual environment support: Isolated dependencies per project
- Numbered article listing: Articles are displayed with numbers for easy reference
- Quick navigation: Jump to any article by simply entering its number
- Direct article access: Jump to and read any article by its number
- Speak mode: Interactive sentence-by-sentence reading with NLP-powered sentence parsing
- Smart highlighting: Highlight sentences directly from speak mode with automatic syncing to Instapaper
- Configurable article limit: The application fetches 25 articles by default (configurable in
ArticleManagerinitialization) - Error handling: Comprehensive error handling for network issues, API errors, and invalid operations
- Interactive highlights: Create multi-line highlights by entering text and pressing Enter twice to finish
- Confirmation prompts: Safe deletion with confirmation prompts
# Activate the virtual environment
source .venv/bin/activate
# Start the application
python ip_conductor.py
# List all articles with numbers (using shortcut)
> a
1. Understanding Python Decorators
2. Introduction to Machine Learning
3. Web Development Best Practices
4. Advanced Git Techniques
5. Docker for Beginners
# Quick jump to article 3 by entering just the number
> 3
Web Development Best Practices
# Read the current article using shortcut
> r
# Or jump and read in one command using shortcut
> r 5
[Displays content of "Docker for Beginners"]
# Enter speak mode for sentence-by-sentence reading using shortcut
> k
[1/350] [0,45]
Docker is a platform for developing applications.
# Press SPACE to see next sentence
# Press H to highlight current sentence
# Press B to go back to previous sentence
# Press Q to quit speak mode
# Or speak a specific article directly
> k 2
[Opens speak mode for article 2: "Introduction to Machine Learning"]
# Navigate to next article using shortcut
> n
[Now at article 6]
# Create a highlight
> highlight
Enter the text you want to highlight (press Enter twice to finish):
This is important text
that I want to remember.
# Star the article using shortcut
> s
# Archive when done using shortcut
> c
# Exit
> exitinstapaper==0.5- Instapaper API client for bookmark managementoauth2==1.9.0.post1- OAuth authentication for Instapaper APIhttplib2==0.31.0- HTTP client library for API requestspython-dotenv==1.2.1- Environment variable management for configurationspacy==3.8.11- Natural language processing for sentence parsingen-core-web-sm- English language model for spaCy (downloaded separately)setuptools==80.9.0- Python package utilities (required for Python 3.12+)
black==25.11.0- Code formatter for consistent Python code styleflake8==7.3.0- Style guide enforcement (PEP 8 compliance)isort==7.0.0- Import statement organizer and sortermypy==1.18.2- Static type checker for Pythonpylint==4.0.3- Comprehensive code analysis and linting
The application also includes various supporting packages for spaCy, HTTP handling, and data processing. See requirements.txt for the complete list of dependencies with exact versions.
All dependencies are listed in requirements.txt and will be installed automatically with pip install -r requirements.txt.
To change the number of articles fetched, pass a different limit when creating the ArticleManager instance:
# In ip_conductor.py main() function
manager = ArticleManager(bookmark_limit=50) # Change from default 25 to 50The ArticleManager class can be easily imported and used in other Python applications. Make sure your .env file is properly configured in your project directory.
from article_manager import ArticleManager
# Create an instance
manager = ArticleManager(bookmark_limit=25)
# Get article information
title = manager.get_current_title()
article_text = manager.get_current_article()
article_list = manager.get_bookmarks_list()
# Navigate articles
manager.next_bookmark()
manager.prev_bookmark()
manager.first_bookmark()
manager.last_bookmark()
# Jump to a specific article by number (1-based)
manager.set_bookmark_by_number(5)
# Manage articles
success, url, error = manager.add_bookmark_url("https://example.com")
success, title, error = manager.star_current_bookmark()
success, title, error = manager.archive_current_bookmark()
success, title, error = manager.delete_current_bookmark()
# Create highlights
success, title, highlight, error = manager.create_highlight_for_current("Important text")
# Parse article into sentences for speak mode functionality
sentences = manager.parse_current_article_sentences()
# Returns list of sentence strings: ["First sentence.", "Second sentence.", ...]
# Access the Instapaper client directly for advanced operations
bookmarks = manager.instapaper_client.bookmarks(limit=10)See example_usage.py for a complete demonstration of using ArticleManager programmatically.
The application is designed to be easily extensible. To add new commands:
- Add a new method to the
ArticleManagerclass inarticle_manager.py - Add error handling using try-except blocks with appropriate exception types
- Add a command handler function in
ip_conductor.py(following the pattern of existing handlers) - Add the command to the main command loop in the
run_console()function - Update the help messages to include the new command
This project includes comprehensive code quality tools to maintain clean, consistent, and error-free Python code:
- Black: Automatic code formatting for consistent style
- isort: Import statement organization and sorting
- Flake8: Style guide enforcement (PEP 8 compliance)
- Pylint: Comprehensive code analysis and quality checking
- Mypy: Static type checking for better code reliability
./lint.sh# Format code automatically
black ip_conductor.py article_manager.py
# Sort and organize imports
isort ip_conductor.py article_manager.py
# Check code style (PEP 8)
flake8 ip_conductor.py article_manager.py
# Comprehensive code analysis
pylint ip_conductor.py article_manager.py
# Static type checking
mypy ip_conductor.py article_manager.py --ignore-missing-imports.flake8: Flake8 configuration with 88-character line lengthpyproject.toml: Centralized configuration for Black, isort, Pylint, and Mypylint.sh: Convenient script to run all tools in sequence
The project includes VS Code settings that integrate these tools for real-time feedback. Install these recommended extensions:
- Python (ms-python.python)
- Pylint (ms-python.pylint)
- Black Formatter (ms-python.black-formatter)
- isort (ms-python.isort)
- Mypy Type Checker (ms-python.mypy-type-checker)
For more details, see LINTING.md.
If you're using VS Code with WSL, the project includes VS Code settings in .vscode/settings.json that will:
- Automatically use the project's virtual environment
- Activate the venv when opening new terminals
This provides seamless integration without manual activation within VS Code.
If you see an error about missing environment variables, ensure:
- Your
.envfile exists in the project root - All four required variables are set (USERNAME, PASSWORD, CONSUMER_KEY, CONSUMER_SECRET)
- There are no extra spaces or quotes around the values
If you get import errors when running from a WSL terminal outside VS Code:
cd /path/to/ip-conductor
source .venv/bin/activateThe virtual environment must be activated to access the installed packages.