Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glubsy/mpv-limited-autoload
Lazily load files from directories into mpv
https://github.com/glubsy/mpv-limited-autoload
convenience mpv playlist
Last synced: 3 months ago
JSON representation
Lazily load files from directories into mpv
- Host: GitHub
- URL: https://github.com/glubsy/mpv-limited-autoload
- Owner: glubsy
- License: gpl-3.0
- Created: 2021-05-09T23:36:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-26T17:42:58.000Z (about 3 years ago)
- Last Synced: 2024-06-30T11:30:24.976Z (5 months ago)
- Topics: convenience, mpv, playlist
- Language: C
- Homepage:
- Size: 85.9 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mpv - limited-autoload - Auto-load files in a lazy way by limiting how many are loaded into playlist at once (File)
README
# Rationale
This script incrementally loads files from directories passed as positional arguments to MPV.
Key bindings are available to load more files from storage at the user's request.This script might solve two issues:
1. By default, MPV loads files from a directory found in its playlist only as it stumbles upon it. This leads to issues when loading multiple directories in MPV, only the first one will be loaded, the other directories will be lost in the vast amount of files loaded by MPV from the first directory. Thus, their chance of being found is unfortunately greatly reduced.
2. Very large amounts of files are loaded into MPV's internal playlist, which may or may not be required by the user. Perhaps the user only wants a peek at what is inside the directory, perhaps the user wants a random selection of files. This script reduces the amount of files fetched from storage, akin to a "lazy load".
## Known issue
This plugin currently does not work with mounted FUSE file systems, most notably SSHFS. The entire SSHFS will crash, need more investigation and testing.
# Installation
## Build
```
make
```Then copy `limited_autoload.so` into `${XDG_CONFIG_HOME}/mpv/scripts/` (or invoke the script with `mpv --scripts=/path/to/script`).
A prebuilt GNU/Linux binary is available for convenience in the release page (built on Arch Linux, may or may not work in other distributions).
## Configuration
1. Configure the default amount of files fetched from storage with a file in `${XDG_CONFIG_HOME}/mpv/script-opts/limited_autoload.conf` with the following content:
```
limit=100
recurse=1
exclude=blend,rar,zip,tar,7z
enabled=1
````
* Initially load at most `limit` number of files from any directory found in the initial playlist, ie. the list of pathnames passed to MPV as positional arguments.
* If `recurse=0`, files from any sub-directory encountered will not be loaded.
* Files with a filename extension present in the `exclude` list will be skipped (case insensitive).
* The script can be explicitly disabled with `enabled=0` (mostly useful as a CLI argument).You can also override these values from the command line:
```
mpv --script-opts=limited_autoload-limit=800,limited_autoload-recurse=0,limited_autoload-exclude=blend:rar:zip:7z
```
Notice the delimiter is different for `exclude` on the command line. The values override those in the .conf file.2. Add the following key bindings to `input.conf`, usually in `${XDG_CONFIG_HOME}/mpv/input.conf`:
```
f script-message limited_autoload append 200
F script-message limited_autoload replace 200
```
Change to whatever key you prefer.
"append" and "replace" are explained below.
The number represents the amount of files to fetch every time the key is pressed.# Usage:
* "append" method: this will append files found in each sub-directory as they are returned by the operating system, similar to how MPV usually does on its own, except the files are NOT sorted in any way. When all files have been loaded, no more files will be appended. This is the "default" method.
* "replace" method: this will replace the current playlist with the next batch of files returned by the operating system each time the key is pressed. It acts as a dynamic "view" over the file system tree.
The `mpv_wrapper.sh` script is just a convenience shell script not directly related to this here script, but perhaps it might be useful to somebody.
# License
GPLv3
# Compatibility
This was written for GNU/Linux, but it could easily be ported to other Operating Systems by tweaking a few function calls and including the proper header files. I probably won't bother doing that myself.