Skip to content

Java CLI application to pick random albums from Discogs collection with Spotify integration

License

Notifications You must be signed in to change notification settings

alfdagos/discogs-random-picker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Discogs Random Picker

๐ŸŽฒ A powerful Java CLI application that picks random albums from your Discogs collection and tracks your listening history with advanced features.

โœจ Features

Core Features

  • ๐ŸŽฒ Random Album Selection - Randomly pick albums from your Discogs collection
  • ๐Ÿ” Advanced Filtering - Filter by genre, year, format, artist, or decade
  • ๐Ÿ“Š Listening History - Track all albums you've listened to with timestamps
  • ๐Ÿ“ˆ Statistics Dashboard - View comprehensive stats about your listening habits
  • ๐Ÿ“ค Export Options - Export history to CSV, HTML, or Markdown formats
  • ๐Ÿšซ Duplicate Detection - Automatically detects if you've already listened to an album
  • ๐Ÿ’พ Persistent Storage - All history saved in JSON format

Technical Features

  • โšก Professional Logging - SLF4J + Logback for comprehensive logging
  • ๐Ÿ—๏ธ Clean Architecture - Separated into models, services, and configuration layers
  • โœ… Well Tested - Includes JUnit 5 unit tests with high coverage
  • ๐Ÿ›ก๏ธ Robust Error Handling - Custom exceptions for better error management
  • ๐Ÿ”„ Rate Limiting - Automatic retry logic for Discogs API calls
  • ๐Ÿ“ Extensive Documentation - JavaDoc comments throughout

๐Ÿš€ Quick Start

Prerequisites

  • Java 11 or higher
  • Maven 3.6 or higher
  • Discogs account with API token

Installation

  1. Clone the repository:

    git clone https://github.com/alfdagos/discogs-random-picker.git
    cd discogs-random-picker
  2. Create configuration file:

    cp config.properties.example config.properties
  3. Configure your credentials:

    Edit config.properties and add:

  4. Build the project:

    mvn clean package

๐Ÿ“– Usage

Basic Usage

Pick a random album (no arguments):

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar

Or with Maven:

mvn exec:java -Dexec.mainClass="com.alfdagos.discogsrandompicker.DiscogsRandomPicker"

Advanced Usage

Filter Options

Filter by genre:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --genre Rock

Filter by specific year:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --year 1980

Filter by decade:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --min-year 1970 --max-year 1979

Filter by format:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --format Vinyl

Filter by artist:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --artist "Pink Floyd"

Combine multiple filters:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --genre Rock --min-year 1970 --max-year 1979 --format Vinyl

History & Statistics

View listening statistics:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --stats

View listening history:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --history

View last 10 entries:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --history --limit 10

Check collection size:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --collection-size

Export Options

Export to CSV:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --export csv

Export to HTML:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --export html -o myhistory.html

Export to Markdown:

java -jar target/discogs-random-picker-1.0-SNAPSHOT.jar --export markdown

All Command Line Options

-h, --help              Show help message
-v, --version           Show version
-s, --stats             Show listening statistics
    --history           Show listening history
    --collection-size   Show collection size
    --limit <NUMBER>    Limit number of history entries
-g, --genre <GENRE>     Filter by genre
-y, --year <YEAR>       Filter by year
-f, --format <FORMAT>   Filter by format (Vinyl, CD, etc.)
-a, --artist <ARTIST>   Filter by artist name
    --min-year <YEAR>   Minimum year for range filter
    --max-year <YEAR>   Maximum year for range filter
-e, --export <FORMAT>   Export history (csv, html, markdown)
-o, --output <FILE>     Output filename for export
    --no-duplicate      Skip albums already in history

๐Ÿ“ Project Structure

