Messages are much less verbose now.
This commit is contained in:
@@ -294,8 +294,6 @@ class AudiobookshelfClient:
|
||||
downloadUrl = f"{self.serverUrl}/api/items/{itemId}/file"
|
||||
headers = {'Authorization': f'Bearer {self.authToken}'}
|
||||
|
||||
print(f"DEBUG: Downloading from: {downloadUrl}")
|
||||
|
||||
# Download with streaming to handle large files
|
||||
# Use context manager to ensure response cleanup
|
||||
with requests.get(downloadUrl, headers=headers, stream=True, timeout=30) as response:
|
||||
@@ -348,14 +346,9 @@ class AudiobookshelfClient:
|
||||
# Validate item exists and has audio content (optional check)
|
||||
if itemDetails:
|
||||
media = itemDetails.get('media', {})
|
||||
numAudioFiles = media.get('numAudioFiles', 0)
|
||||
duration = media.get('duration', 0.0)
|
||||
print(f"DEBUG: Item has {numAudioFiles} audio files, duration {duration}s")
|
||||
|
||||
# Use the /play endpoint which creates a playback session and returns stream info
|
||||
# This is what the web player uses
|
||||
playUrl = f"{self.serverUrl}/api/items/{itemId}/play"
|
||||
print(f"DEBUG: Requesting play session from: {playUrl}")
|
||||
|
||||
response = requests.post(
|
||||
playUrl,
|
||||
@@ -378,7 +371,6 @@ class AudiobookshelfClient:
|
||||
return None
|
||||
|
||||
playData = response.json()
|
||||
print(f"DEBUG: Play response keys: {list(playData.keys())}")
|
||||
|
||||
# Extract the actual stream URL from the play response
|
||||
# The response contains either 'audioTracks' or direct 'url'
|
||||
@@ -389,15 +381,12 @@ class AudiobookshelfClient:
|
||||
# Multi-file audiobook - use first track or concatenated stream
|
||||
audioTrack = playData['audioTracks'][0]
|
||||
streamUrl = audioTrack.get('contentUrl')
|
||||
print(f"DEBUG: Using audioTrack URL")
|
||||
elif 'url' in playData:
|
||||
# Direct URL
|
||||
streamUrl = playData.get('url')
|
||||
print(f"DEBUG: Using direct URL")
|
||||
elif 'contentUrl' in playData:
|
||||
# Alternative format
|
||||
streamUrl = playData.get('contentUrl')
|
||||
print(f"DEBUG: Using contentUrl")
|
||||
|
||||
if not streamUrl:
|
||||
print(f"ERROR: No stream URL found in play response")
|
||||
@@ -408,7 +397,6 @@ class AudiobookshelfClient:
|
||||
if streamUrl.startswith('/'):
|
||||
streamUrl = f"{self.serverUrl}{streamUrl}"
|
||||
|
||||
print(f"DEBUG: Stream URL: {streamUrl[:100]}...")
|
||||
return streamUrl
|
||||
|
||||
except Exception as e:
|
||||
@@ -551,7 +539,6 @@ class AudiobookshelfClient:
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
sessionId = data.get('id')
|
||||
print(f"DEBUG: Session created successfully: {sessionId}")
|
||||
return sessionId
|
||||
else:
|
||||
# Session creation not critical, just log and continue
|
||||
|
||||
@@ -177,15 +177,6 @@ class AudiobookshelfMenu:
|
||||
elif direction == 'down':
|
||||
self.currentSelection = (self.currentSelection + 1) % len(self.items)
|
||||
|
||||
# Debug output
|
||||
print(f"DEBUG NAV: {direction} - moved from {oldSelection} to {self.currentSelection} (total items: {len(self.items)})")
|
||||
if self.currentSelection < len(self.items):
|
||||
item = self.items[self.currentSelection]
|
||||
media = item.get('media', {})
|
||||
metadata = media.get('metadata', {})
|
||||
title = metadata.get('title', 'Unknown')
|
||||
print(f"DEBUG NAV: Current item title: {title}")
|
||||
|
||||
self._speak_current_item()
|
||||
|
||||
def change_view(self, direction):
|
||||
@@ -375,31 +366,21 @@ class AudiobookshelfMenu:
|
||||
# Book selected
|
||||
self.selectedBook = item
|
||||
|
||||
# Debug: what book did user select?
|
||||
media = item.get('media', {})
|
||||
metadata = media.get('metadata', {})
|
||||
title = metadata.get('title', 'Unknown')
|
||||
print(f"\nDEBUG SELECT: User pressed ENTER on item {self.currentSelection}")
|
||||
print(f"DEBUG SELECT: Book title: {title}")
|
||||
print(f"DEBUG SELECT: Book ID: {item.get('id', 'NO ID')}")
|
||||
|
||||
# For books from series/collections, fetch full details if needed
|
||||
# (they might have incomplete metadata)
|
||||
if not item.get('media'):
|
||||
# Book doesn't have full media details, fetch them
|
||||
bookId = item.get('id') or item.get('libraryItemId')
|
||||
if bookId:
|
||||
print(f"\nFetching full details for book ID: {bookId}")
|
||||
fullDetails = self.absClient.get_library_item_details(bookId)
|
||||
if fullDetails:
|
||||
self.selectedBook = fullDetails
|
||||
item = fullDetails
|
||||
print("Full book details loaded")
|
||||
# Re-extract metadata from full details
|
||||
media = item.get('media', {})
|
||||
metadata = media.get('metadata', {})
|
||||
title = metadata.get('title', 'Unknown')
|
||||
print(f"DEBUG SELECT: After fetch, title is: {title}")
|
||||
|
||||
# Get metadata for later use
|
||||
media = item.get('media', {})
|
||||
metadata = media.get('metadata', {})
|
||||
title = metadata.get('title', 'Unknown')
|
||||
|
||||
# Check if local copy exists
|
||||
isLocal = self._check_if_local(item)
|
||||
|
||||
@@ -54,8 +54,6 @@ class FolderAudiobookParser:
|
||||
if not audioFiles:
|
||||
raise ValueError(f"No audio files found in: {folderPath}")
|
||||
|
||||
print(f"Found {len(audioFiles)} audio files in folder")
|
||||
|
||||
# Extract metadata from each file
|
||||
fileMetadata = []
|
||||
for audioFile in audioFiles:
|
||||
@@ -98,10 +96,6 @@ class FolderAudiobookParser:
|
||||
book.audioFiles = [fileData['path'] for fileData in sortedFiles]
|
||||
book.isMultiFile = True
|
||||
|
||||
print(f"Loaded: {book.title} by {book.author}")
|
||||
print(f"Total duration: {totalDuration / 60:.1f} minutes")
|
||||
print(f"Chapters: {len(book.chapters)}")
|
||||
|
||||
return book
|
||||
|
||||
def _find_audio_files(self, folderPath):
|
||||
|
||||
Reference in New Issue
Block a user