diff --git a/modules/videos/channel/api.py b/modules/videos/channel/api.py index 07d8169a..a372ec5f 100644 --- a/modules/videos/channel/api.py +++ b/modules/videos/channel/api.py @@ -49,7 +49,9 @@ def channel_post(_: Request, body: schema.ChannelPostRequest): if not body.directory.is_dir() and body.mkdir: make_media_directory(body.directory) - channel = lib.create_channel(body.__dict__) # TODO don't use the dataclass as a dict. + bd_edit = body.__dict__ + bd_edit['name'] = bd_edit['name'].strip() + channel = lib.create_channel(bd_edit) # TODO don't use the dataclass as a dict. # Refresh the videos asynchronously from ..api import refresh_videos diff --git a/modules/videos/channel/test/test_api.py b/modules/videos/channel/test/test_api.py index 0d00600a..3af4c84f 100644 --- a/modules/videos/channel/test/test_api.py +++ b/modules/videos/channel/test/test_api.py @@ -50,7 +50,7 @@ class TestVideoAPI(TestAPI): new_channel = dict( directory=channel_directory, match_regex='asdf', - name='Example Channel 1', + name=' Example Channel 1 ', url='https://example.com/channel1', ) @@ -67,6 +67,9 @@ class TestVideoAPI(TestAPI): self.assertIsNotNone(created) self.assertIsNotNone(created['id']) + # Channel name leading/trailing whitespace should be stripped + assert created['name'] == 'Example Channel 1' + # Channel directory should be relative to the media directory assert not pathlib.Path(created['directory']).is_absolute(), \ f'Channel directory is absolute: {created["directory"]}'