Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions SECURITY_MANIFEST.sha256
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
ea8f8d1b3c14ede097b7707eeed6558349579f4a7f660a0e6286685c89552a8a 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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.6
8.0.7
5 changes: 4 additions & 1 deletion docs/GUIA_COMPLETA.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion flow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
APP_NAME = "FlowMobile"
APP_VERSION = "8.0.6"
APP_VERSION = "8.0.7"
32 changes: 29 additions & 3 deletions flow/infrastructure/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import mimetypes
import os
from pathlib import Path
import shlex
import shutil
import subprocess
from urllib.parse import urlparse
Expand All @@ -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]
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
128 changes: 97 additions & 31 deletions flow/infrastructure/ytdlp_gateway.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -54,27 +55,54 @@ 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:
hostname = (urlparse(url).hostname or "").casefold()
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]]:
"""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, device_id=_tiktok_device_id())


def _extract_info_with_fallback(
url: str,
options: dict[str, Any],
Expand All @@ -88,9 +116,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:
Expand Down Expand Up @@ -143,28 +170,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") or fmt.get("manifest_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/"
Comment on lines +227 to +228

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid offering formats the selector cannot match

When a downloadable format supplies only resolution (for example, 1280x720) and omits width and height, _short_side now advertises 720p in the menu, but every selector alternative here filters on one of those absent fields. yt-dlp treats unknown filtered fields as nonmatches, so choosing the advertised quality ends with “requested format not available”; either exclude such formats from the menu or add a selector path that can match their metadata safely.

Useful? React with 👍 / 👎.

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,
Expand Down Expand Up @@ -284,15 +354,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:
Expand Down
14 changes: 14 additions & 0 deletions flow/presentation/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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}")
Expand Down
Loading