From 3ef08f86bc3023e91760bca96ee48b3fa971f3b8 Mon Sep 17 00:00:00 2001 From: tacosandtypescript-debug Date: Mon, 31 Aug 2026 05:24:57 -0400 Subject: [PATCH 1/2] FlowMobile 8.0.7: iOS nativo, TikTok y calidades reales MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Compartir y reproducir en iOS usa ios_system (a-Shell) en lugar de abrir Safari. - TikTok reintenta hosts extra de API con un device_id fresco cuando falla el extractor. - Las calidades listadas salen solo de formatos descargables; el selector recorta por el lado corto de la resolución. --- CHANGELOG.md | 9 ++ README.md | 4 +- SECURITY_MANIFEST.sha256 | 8 +- VERSION | 2 +- docs/GUIA_COMPLETA.md | 5 +- flow/__init__.py | 2 +- flow/infrastructure/device.py | 32 ++++++- flow/infrastructure/ytdlp_gateway.py | 129 ++++++++++++++++++++------- flow/presentation/cli.py | 14 +++ tests/test_device.py | 24 ++++- tests/test_quality.py | 52 +++++++++-- 11 files changed, 228 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e36589d..4b1c088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Historial de versiones +## 8.0.7 — 2026-08-31 + +- Compartir y reproducir en iPhone/iPad usan `ios_system` de a-Shell, no un proceso Unix aislado. +- Tras cada descarga se indica la ruta en Archivos › a-Shell › FlowMobile. +- Si la hoja de iOS no abre, se muestran pasos para Compartir y Guardar en Fotos. +- TikTok reintenta en más hosts de API móvil con un device_id nuevo, no uno quemado. +- El menú de calidades solo lista formatos con URL real; no inventa 360p/720p/1080p. +- La descarga limita de verdad al lado corto elegido, no solo reordena formatos. + ## 8.0.6 — 2026-08-12 - TikTok reintenta automáticamente con la API móvil cuando falla la extracción web. diff --git a/README.md b/README.md index 1a7de24..dc2cecd 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Descarga vídeos o extrae audio desde **iOS, Android, Windows y Linux**. El comando para abrir la aplicación es `flow`. -Versión actual: **8.0.6**. +Versión actual: **8.0.7**. [![CI](https://github.com/tacosandtypescript-debug/FlowMobile/actions/workflows/ci.yml/badge.svg)](https://github.com/tacosandtypescript-debug/FlowMobile/actions/workflows/ci.yml) [![Última versión](https://img.shields.io/github/v/release/tacosandtypescript-debug/FlowMobile?label=versión&color=7c3aed)](https://github.com/tacosandtypescript-debug/FlowMobile/releases/latest) @@ -47,7 +47,7 @@ Si el botón no abre, usa el respaldo para - Audio automático, M4A o MP3. - YouTube, TikTok, Facebook, Instagram, X y otras 30 plataformas. - Historial, lotes, playlists, reanudación y cancelación limpia. -- Compartir archivos y mostrarlos en la galería de Android. +- Compartir archivos, Guardar en Fotos en iOS y galería de Android. - Cookies privadas, actualizaciones, diagnóstico y modo de reparación. ## Dónde aparecen las descargas diff --git a/SECURITY_MANIFEST.sha256 b/SECURITY_MANIFEST.sha256 index 7b7d268..847cd3b 100644 --- a/SECURITY_MANIFEST.sha256 +++ b/SECURITY_MANIFEST.sha256 @@ -1,5 +1,5 @@ bc65ac1f04d1daf95e2becdff1187d00e62afd1cc56e83c23256b8e93c03bb97 bootstrap_ios.py -1788180c33607b00c61c7c664e3491b0f41981eb7c69e10690dd7ff5b90b5d07 flow/__init__.py +bb685d90585ece46eded155676125c0e881475a1c4b747dee94682056f6c9e62 flow/__init__.py e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 flow/application/__init__.py 7b4d5de99e6b1a966cccd68f70a10ce0ccf6dab05583314727c04d37ca495a22 flow/application/media_service.py 16c46681e9d59b84a59a19442d12892d146cb21ecb5acc7faa25bce7f5348379 flow/application/real_tests.py @@ -14,7 +14,7 @@ ad81f8b337eb6f777a4dd142c97e95b7ad365c6f0c0106067a018b0cf897725b flow/domain/mo e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 flow/infrastructure/__init__.py 8666a2a85c55b22c1d5238af4152025f9f415230b722c30b256e3ff0e01a1674 flow/infrastructure/batches.py b859f19f74df5605e664825fafdcf0df38ff5fc0f39debef9714deaf06eb4530 flow/infrastructure/clipboard.py -9c283ca9b9dcedfe241fdd45e4880d7713d0766141aa2b9aab9cc21a168b914f flow/infrastructure/device.py +b7c16c83d05581206e13c588206cbc7543a80e143ece80cbe436f24453a732dc flow/infrastructure/device.py 0de44e7db16bc34633159f133a8764ec59104652cb216088917eb9cd2f069265 flow/infrastructure/diagnostics.py e3683f7d87e118f717999d899950a30152f84dda68b1ffd9da00c5e54bd86537 flow/infrastructure/feedback.py a709587a39ba77b1eb2b7c2b60a654ac7ae4613b1202168614e98be461ca5d6f flow/infrastructure/ffmpeg.py @@ -30,9 +30,9 @@ f1e7e3132df532659ce39eaecfdc13e783f9ad529ec97144f564e1c8b4f317c3 flow/infrastru b2d5a084f1276bac16c87769a32c6a7165816ed006e16b9f2e3f4621b6a5276b flow/infrastructure/settings.py 12052b1c424e8ef935d6cc89b54baa55f21603cb29ba7123f7082afbd5ffb1e6 flow/infrastructure/uninstall.py 046f27d2016ac365f452f8df8ec92f72763b7067fc4c6e02faa5c3e10b9aec03 flow/infrastructure/updates.py -be49fbc4bf31bda5d2f2d458b526c0acf64aebc6e8fcd7255d259dd4f5f56f34 flow/infrastructure/ytdlp_gateway.py +5748e1b999b21be6e99096e0693097ce57f388e91d336cb32369c6b8c11f884b flow/infrastructure/ytdlp_gateway.py e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 flow/presentation/__init__.py -35b0565d22b41aa194ffb430e0d7c0614a4d1839725e82cec5cfb38649977f42 flow/presentation/cli.py +07bc29868f175123953c215b8d8dc8fb459278dfb5fa2bb58e7143a554be66e0 flow/presentation/cli.py 37969356b90b0cacae43cb7a171ecb00468eb9b213535d073aea73e52834aa77 flow/presentation/theme.py 180a06189d1a4a43afadca937699fe71547c688452078a6504df660ce4597cd9 flow/presentation/tools_menu.py 19eaec49c93f8d1b91b90ec50da3149a69820d83e50a45a207afd267a434ab60 flow/presentation/update_menu.py diff --git a/VERSION b/VERSION index 68d92dd..404f7d9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.6 +8.0.7 diff --git a/docs/GUIA_COMPLETA.md b/docs/GUIA_COMPLETA.md index 6477ece..072b431 100644 --- a/docs/GUIA_COMPLETA.md +++ b/docs/GUIA_COMPLETA.md @@ -70,7 +70,10 @@ archivo no coincide con el release oficial y la instalación debe detenerse. ## Descargas y galería -- a-Shell guarda los archivos dentro de `FlowMobile/Downloads`. +- a-Shell guarda los archivos dentro de `FlowMobile/Downloads` (vídeos y + audios en subcarpetas). En el iPhone aparecen en **Archivos › a-Shell › + FlowMobile › Downloads**. Compartir abre la hoja de iOS para Guardar en + Fotos, AirDrop o Mensajes. - Android guarda los vídeos en `Movies/FlowMobile` y los audios en `Music/FlowMobile`. - Android registra los archivos terminados en el catálogo multimedia para que diff --git a/flow/__init__.py b/flow/__init__.py index 903dbeb..39a0063 100644 --- a/flow/__init__.py +++ b/flow/__init__.py @@ -1,2 +1,2 @@ APP_NAME = "FlowMobile" -APP_VERSION = "8.0.6" +APP_VERSION = "8.0.7" diff --git a/flow/infrastructure/device.py b/flow/infrastructure/device.py index f869d81..ca9d16b 100644 --- a/flow/infrastructure/device.py +++ b/flow/infrastructure/device.py @@ -3,6 +3,7 @@ import mimetypes import os from pathlib import Path +import shlex import shutil import subprocess from urllib.parse import urlparse @@ -17,6 +18,29 @@ def _run(command: list[str]) -> bool: return False +def _ashell_run(command: str) -> bool: + """Ejecuta un comando de a-Shell vía ios_system; subprocess no los ve.""" + try: + import ctypes + + executor = ctypes.CDLL(None).ios_system + executor.argtypes = (ctypes.c_char_p,) + executor.restype = ctypes.c_int + except (AttributeError, ImportError, OSError): + return False + try: + return executor(command.encode("utf-8")) == 0 + except (OSError, TypeError, ValueError): + return False + + +def _ashell_open(path_or_url: str, command: str = "open") -> bool: + quoted = shlex.quote(path_or_url) + if _ashell_run(f"{command} {quoted}"): + return True + return _run([command, path_or_url]) + + def _windows_open(target: str) -> bool: try: os.startfile(target) # type: ignore[attr-defined] @@ -73,7 +97,7 @@ def open_share(path: Path) -> bool: return _run(["explorer.exe", "/select,", str(path.resolve())]) if getattr(PLATFORM, "is_linux", False): return _run(["xdg-open", str(path.resolve().parent)]) - return _run(["open", portable_path]) + return _ashell_open(portable_path, "open") def open_url(url: str) -> bool: @@ -89,7 +113,7 @@ def open_url(url: str) -> bool: return _windows_open(url) if getattr(PLATFORM, "is_linux", False): return _run(["xdg-open", url]) - return _run(["open", url]) + return _ashell_open(url, "open") def play_media(path: Path) -> bool: @@ -100,7 +124,9 @@ def play_media(path: Path) -> bool: return _windows_open(str(path.resolve())) if getattr(PLATFORM, "is_linux", False): return _run(["xdg-open", str(path.resolve())]) - return _run(["play", portable_path]) + if _ashell_open(portable_path, "play"): + return True + return _ashell_open(portable_path, "open") def notify_complete(path: Path) -> bool: diff --git a/flow/infrastructure/ytdlp_gateway.py b/flow/infrastructure/ytdlp_gateway.py index 28c49f7..e31ed19 100644 --- a/flow/infrastructure/ytdlp_gateway.py +++ b/flow/infrastructure/ytdlp_gateway.py @@ -1,6 +1,7 @@ from __future__ import annotations from pathlib import Path -from typing import Any, Callable +from typing import Any, Callable, Iterator +import random import time from urllib.parse import urlparse import yt_dlp @@ -54,9 +55,14 @@ def common_options(progress_hook: Callable[[dict[str, Any]], None]) -> dict[str, _TIKTOK_API_HOSTS = ( "api16-normal-c-useast1a.tiktokv.com", + "api19-normal-c-useast1a.tiktokv.com", "api22-normal-c-useast2a.tiktokv.com", + "api16-normal-c-useast2a.tiktokv.com", +) +_IPHONE_UA = ( + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) " + "AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1" ) -_TIKTOK_DEVICE_ID = "7379690547022071302" def _is_tiktok_url(url: str) -> bool: @@ -64,17 +70,40 @@ def _is_tiktok_url(url: str) -> bool: return hostname == "tiktok.com" or hostname.endswith(".tiktok.com") -def _tiktok_fallback_options(options: dict[str, Any], host: str) -> dict[str, Any]: +def _tiktok_device_id() -> str: + return str(random.randint(10**18, 10**19 - 1)) + + +def _with_tiktok_args( + options: dict[str, Any], + *, + host: str | None = None, + device_id: str | None = None, +) -> dict[str, Any]: fallback = dict(options) - fallback["extractor_args"] = { - "tiktok": { - "device_id": _TIKTOK_DEVICE_ID, - "api_hostname": host, - } - } + headers = dict(fallback.get("http_headers") or {}) + headers["User-Agent"] = _IPHONE_UA + fallback["http_headers"] = headers + tiktok: dict[str, Any] = {} + if host: + tiktok["api_hostname"] = host + if device_id: + tiktok["device_id"] = device_id + if tiktok: + extractor_args = dict(fallback.get("extractor_args") or {}) + extractor_args["tiktok"] = tiktok + fallback["extractor_args"] = extractor_args return fallback +def _tiktok_fallback_options(base: dict[str, Any]) -> Iterator[dict[str, Any]]: + """Rutas alternativas: API móvil en varios hosts y un device_id fresco.""" + yield _with_tiktok_args(base) + for host in _TIKTOK_API_HOSTS: + yield _with_tiktok_args(base, host=host) + yield _with_tiktok_args(base, host=host, device_id=_tiktok_device_id()) + + def _extract_info_with_fallback( url: str, options: dict[str, Any], @@ -88,9 +117,8 @@ def _extract_info_with_fallback( if not _is_tiktok_url(url): raise last_error: Exception = first_error - for host in _TIKTOK_API_HOSTS: + for fallback in _tiktok_fallback_options(options): try: - fallback = _tiktok_fallback_options(options, host) with yt_dlp.YoutubeDL(fallback) as ydl: return ydl.extract_info(url, download=download) except Exception as error: @@ -143,28 +171,71 @@ def playlist_urls(url: str) -> list[str]: return list(dict.fromkeys(urls)) +def _format_is_downloadable(fmt: dict[str, Any]) -> bool: + if fmt.get("has_drm") is True: + return False + protocol = str(fmt.get("protocol") or "") + if protocol in {"mhtml", "mhtml+https", "storyboard"}: + return False + vcodec = fmt.get("vcodec") + if vcodec in (None, "none", "images"): + return False + if fmt.get("url"): + return True + fragments = fmt.get("fragments") + return isinstance(fragments, list) and bool(fragments) + + +def _short_side(fmt: dict[str, Any]) -> int | None: + width = fmt.get("width") + height = fmt.get("height") + if isinstance(width, int) and width > 0 and isinstance(height, int) and height > 0: + return min(width, height) + if isinstance(height, int) and height > 0: + return height + if isinstance(width, int) and width > 0: + return width + resolution = fmt.get("resolution") + if isinstance(resolution, str) and "x" in resolution.casefold(): + parts = resolution.lower().replace("×", "x").split("x", 1) + try: + values = [int(part.strip()) for part in parts] + except ValueError: + return None + if len(values) == 2 and min(values) > 0: + return min(values) + return None + + def available_resolutions(info: dict[str, Any]) -> list[int]: + """Solo calidades de formatos descargables; no inventa 360/720/1080.""" values: set[int] = set() for fmt in info.get("formats") or []: - if not isinstance(fmt, dict): + if not isinstance(fmt, dict) or not _format_is_downloadable(fmt): continue - height = fmt.get("height") - width = fmt.get("width") - vcodec = fmt.get("vcodec") - protocol = fmt.get("protocol") - if ( - vcodec in (None, "none", "images") - or protocol == "mhtml" - or fmt.get("has_drm") is True - ): - continue - if isinstance(width, int) and width > 0 and isinstance(height, int) and height > 0: - values.add(min(width, height)) - elif isinstance(height, int) and height > 0: - values.add(height) + short = _short_side(fmt) + if short is not None: + values.add(short) return sorted(values, reverse=True) +def video_format_selector(height: int | None) -> str: + """Limita de verdad al lado corto pedido; no usa solo format_sort.""" + if height is None: + return "bestvideo*+bestaudio/best" + h = int(height) + return ( + f"bestvideo*[width={h}][height>={h}]+bestaudio/" + f"bestvideo*[height={h}][width>={h}]+bestaudio/" + f"best[width={h}]/" + f"best[height={h}]/" + f"bestvideo*[width<={h}]+bestaudio/" + f"bestvideo*[height<={h}]+bestaudio/" + f"best[width<={h}]/" + f"best[height<={h}]" + ) + + def estimate_size( info: dict[str, Any], height: int | None, @@ -284,15 +355,11 @@ def download( }) else: target_dir = video_dir - selector = "bestvideo*+bestaudio/best" options.update({ - "format": selector, + "format": video_format_selector(height), "outtmpl": str(target_dir / "%(title).120B [%(id)s].%(ext)s"), "merge_output_format": "mkv", }) - if height is not None: - # `res` usa la dimensión menor y funciona también con video vertical. - options["format_sort"] = [f"res:{height}"] target_dir.mkdir(parents=True, exist_ok=True) try: diff --git a/flow/presentation/cli.py b/flow/presentation/cli.py index 14b5e1d..878b874 100644 --- a/flow/presentation/cli.py +++ b/flow/presentation/cli.py @@ -436,6 +436,11 @@ def after_download(self, path: Path, kind: str) -> None: print(f"{GRAY}Archivo: {path.name}{RESET}") if PLATFORM.is_termux: print(f"{CYAN}Dónde encontrarlo: {android_location}{RESET}") + elif PLATFORM.is_ashell: + folder = path.parent.name + print( + f"{CYAN}Dónde encontrarlo: Archivos › a-Shell › FlowMobile › Downloads › {folder}{RESET}" + ) else: print(f"{CYAN}Ubicación: {path.parent}{RESET}") print(f"{MAGENTA}{BOLD}SIGUIENTE ACCIÓN{RESET}") @@ -456,6 +461,15 @@ def after_download(self, path: Path, kind: str) -> None: if PLATFORM.is_termux: print(f"{YELLOW}Alternativa manual:{RESET}") print(f"{GRAY}Abre Archivos › {android_location}, mantén pulsado el archivo y toca Compartir.{RESET}") + elif PLATFORM.is_ashell: + print(f"{YELLOW}Alternativa manual:{RESET}") + print( + f"{GRAY}Abre Archivos › a-Shell › FlowMobile › Downloads, " + "mantén pulsado el archivo y toca Compartir.{RESET}" + ) + print( + f"{GRAY}Desde esa hoja puedes Guardar vídeo en Fotos o enviarlo.{RESET}" + ) else: message = "Ubicación abierta." if getattr(PLATFORM, "is_desktop", False) else f"Archivo enviado a la vista de {PLATFORM.mobile_os}." print(f"{GREEN}{message}{RESET}") diff --git a/tests/test_device.py b/tests/test_device.py index 411a917..329c447 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -56,12 +56,30 @@ def test_termux_share_falls_back_to_optional_api_command(self): def test_ashell_share_uses_open(self): completed = SimpleNamespace(returncode=0) - platform = SimpleNamespace(is_termux=False) + platform = SimpleNamespace(is_termux=False, is_windows=False, is_linux=False) with patch.object(device, "PLATFORM", platform): - with patch.object(device.subprocess, "run", return_value=completed) as run: - self.assertTrue(device.open_share(Path("/tmp/video.mp4"))) + with patch.object(device, "_ashell_run", return_value=False): + with patch.object(device.subprocess, "run", return_value=completed) as run: + self.assertTrue(device.open_share(Path("/tmp/video.mp4"))) self.assertEqual(run.call_args.args[0], ["open", "/tmp/video.mp4"]) + def test_ashell_share_prefers_ios_system(self): + platform = SimpleNamespace(is_termux=False, is_windows=False, is_linux=False) + with patch.object(device, "PLATFORM", platform): + with patch.object(device, "_ashell_run", return_value=True) as run: + with patch.object(device, "_run") as fallback: + self.assertTrue(device.open_share(Path("/tmp/clip video.mp4"))) + self.assertTrue(run.call_args.args[0].startswith("open ")) + self.assertIn("clip video.mp4", run.call_args.args[0]) + fallback.assert_not_called() + + def test_ashell_play_uses_play_command(self): + platform = SimpleNamespace(is_termux=False, is_windows=False, is_linux=False) + with patch.object(device, "PLATFORM", platform): + with patch.object(device, "_ashell_run", return_value=True) as run: + self.assertTrue(device.play_media(Path("/tmp/audio.m4a"))) + self.assertTrue(run.call_args.args[0].startswith("play ")) + def test_ashell_opens_feedback_in_browser(self): completed = SimpleNamespace(returncode=0) platform = SimpleNamespace(is_termux=False) diff --git a/tests/test_quality.py b/tests/test_quality.py index 2aebd4b..8f5459d 100644 --- a/tests/test_quality.py +++ b/tests/test_quality.py @@ -5,14 +5,35 @@ from flow.infrastructure.ffmpeg import probe_media from flow.infrastructure.ytdlp_gateway import ( + _TIKTOK_API_HOSTS, + _tiktok_fallback_options, available_resolutions, common_options, estimate_size, retry_delay, + video_format_selector, ) class QualityDetectionTests(unittest.TestCase): + def test_tiktok_fallback_covers_multiple_hosts_without_fixed_device(self): + attempts = list(_tiktok_fallback_options({})) + hosts = [ + attempt["extractor_args"]["tiktok"]["api_hostname"] + for attempt in attempts + if "extractor_args" in attempt + ] + self.assertGreaterEqual(len(attempts), 1 + len(_TIKTOK_API_HOSTS)) + for host in _TIKTOK_API_HOSTS: + self.assertIn(host, hosts) + device_ids = [ + attempt["extractor_args"]["tiktok"]["device_id"] + for attempt in attempts + if "device_id" in attempt.get("extractor_args", {}).get("tiktok", {}) + ] + self.assertTrue(device_ids) + self.assertNotIn("7379690547022071302", device_ids) + def test_download_options_back_off_between_retries(self): options = common_options(lambda _: None) self.assertEqual(options["sleep_interval_requests"], 0.75) @@ -23,9 +44,9 @@ def test_download_options_back_off_between_retries(self): def test_horizontal_and_vertical_video_use_short_dimension(self): info = { "formats": [ - {"width": 1920, "height": 1080, "vcodec": "h264", "protocol": "https"}, - {"width": 1080, "height": 1920, "vcodec": "h264", "protocol": "https"}, - {"width": 720, "height": 1280, "vcodec": "h264", "protocol": "https"}, + {"width": 1920, "height": 1080, "vcodec": "h264", "protocol": "https", "url": "https://cdn/a"}, + {"width": 1080, "height": 1920, "vcodec": "h264", "protocol": "https", "url": "https://cdn/b"}, + {"width": 720, "height": 1280, "vcodec": "h264", "protocol": "https", "url": "https://cdn/c"}, ] } self.assertEqual(available_resolutions(info), [1080, 720]) @@ -33,8 +54,8 @@ def test_horizontal_and_vertical_video_use_short_dimension(self): def test_storyboards_are_not_presented_as_video_quality(self): info = { "formats": [ - {"width": 160, "height": 90, "vcodec": "images", "protocol": "mhtml"}, - {"width": 1280, "height": 720, "vcodec": "h264", "protocol": "https"}, + {"width": 160, "height": 90, "vcodec": "images", "protocol": "mhtml", "url": "https://cdn/sb"}, + {"width": 1280, "height": 720, "vcodec": "h264", "protocol": "https", "url": "https://cdn/v"}, ] } self.assertEqual(available_resolutions(info), [720]) @@ -44,13 +65,30 @@ def test_drm_formats_are_not_presented_as_downloadable(self): "formats": [ { "width": 3840, "height": 2160, "vcodec": "h264", - "protocol": "https", "has_drm": True, + "protocol": "https", "has_drm": True, "url": "https://cdn/drm", }, - {"width": 1920, "height": 1080, "vcodec": "h264", "protocol": "https"}, + {"width": 1920, "height": 1080, "vcodec": "h264", "protocol": "https", "url": "https://cdn/ok"}, ] } self.assertEqual(available_resolutions(info), [1080]) + def test_formats_without_url_are_not_invented_as_qualities(self): + info = { + "formats": [ + {"width": 1920, "height": 1080, "vcodec": "h264", "protocol": "https"}, + {"width": 640, "height": 360, "vcodec": "h264", "protocol": "https", "url": "https://cdn/360"}, + ] + } + self.assertEqual(available_resolutions(info), [360]) + + def test_video_selector_caps_requested_height(self): + selector = video_format_selector(720) + self.assertIn("width=720", selector) + self.assertIn("height=720", selector) + self.assertIn("width<=720", selector) + self.assertNotIn("/bestvideo*+bestaudio/best", selector) + self.assertEqual(video_format_selector(None), "bestvideo*+bestaudio/best") + def test_estimate_respects_vertical_resolution_limit(self): info = { "formats": [ From b39cec6aff8deae7db7c57c711453449076b6bdf Mon Sep 17 00:00:00 2001 From: tacosandtypescript-debug Date: Mon, 31 Aug 2026 05:26:41 -0400 Subject: [PATCH 2/2] Ajustar listado HLS y reintentos de TikTok - HLS/DASH con manifest_url cuentan como calidad real. - Un intento por host de API para no bloquear el iPhone. - La prueba de abrir URLs en a-Shell no depende de ios_system. --- SECURITY_MANIFEST.sha256 | 2 +- flow/infrastructure/ytdlp_gateway.py | 5 ++--- tests/test_device.py | 7 ++++--- tests/test_quality.py | 11 +++++++++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/SECURITY_MANIFEST.sha256 b/SECURITY_MANIFEST.sha256 index 847cd3b..2e4178a 100644 --- a/SECURITY_MANIFEST.sha256 +++ b/SECURITY_MANIFEST.sha256 @@ -30,7 +30,7 @@ f1e7e3132df532659ce39eaecfdc13e783f9ad529ec97144f564e1c8b4f317c3 flow/infrastru b2d5a084f1276bac16c87769a32c6a7165816ed006e16b9f2e3f4621b6a5276b flow/infrastructure/settings.py 12052b1c424e8ef935d6cc89b54baa55f21603cb29ba7123f7082afbd5ffb1e6 flow/infrastructure/uninstall.py 046f27d2016ac365f452f8df8ec92f72763b7067fc4c6e02faa5c3e10b9aec03 flow/infrastructure/updates.py -5748e1b999b21be6e99096e0693097ce57f388e91d336cb32369c6b8c11f884b flow/infrastructure/ytdlp_gateway.py +ea8f8d1b3c14ede097b7707eeed6558349579f4a7f660a0e6286685c89552a8a flow/infrastructure/ytdlp_gateway.py e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 flow/presentation/__init__.py 07bc29868f175123953c215b8d8dc8fb459278dfb5fa2bb58e7143a554be66e0 flow/presentation/cli.py 37969356b90b0cacae43cb7a171ecb00468eb9b213535d073aea73e52834aa77 flow/presentation/theme.py diff --git a/flow/infrastructure/ytdlp_gateway.py b/flow/infrastructure/ytdlp_gateway.py index e31ed19..dd18869 100644 --- a/flow/infrastructure/ytdlp_gateway.py +++ b/flow/infrastructure/ytdlp_gateway.py @@ -97,10 +97,9 @@ def _with_tiktok_args( def _tiktok_fallback_options(base: dict[str, Any]) -> Iterator[dict[str, Any]]: - """Rutas alternativas: API móvil en varios hosts y un device_id fresco.""" + """UA de iPhone y un intento por host de API con device_id fresco.""" yield _with_tiktok_args(base) for host in _TIKTOK_API_HOSTS: - yield _with_tiktok_args(base, host=host) yield _with_tiktok_args(base, host=host, device_id=_tiktok_device_id()) @@ -180,7 +179,7 @@ def _format_is_downloadable(fmt: dict[str, Any]) -> bool: vcodec = fmt.get("vcodec") if vcodec in (None, "none", "images"): return False - if fmt.get("url"): + if fmt.get("url") or fmt.get("manifest_url"): return True fragments = fmt.get("fragments") return isinstance(fragments, list) and bool(fragments) diff --git a/tests/test_device.py b/tests/test_device.py index 329c447..6861735 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -82,10 +82,11 @@ def test_ashell_play_uses_play_command(self): def test_ashell_opens_feedback_in_browser(self): completed = SimpleNamespace(returncode=0) - platform = SimpleNamespace(is_termux=False) + platform = SimpleNamespace(is_termux=False, is_windows=False, is_linux=False) with patch.object(device, "PLATFORM", platform): - with patch.object(device.subprocess, "run", return_value=completed) as run: - self.assertTrue(device.open_url("https://github.com/example/issues/new")) + with patch.object(device, "_ashell_run", return_value=False): + with patch.object(device.subprocess, "run", return_value=completed) as run: + self.assertTrue(device.open_url("https://github.com/example/issues/new")) self.assertEqual( run.call_args.args[0], ["open", "https://github.com/example/issues/new"], diff --git a/tests/test_quality.py b/tests/test_quality.py index 8f5459d..b817731 100644 --- a/tests/test_quality.py +++ b/tests/test_quality.py @@ -81,6 +81,17 @@ def test_formats_without_url_are_not_invented_as_qualities(self): } self.assertEqual(available_resolutions(info), [360]) + def test_hls_manifest_is_treated_as_downloadable(self): + info = { + "formats": [ + { + "width": 1280, "height": 720, "vcodec": "h264", + "protocol": "m3u8_native", "manifest_url": "https://cdn/720.m3u8", + }, + ] + } + self.assertEqual(available_resolutions(info), [720]) + def test_video_selector_caps_requested_height(self): selector = video_format_selector(720) self.assertIn("width=720", selector)