Fix Discogs API integration with proper authentication

- Updated to use python3-discogs-client==2.8 library
- Added environment variable configuration for API keys
- Implemented proper error handling for missing API credentials
- Added .env file for configuration management
- Enhanced search functionality with graceful fallbacks
- Updated README with Discogs API setup instructions
This commit is contained in:
2025-08-11 16:15:15 +07:00
parent 28f927e973
commit d9f184d084
8 changed files with 655 additions and 0 deletions

86
templates/index.html Normal file
View File

@@ -0,0 +1,86 @@
{% extends "base.html" %}
{% block title %}Search Media - Media Inventory App{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">
<h2 class="card-title mb-0">🔍 Search Media</h2>
</div>
<div class="card-body">
{% if error %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endif %}
<form method="post" action="/search">
<div class="mb-3">
<label for="media_type" class="form-label">Media Type</label>
<select class="form-select" id="media_type" name="media_type" required>
<option value="">Select media type...</option>
<option value="book">📚 Book</option>
<option value="vinyl">🎵 Vinyl Record</option>
<option value="cd">💿 CD</option>
<option value="cassette">📼 Cassette</option>
</select>
</div>
<div class="mb-3">
<label for="query" class="form-label">Search Query</label>
<input type="text" class="form-control" id="query" name="query"
placeholder="Enter title, album name, or keywords..." required>
<div class="form-text">
For books: Enter book title or author name<br>
For music: Enter album title or song name
</div>
</div>
<div class="mb-3" id="artist-field" style="display: none;">
<label for="artist" class="form-label">Artist (Optional)</label>
<input type="text" class="form-control" id="artist" name="artist"
placeholder="Enter artist name...">
<div class="form-text">
Helps narrow down music search results
</div>
</div>
<button type="submit" class="btn btn-primary btn-lg w-100">
🔍 Search
</button>
</form>
</div>
</div>
<div class="mt-4">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0"> How it works</h5>
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong>📚 Books:</strong> Searches OpenLibrary.org for book information</li>
<li><strong>🎵 Music (Vinyl/CD/Cassette):</strong> Searches Discogs.com for music releases</li>
<li><strong>🎯 Tips:</strong> Be specific with your search terms for better results</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<script>
document.getElementById('media_type').addEventListener('change', function() {
const artistField = document.getElementById('artist-field');
const selectedType = this.value;
if (selectedType === 'vinyl' || selectedType === 'cd' || selectedType === 'cassette') {
artistField.style.display = 'block';
} else {
artistField.style.display = 'none';
}
});
</script>
{% endblock %}