diff --git a/lib/screens/settings/audio_sources.dart b/lib/screens/settings/audio_sources.dart index 10cf5c7b..1dcf38b7 100644 --- a/lib/screens/settings/audio_sources.dart +++ b/lib/screens/settings/audio_sources.dart @@ -47,7 +47,14 @@ class _AudioSourcesScreenState extends State { if (_formKey.currentState!.validate()) { // fetch the title for the page. final url = _textEditingController.text; - final metadata = await MetadataFetch.extract(url); + Metadata? metadata; + try { + metadata = await MetadataFetch.extract(url); + } catch (e) { + metadata = null; + } + + final title = metadata?.title ?? Uri.parse(url).host; if (!mounted) return; final model = Provider.of(context, listen: false); @@ -55,8 +62,7 @@ class _AudioSourcesScreenState extends State { if (!mounted) return; await model.showAudioPermissionDialog(context); } - await model - .addSource(AudioSource(metadata?.title, Uri.parse(url), false)); + await model.addSource(AudioSource(title, Uri.parse(url), false)); if (!mounted) return; _textEditingController.clear();