mangayomi-mirror/lib/services
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
..
anime_extractors dart format 2025-05-30 17:43:42 +01:00
download_manager fix(downloads): unstall anime downloads on sources that return URLs with query strings or HTTP 206 2026-05-09 19:10:35 -07:00
http Revert "fix(http): stabilize cloudflare resolver retry semantics" 2026-04-04 02:29:37 +02:00
trackers update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
aniskip.dart dart format 2025-05-30 17:43:42 +01:00
aniskip.g.dart update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
fetch_item_sources.dart Add IsolateService for improved asynchronous operations and refactor service calls to utilize it 2025-11-07 16:48:42 +01:00
fetch_item_sources.g.dart update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
fetch_sources_list.dart Update dependencies, refactor HTTP client handling and fix dart extension header handling 2026-04-03 12:13:11 +01:00
fetch_subtitles.dart added required api key via a cloudflare proxy 2026-03-28 20:54:39 +01:00
fetch_watch_order.dart added sequels 2025-08-25 01:52:03 +02:00
get_chapter_pages.dart Redundant GetChapterPagesModel created per page 2026-04-16 04:31:46 +02:00
get_chapter_pages.g.dart Change the MangasListStateProvider to Set<int> 2026-04-12 23:03:18 +02:00
get_detail.dart Add IsolateService for improved asynchronous operations and refactor service calls to utilize it 2025-11-07 16:48:42 +01:00
get_detail.g.dart update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
get_filter_list.dart Add service disposal and lifecycle cleanup 2026-01-13 01:11:19 +01:00
get_html_content.dart feat #682 option to split chapter whe importing local epub 2026-04-07 11:55:42 +01:00
get_html_content.g.dart feat #682 option to split chapter whe importing local epub 2026-04-07 11:55:42 +01:00
get_latest_updates.dart Add IsolateService for improved asynchronous operations and refactor service calls to utilize it 2025-11-07 16:48:42 +01:00
get_latest_updates.g.dart update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
get_popular.dart Add IsolateService for improved asynchronous operations and refactor service calls to utilize it 2025-11-07 16:48:42 +01:00
get_popular.g.dart update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
get_source_baseurl.dart Add service disposal and lifecycle cleanup 2026-01-13 01:11:19 +01:00
get_source_baseurl.g.dart Refactor 2026-03-02 11:49:19 +01:00
get_source_preference.dart Add service disposal and lifecycle cleanup 2026-01-13 01:11:19 +01:00
get_video_list.dart refactor: replace getExtensionService with getIsolateService for page and video list retrieval 2025-11-11 14:51:10 +01:00
get_video_list.g.dart update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
isolate_service.dart Update dependencies, refactor HTTP client handling and fix dart extension header handling 2026-04-03 12:13:11 +01:00
library_updater.dart Improve failure message by using itemType.name 2026-02-22 14:45:01 +01:00
m_extension_server.dart Use Platform Helper Everywhere Possible 2026-04-26 19:42:13 +02:00
recommendation.dart added Anibrain recommendations 2025-08-15 21:42:47 +02:00
search.dart Add IsolateService for improved asynchronous operations and refactor service calls to utilize it 2025-11-07 16:48:42 +01:00
search.g.dart update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
supports_latest.dart Add service disposal and lifecycle cleanup 2026-01-13 01:11:19 +01:00
supports_latest.g.dart Refactor 2026-03-02 11:49:19 +01:00
sync_server.dart Add keepAlive calls in Synching and SyncServer build methods 2025-11-08 22:04:57 +01:00
sync_server.g.dart update dependencies & update riverpod provider declarations 2026-01-08 14:27:08 +01:00
torrent_server.dart Use Platform Helper Everywhere Possible 2026-04-26 19:42:13 +02:00