Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: metadata lookup failure handling #1321

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/screens/settings/audio_sources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,22 @@ class _AudioSourcesScreenState extends State<AudioSourcesScreen> {
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<AudioModel>(context, listen: false);
if (!await AudioChannel.hasPermission()) {
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();
Expand Down
Loading