Describe the bug
Downloading videos with Persian (Farsi) titles fails with a FileNotFoundError in Python's tempfile.mkstemp() when using the wget module.
Consider download this file by apyrat
https://www.aparat.com/v/u75537l?playlist=289610
To Reproduce
- Install latest version:
- Run:
apyrat https://www.aparat.com/v/u75537l?playlist=289610
- Choose quality (e.g. 720p)
Expected behavior
The video should download successfully with the correct Persian filename.
Actual behavior
لینوکس از کیلومتر صفر (ویدیوی دوم: انتخاب توزیع گنو/لینوکس)
https://as9.cdn.asset.aparat.com/...
Traceback (most recent call last):
...
File "/.../wget.py", line 506, in download
(fd, tmpfile) = tempfile.mkstemp(".tmp", prefix=prefix, dir=".")
...
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/apyrat/entekhab/لینوکس از کیلومتر صفر (ویدیوی دوم: انتخاب توزیع گنو/لینوکس).mp4xcjpfmtx.tmp'
Environment
- OS: Debian 13 (also likely affects other Linux distributions)
- Python: 3.11
- apyrat version: latest (as of June 2026)
- Shell: bash
- Locale: UTF-8 (Persian)
Additional context
- The bug occurs because
wget.download() creates a temporary file using the full output filename (which contains Persian characters) as a prefix in tempfile.mkstemp().
- The combination of Persian directory + Persian filename breaks the temporary file creation on some systems.
yt-dlp downloads the same video without any issues.
Suggested fix by AI
In src/apyrat.py (around line 158):
- Sanitize the filename (remove/replace invalid characters for the filesystem).
- Use a safe ASCII temporary filename.
- Consider replacing the
wget module with requests + proper streaming, or use tempfile.mkstemp(dir="/tmp") explicitly.
Describe the bug
Downloading videos with Persian (Farsi) titles fails with a
FileNotFoundErrorin Python'stempfile.mkstemp()when using thewgetmodule.Consider download this file by apyrat
https://www.aparat.com/v/u75537l?playlist=289610
To Reproduce
apyrat https://www.aparat.com/v/u75537l?playlist=289610Expected behavior
The video should download successfully with the correct Persian filename.
Actual behavior
Environment
Additional context
wget.download()creates a temporary file using the full output filename (which contains Persian characters) as a prefix intempfile.mkstemp().yt-dlpdownloads the same video without any issues.Suggested fix by AI
In
src/apyrat.py(around line 158):wgetmodule withrequests+ proper streaming, or usetempfile.mkstemp(dir="/tmp")explicitly.