scdl-org / scdl

Soundcloud Music Downloader
GNU General Public License v2.0
3.29k stars 331 forks source link

Android/Termux doesn't have flock, see yt-dlp solution #496

Closed Leif-W closed 3 weeks ago

Leif-W commented 2 months ago

TL;DR filelock dependency issue?

Same issue as listed on yt-dlp.

Android/Termux doesn't have flock. Fallback to lockf. Possibly fallback to no lock.

scdl -l https://soundcloud.com/user/track
Soundcloud Downloader
Found a track
Downloading track
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/filelock/_unix.py", line 46, in _acquire
    fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
OSError: [Errno 38] Function not implemented

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/scdl", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/scdl/scdl.py", line 304, in main
    download_url(client, **python_args)
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/scdl/scdl.py", line 409, in download_url
    download_track(client, item, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/scdl/scdl.py", line 887, in download_track
    with lock:
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/filelock/_api.py", line 376, in __enter__
    self.acquire()
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/filelock/_api.py", line 332, in acquire
    self._acquire()
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/filelock/_unix.py", line 51, in _acquire
    raise NotImplementedError(msg) from exception
NotImplementedError: FileSystem does not appear to support flock; use SoftFileLock instead
Leif-W commented 2 months ago

Redirecting to filelock dependency.

Leif-W commented 3 weeks ago

Actually, regardless of the filelock dependency, this problem exists, and should be addressed. Test if the system can create a file lock, catch the exception, if exception, try a soft file lock, if soft file lock fails, just don't lock. This should not be causing an error. If the filelock lib fixes this, update dependency requirement and remove code.

7x11x13 commented 3 weeks ago

Possibly fixed in v2.12.1, can you see if it works on your system?

Leif-W commented 3 weeks ago

Works for me now. Much appreciated workaround. Can leave open for a bit if anyone else wants to verify.