mangayomi-mirror/lib/utils
Mehakdeep Singh bbc7fa04f5 fix(downloads): unstall anime downloads on sources that return URLs with query strings or HTTP 206
Two related bugs left anime downloads stuck at 0% with no error visible to
the user. Manga downloads from clean HTTPS sources were unaffected.

1) lib/utils/extensions/string_extensions.dart

   isMediaVideo() did a plain endsWith on the full URL string, so URLs
   shaped like https://host/play/{id}/video.mp4?for={token} (used by
   AnimeGG and several other sources) failed the filter because of the
   trailing `?for=...` query string. With both m3u8Urls and nonM3u8Urls
   empty in downloadChapter, the surrounding
   Future.doWhile(() => isOk == true) poll never sets isOk and waits
   forever -- MDownloader is never constructed.

   Fix: match against Uri.tryParse(this)?.path instead of the full
   string, and use a leading "." in the suffix so e.g. "flashmp4" cannot
   accidentally match.

2) lib/services/download_manager/download_isolate_pool.dart

   Once the URL passes the filter, _downloadFile (anime branch) opens a
   streaming request. When the source extension sets Range: bytes=0-,
   the server correctly responds with HTTP 206 Partial Content. The
   previous "if (response.statusCode != 200)" check rejected that,
   retried 3x, and threw. The throw was masked by an outer catch(_) in
   downloadChapter, so the user only saw a forever-spinner.

   Fix: accept any 2xx (>= 200 && < 300). Same fix applied to
   _downloadSegment for HLS segment fetches.

Repro
- Source: AnimeGG (en) -- install via Mangayomi extensions
- Pick any episode (tested with Toriko Ep 147, Gintama Ep 39, Grand Blue
  Ep 12)
- Tap the download icon

Before: an empty
".../AnimeGG (EN)/<series>/<episode>.mp4"-named folder is created, the
download icon stays in the spinner state, no error toast.

After: the .mp4 is written to disk at the size declared in Content-Length
(65,026,283 bytes for Toriko Ep 147), plays in the system video player.

Tested on macOS 26.3 / Apple Silicon with AnimeGG (multiple episodes,
multiple series, including a 180 MB 720p) and a manga control
(Asura Scans, 9 pages) on the same build to confirm no regression on the
manga path.
2026-05-09 19:10:35 -07:00
..
cryptoaes dart format 2025-05-30 17:43:42 +01:00
extensions fix(downloads): unstall anime downloads on sources that return URLs with query strings or HTTP 206 2026-05-09 19:10:35 -07:00
log Fix Exception 2026-04-21 21:45:40 +02:00
url_protocol refactor: improve download button logic and clean up code 2025-04-01 17:15:54 +01:00
cached_network.dart Don't allow zooming 2025-06-29 20:30:16 +02:00
chapter_recognition.dart Add multi-season support and split parse methods 2026-04-26 03:32:28 +02:00
constant.dart adjusted tracker icons 2025-08-25 19:08:50 +02:00
date.dart testing iOS Picture-in-Picture 2025-08-07 21:37:46 +02:00
discord_rpc.dart Initialize rpcShowReadingWatchingProgress to false 2025-11-08 23:57:32 +01:00
fetch_interval.dart feat: Implement upcoming manga calendar feature 2026-03-05 12:05:29 +01:00
global_style.dart dart format 2025-02-23 15:31:49 +01:00
headers.dart refactor: enhance headers function for mihon source 2026-04-06 13:03:41 +01:00
headers.g.dart feat #682 option to split chapter whe importing local epub 2026-04-07 11:55:42 +01:00
html_to_xml_doc.dart remove unnecessary calls 2025-12-17 21:34:45 +01:00
item_type_filters.dart Group related functions using an extension 2025-12-29 23:19:31 +01:00
item_type_localization.dart Group related functions using an extension 2025-12-29 23:19:31 +01:00
language.dart + 2025-11-08 23:43:01 +01:00
platform_utils.dart Use Platform Helper Everywhere Possible 2026-04-26 19:42:13 +02:00
reg_exp_matcher.dart Fix indexing and path for downloaded chapter images and update padding logic 2025-06-04 17:28:31 +01:00
riverpod.dart Refactor and update dependencies for Isar and Riverpod 2025-10-29 13:08:42 +01:00
system_ui.dart Reduce Code Duplication Across 3 Files 2026-04-26 15:03:56 +02:00
utils.dart small adjustments for a better reading experience of many single pages in a row 2026-01-30 23:15:26 +01:00
window_geometry.dart feat: implement multiple bug fixes and feature requests\n\n- #339: Remember window size/position on desktop (WindowGeometry utility)\n- #256: Add S key shortcut to skip intro in desktop anime player\n- #372: Auto-delete downloaded chapters after reading (new setting + toggle)\n- #402: Fix manhwa reader scroll jumps by caching image dimensions for placeholders\n- #608: Fix 'Fit width' scale type cropping pages in paged reader mode\n- #572: Add mouse back button navigation support on desktop" 2026-03-17 14:31:21 +01:00
xpath_selector.dart initial adding madara multi source 2023-05-25 20:59:02 +01:00