discogs-random-picker/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/com/alfdagos/discogsrandompicker/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ DiscogsRandomPicker.java       # Main application
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ConfigManager.java         # Configuration management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ exception/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ConfigurationException.java
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ DiscogsApiException.java
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ HistoryException.java
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ model/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Album.java                 # Album entity
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AlbumFilter.java           # Filter criteria
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ListeningHistoryEntry.java # History entry
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Statistics.java            # Statistics model
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ service/
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ DiscogsService.java        # Discogs API interaction
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ HistoryService.java        # History management
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ StatisticsService.java     # Statistics generation
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ ExportService.java         # Export functionality
โ”‚   โ”‚   โ””โ”€โ”€ resources/
โ”‚   โ”‚       โ””โ”€โ”€ logback.xml                    # Logging configuration
โ”‚   โ””โ”€โ”€ test/
โ”‚       โ””โ”€โ”€ java/com/alfdagos/discogsrandompicker/
โ”‚           โ”œโ”€โ”€ model/
โ”‚           โ”‚   โ”œโ”€โ”€ AlbumTest.java
โ”‚           โ”‚   โ””โ”€โ”€ AlbumFilterTest.java
โ”‚           โ””โ”€โ”€ service/
โ”‚               โ””โ”€โ”€ HistoryServiceTest.java
โ”œโ”€โ”€ config.properties.example                  # Example configuration
โ”œโ”€โ”€ listening_history.json                     # Listening history (auto-generated)
โ”œโ”€โ”€ pom.xml                                    # Maven configuration
โ””โ”€โ”€ README.md                                  # This file

๐Ÿ”ง Configuration

Create a config.properties file in the project root:

# Discogs API Configuration
# Get your token from: https://www.discogs.com/settings/developers
discogs.username=your_discogs_username
discogs.token=your_discogs_api_token

# Spotify API Configuration (Optional - for future integration)
spotify.client.id=your_spotify_client_id
spotify.client.secret=your_spotify_client_secret

๐Ÿ“Š Statistics Example

The statistics feature provides insights like:

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘     LISTENING HISTORY STATISTICS     โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ“€ Total Albums Listened: 142

๐ŸŽค Most Listened Artist: Pink Floyd (8 albums)
๐Ÿ“… Most Popular Year: 1977 (12 albums)
๐Ÿ•ฐ๏ธ  Most Popular Decade: 1970s (58 albums)

๐ŸŽธ Top 5 Artists:
   Pink Floyd: 8 albums
   The Beatles: 7 albums
   Led Zeppelin: 6 albums
   David Bowie: 5 albums
   Radiohead: 4 albums

๐Ÿ“† Top 5 Years:
   1977: 12 albums
   1973: 10 albums
   1971: 9 albums
   1980: 8 albums
   1975: 8 albums

๐Ÿงช Testing

Run the test suite:

mvn test

Run with coverage:

mvn clean test jacoco:report

๐Ÿ“ Logging

Logs are stored in logs/discogs-random-picker.log and rotated daily. Configure logging levels in src/main/resources/logback.xml.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

MIT License

๐Ÿ™ Acknowledgments

๐Ÿ”ฎ Future Features

  • ๐ŸŽง Spotify integration for direct playback
  • ๐ŸŒ Web interface for browsing history
  • ๐Ÿ“ฑ REST API for mobile integration
  • ๐ŸŽจ Album cover display in terminal
  • ๐Ÿ”” Notifications when new albums are added to collection
  • ๐Ÿ“Š Advanced analytics and charts
  • ๐ŸŽฏ Recommendation system based on listening history

๐Ÿ’ก Tips & Tricks

  1. Create shortcuts - Add aliases to your shell for common commands
  2. Regular exports - Export your history regularly as backup
  3. Use filters wisely - If a filter returns no results after 50 attempts, try relaxing your criteria
  4. Check collection size - Use --collection-size to see how many albums you have

๐Ÿ› Troubleshooting

"Configuration Error: Discogs username not configured"

Make sure you've created config.properties from the example file and filled in your credentials.

"API request failed with status code: 401"

Your Discogs token is invalid. Get a new one from https://www.discogs.com/settings/developers

"Rate limited after X retries"

The application respects Discogs API rate limits. Wait a moment and try again.

๐Ÿ“ž Support

If you encounter any issues or have questions:

  • Open an issue on GitHub
  • Check existing issues for solutions
  • Review the logs in logs/discogs-random-picker.log

Made with โค๏ธ by alfdagos

Version 2.0 - Enhanced Edition

About

Java CLI application to pick random albums from Discogs collection with Spotify integration

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages