diff --git a/README.md b/README.md index e7ad875..755cd58 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,5 @@ - refactor code - use sliding to switch between history pages - optimize furigana display -- fix audio download failed case - ios REGEX - full-width/half-width unification \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index d30bca1..06c1aa7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -344,11 +344,15 @@ class _MyHomePageState extends State { setState(() { item['loading'] = true; }); - var file = await DefaultCacheManager() - .getSingleFile(url, headers: burpHeader); - var hash = await sha256.bind(file.openRead()).first; - if (hash.toString() == - 'ae6398b5a27bc8c0a771df6c907ade794be15518174773c58c7c7ddd17098906') { + try { + var file = await DefaultCacheManager() + .getSingleFile(url, headers: burpHeader); + var hash = await sha256.bind(file.openRead()).first; + if (hash.toString() == + 'ae6398b5a27bc8c0a771df6c907ade794be15518174773c58c7c7ddd17098906') { + throw const FormatException("NOT IMPLEMENTED"); + } + } catch (_) { url = audio.getElementsByTagName('source')[0].attributes['src']; } break; @@ -383,7 +387,9 @@ class _MyHomePageState extends State { match = utf8.decode(base64.decode(match!)); url = 'https://audio00.forvo.com/ogg/$match'; } - } catch (_) {} + } catch (_) { + url = null; + } } if (url != null && url.isNotEmpty) { setState(() { @@ -395,7 +401,9 @@ class _MyHomePageState extends State { await DefaultCacheManager().getSingleFile(url, headers: burpHeader); await player.setFilePath(file.path); player.play(); - } catch (_) {} + } catch (_) { + url = null; + } } setState(() { _hatsuonCache[item['idex']] = url;