* strm *strm* is a small Bash script that lets you stream media files over SSH in a convenient way. No need for mounting and navigating through complex directory structures anymore. Just provide a query and the matching media files are played locally via [[https://mpv.io/][mpv]]. Here is an example.. let's assume you have the shortfilm [[https://www.dailydweebs.com/][The Daily Dweebs]] stored on a remote machine in the following directory structure: #+begin_src text media └── movies ├── ... ├── The Daily Dweebs (2017) │   └── The Daily Dweebs (2017).mkv └── ... #+end_src If strm is configured to use the =media= directory, you can play the shortfilm e.g. with the following command: #+begin_src sh strm daily dweebs #+end_src Every argument which is not assigned to a flag is interpreted as part of the query. The query arguments are interpreted as [[https://en.wikipedia.org/wiki/Glob_(programming)][glob patterns]], additionally surrounded by wildcards (=*=). If every pattern matches any filepath in the configured media directories, the matched filepaths are interpreted as result. The =--or= flag can be set to get results which match at least one pattern. Matchings are always done case-insensitive. The shortfilm from the example above could have also been played with one of the following commands: #+begin_src sh strm dweebs daily strm movies dwee strm d d 17 #+end_src It is possible that multiple files are matched by one of the commands. All files are then played in the order of the configured media directories, followed by lexicographical order of the filepath. strm consists mainly of two parts: 1. Execute =find= via SSH on a machine 2. Play the matched files with =mpv= over SFTP The rest is just bells and whistles. ** Features - List remote files by query - Play remote files via mpv - Query multiple remote directories with one command - Play remote files on other machines (need to have *strm* installed) You can access your local machine also via SSH, so every occurrence of /remote/ in the list can be replaced with /local/. mpv has a nice feature which lets you resume playback. This is handy if you want to e.g. continue watching you favourite series at a later point in time. Check the *usage* below to see how this works. ** Installation Make sure, mpv is installed and that you have access to a machine via SSH. strm is just a script, you can execute it directly. Or grab it and place it in your =$PATH=. This project is also a [[https://nixos.wiki/wiki/Flakes][Nix flake]]. You can execute it with the following command if you have a recent version of [[https://nixos.org/][Nix]] installed and flakes are enabled: #+begin_src sh nix run github:Deleh/strm -- --help #+end_src If you use it this way, mpv is started with *MPRIS* support by default. ** Usage #+begin_src text Usage: strm [OPTIONS] QUERIES ... [OPTIONS] Stream media files over SSH in a convenient way. OPTIONS -h, --help Show this help message -c, --config CONFIG_FILE Path to config file (default: ~/.config/strm/strm.config) -f, --fullscreen Play video files in fullscreen -l, --list List files instead of playing -m, --media-directories MEDIA_DIRECTORIES Use given media directories, config is ignored -o, --or Use a logical OR for queries (default: AND) -r, --remote SSH_CONNECTION_STRING Execute strm with other given arguments on remote machine (-f is set by default) -s, --shuffle Play files in random order EXAMPLES strm -l . # List all available files strm Elephants Dream # Play files whose path contain 'elephants' and 'dream' strm e*phants # Play files whose path matches the glob pattern 'e*phants' #+end_src The usual [[https://mpv.io/manual/master/#interactive-control][mpv controls]] are available while playback. Here is a subset: - =LEFT= and =RIGHT= :: Seek backward/forward. - =p= and =SPACE= :: Pause (pressing again unpauses). - =<= and =>= :: Go backward/forward in the playlist. - =f= :: Toggle fullscreen. - =q= :: Stop playing and quit. - =Q= :: Like =q=, but store the current playback position. Playing the same file later will resume at the old playback position if possible. This works for single and mutliple files. To listen e.g. to an audiobook in multiple stages you can always use the same command (=strm audiobook=). Just make sure you always quit with =Q=. To clear all stored positions remove the directory (=~/.config/mpv/watch_later=). *** The =--remote== flag The =--remote= flag executes *strm* on another machine and passes all other arguments to it. For this, *strm* needs to be installed and configured on the remote machine. If you pass the =--media-directories= flag it doesn't need to be configured but make sure your arguments are correct from the point of view of the remote machine. The =--fullscreen= is inverted when playing on a remote machine. It is set by default and not set if you explicitly pass it. The remote =$DISPLAY= variable is set to =:0= by default which should fit most setups. If you wish to change this you have to adjust the script in line 131. ** Configuration If the =--media-directories= argument is not set, the script looks for a configuration file with the following content: #+begin_src sh # Media directories on remote machines of the following form: # # # # Multiple media directories can be set with a comma (,) as delimiter. # Spaces must be escaped with a backslash (\). # Media directories are queried and played in order. # # Examples: # localhost/home/bob/videos # remote-machine/home/bob/music # bob@another-machine/media/movies,bob@10.0.0.1/home/bob/series media_directories="" #+end_src An example configuration file can be found in the repository. The default path of the configuration is =$HOME/.config/strm/strm.config=. You can use the =--config= flag to set another configuration file. The flag =--media-directories= is used in favour of a configuration file and can be used with the same syntax as described above.