Skip to content

Commit 94e43ad

Browse files
committed
fixes
1 parent ed2e4a6 commit 94e43ad

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

nowplaying/processes/trackpoll.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,20 @@ def _write_to_text(self):
382382
templatehandler=self.txttemplatehandler,
383383
metadata=self.currentmeta)
384384

385-
def _strip_blobs_metadata(self, metadata: TrackMetadata) -> TrackMetadata:
385+
@staticmethod
386+
def _strip_blobs_metadata(metadata: TrackMetadata) -> TrackMetadata:
386387
''' Strip binary blob data for remote transmission '''
387388
remote_data = metadata.copy()
388389

389390
# Remove all blob fields
390391
for key in nowplaying.db.METADATABLOBLIST:
391392
remote_data.pop(key, None)
392393

394+
for key, value in remote_data.items():
395+
if isinstance(value, bytes):
396+
logging.error("%s was dropped from remote_data (bytes)", key)
397+
remote_data.pop(key, None)
398+
393399
# Remove dbid if present
394400
if remote_data.get('dbid'):
395401
del remote_data['dbid']
@@ -411,10 +417,10 @@ async def _write_to_remote(self) -> None:
411417
# Debug: write JSON to file to inspect
412418
try:
413419
debug_file = '/tmp/remote_debug.json'
414-
with open(debug_file, 'w', encoding='utf-8') as f:
415-
json.dump(remote_data, f, indent=2)
420+
with open(debug_file, 'w', encoding='utf-8') as fnout:
421+
json.dump(remote_data, fnout, indent=2)
416422
logging.info('Debug: wrote remote data to %s', debug_file)
417-
except Exception as exc: # pylint: disable=broad-except
423+
except Exception: # pylint: disable=broad-except
418424
logging.exception('Failed to write debug JSON: %s')
419425

420426
async with aiohttp.ClientSession() as session:

tests/test_remote.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ async def test_remote_plugin_getplayingtrack(remote_bootstrap): # pylint: disab
159159
test_metadata = {'artist': 'Test Artist', 'title': 'Test Title', 'filename': 'test.mp3'}
160160
plugin.metadata = test_metadata
161161

162-
with patch.object(plugin, 'start') as mock_start:
162+
# Mock the database initialization in start() to avoid actual file operations
163+
with patch('nowplaying.db.MetadataDB'), patch('nowplaying.db.DBWatcher'):
163164
result = await plugin.getplayingtrack()
164-
mock_start.assert_called_once()
165165
assert result == test_metadata
166166

167167

@@ -301,8 +301,10 @@ async def test_remote_plugin_config_missing_remotedb(bootstrap):
301301

302302
plugin = nowplaying.inputs.remote.Plugin(config=config)
303303

304-
# Should handle missing config gracefully
305-
assert plugin.remotedbfile is None or plugin.remotedbfile == ''
304+
# Plugin now sets a default path via defaults() method
305+
# So remotedbfile should contain a valid path, not be None/empty
306+
assert plugin.remotedbfile is not None
307+
assert 'remote.db' in plugin.remotedbfile
306308

307309

308310
@pytest.mark.asyncio

0 commit comments

Comments
 (0)