Compare commits

..

No commits in common. "413701bf138faef6d37cf21dff1f18b967b4b3b1" and "4bd4a018fd3f7c8d8b494b6d418fee2302ef37ca" have entirely different histories.

4 changed files with 27 additions and 57 deletions

View file

@ -18,7 +18,7 @@
If *strm* is configured to use the =media= directory, you can play the shortfilm e.g. with the following command: If *strm* is configured to use the =media= directory, you can play the shortfilm e.g. with the following command:
: $ strm daily dweebs : strm daily dweebs
Every argument which is not assigned to an flag is interpreted as part of the query. Every argument which is not assigned to an 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 (=*=). The query arguments are interpreted as [[https://en.wikipedia.org/wiki/Glob_(programming)][glob patterns]], additionally surrounded by wildcards (=*=).
@ -28,9 +28,9 @@
The shortfilm from the example above could have also been played with one of the following commands: The shortfilm from the example above could have also been played with one of the following commands:
: $ strm dweebs daily : strm dweebs daily
: $ strm movies dwee : strm movies dwee
: $ strm d d 17 : strm d d 17
It is possible that multiple files are matched by one of the commands. 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. All files are then played in the order of the configured media directories, followed by lexicographical order of the filepath.
@ -74,7 +74,7 @@
This project is also a [[https://nixos.wiki/wiki/Flakes][Nix flake]]. 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: You can execute it with the following command if you have a recent version of [[https://nixos.org/][Nix]] installed and flakes are enabled:
: $ nix run github:Deleh/strm -- --help : nix run github:Deleh/strm -- --help
If you use it this way, mpv is started with *MPRIS* support by default. If you use it this way, mpv is started with *MPRIS* support by default.

41
flake.lock generated
View file

@ -1,15 +1,12 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1694529238, "lastModified": 1631561581,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,18 +17,15 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1700794826, "lastModified": 1634115022,
"narHash": "sha256-RyJTnTNKhO0yqRpDISk03I/4A67/dp96YRxc86YOPgU=", "narHash": "sha256-K9DZMQ47VRrg9gtTPwex5p0E8LnwM/dDkNe7AQW0qj0=",
"owner": "nixos", "path": "/nix/store/fjn0mcw4wcm7lkcn92bzq11f0mzv3xqv-source",
"repo": "nixpkgs", "rev": "564cb4d81d4f734dd068684adec5a60077397fe9",
"rev": "5a09cb4b393d58f9ed0d9ca1555016a8543c2ac8", "type": "path"
"type": "github"
}, },
"original": { "original": {
"owner": "nixos", "id": "nixpkgs",
"ref": "nixos-unstable", "type": "indirect"
"repo": "nixpkgs",
"type": "github"
} }
}, },
"root": { "root": {
@ -39,21 +33,6 @@
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -3,10 +3,7 @@
nixConfig.bash-prompt = "\[\\e[1mstrm-dev\\e[0m:\\w\]$ "; nixConfig.bash-prompt = "\[\\e[1mstrm-dev\\e[0m:\\w\]$ ";
inputs = { inputs.flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = github:nixos/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
@ -16,7 +13,7 @@
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
# Use mpv with scripts # Use mpv with scripts
mpv = (pkgs.mpv.override { mpv = (pkgs.mpv-with-scripts.override {
scripts = [ scripts = [
pkgs.mpvScripts.mpris pkgs.mpvScripts.mpris
]; ];

24
strm
View file

@ -154,7 +154,7 @@ while (( "$#" )); do
remote_arguments+=("$1") remote_arguments+=("$1")
shift shift
;; ;;
-*) -*|--*=)
error "Unsupported flag: $1" error "Unsupported flag: $1"
;; ;;
*) *)
@ -190,7 +190,7 @@ if [ "$remote" != "" ]; then
remote_arguments+=("--is-remote-call") remote_arguments+=("--is-remote-call")
# Execute strm on remote machine # Execute strm on remote machine
ssh -o ConnectTimeout=10 -t "$remote" "DISPLAY=:0 tmux new-session -s strm 'tmux set-option status off; strm ${remote_arguments[*]}' &>/dev/null" ssh -o ConnectTimeout=10 -t "$remote" "DISPLAY=:0 tmux new-session -s strm 'tmux set-option status off; strm ${remote_arguments[@]}' &>/dev/null"
fi fi
exit exit
fi fi
@ -253,7 +253,7 @@ if [ "$list" == false ] && [ "$playback_directory" != "" ]; then
# Add leading and trailing slash to directory if missing # Add leading and trailing slash to directory if missing
[[ "$directory" != /*/ ]] && directory="/$directory/" [[ "$directory" != /*/ ]] && directory="/$directory/"
echo -ne "Synchronizing playback directory with $text_bold$(basename "$connection_string")$text_reset\n" echo -ne "Synchronizing playback directory with $text_bold$(basename $connection_string)$text_reset\n"
# Make remote directory if not existent # Make remote directory if not existent
ssh -o ConnectTimeout=10 "$connection_string" "mkdir -p $directory" ssh -o ConnectTimeout=10 "$connection_string" "mkdir -p $directory"
@ -272,10 +272,10 @@ if [ "${#queries[@]}" == 0 ]; then
fi fi
# Read media directories # Read media directories
IFS="," read -ar media_directories <<< "$media_directories" IFS="," read -a media_directories <<< "$media_directories"
# Read ignore files # Read ignore files
IFS="," read -ar ignore_files <<< "$ignore_files" IFS="," read -a ignore_files <<< "$ignore_files"
# Construct find argument array # Construct find argument array
@ -337,7 +337,7 @@ for media_directory in "${media_directories[@]}"; do
# Add leading and trailing slash to directory if missing # Add leading and trailing slash to directory if missing
[[ "$directory" != /*/ ]] && directory="/$directory/" [[ "$directory" != /*/ ]] && directory="/$directory/"
echo -ne "Fetching results from $text_bold$(basename "$directory")$text_reset on $text_bold$connection_string$text_reset\n" echo -ne "Fetching results from $text_bold$(basename $directory)$text_reset on $text_bold$connection_string$text_reset\n"
# Get search results from remote # Get search results from remote
# Look for paths matching given queries in visible directories, listing only filenames and links # Look for paths matching given queries in visible directories, listing only filenames and links
@ -359,7 +359,7 @@ echo
if [ "${#sftp_results[@]}" == 0 ]; then if [ "${#sftp_results[@]}" == 0 ]; then
if [ "$is_remote_call" == true ]; then if [ "$is_remote_call" == true ]; then
echo "No files found, press something to quit" echo "No files found, press something to quit"
read -nr 1 read -n 1
else else
echo "No files found" echo "No files found"
fi fi
@ -389,7 +389,7 @@ if [ "$list" == false ]; then
# Save arguments for later call # Save arguments for later call
if [ "$playback_directory" != "" ]; then if [ "$playback_directory" != "" ]; then
echo "queries=(${queries[*]})" > "$HOME/.cache/strm/strm_later" echo "queries=(${queries[@]})" > "$HOME/.cache/strm/strm_later"
echo "or=$or" >> "$HOME/.cache/strm/strm_later" echo "or=$or" >> "$HOME/.cache/strm/strm_later"
echo "shuffle=$shuffle" >> "$HOME/.cache/strm/strm_later" echo "shuffle=$shuffle" >> "$HOME/.cache/strm/strm_later"
fi fi
@ -414,12 +414,6 @@ if [ "$list" == false ]; then
fi fi
if [ "$playback_directory" != "" ]; then if [ "$playback_directory" != "" ]; then
mpv_arguments+=("--save-position-on-quit") mpv_arguments+=("--save-position-on-quit")
# Save only the playback position if mpv version is at least 0.34.0
[[ $(mpv --version | head -n 1) =~ [0-9]+.([0-9]+).[0-9]+ ]]
if [ "${BASH_REMATCH[1]}" -ge 34 ]; then
mpv_arguments+=("--watch-later-options-clr")
fi
fi fi
# Play all remote files # Play all remote files
@ -447,7 +441,7 @@ if [ "$list" == false ]; then
# Add leading and trailing slash to directory if missing # Add leading and trailing slash to directory if missing
[[ "$directory" != /*/ ]] && directory="/$directory/" [[ "$directory" != /*/ ]] && directory="/$directory/"
echo -ne "\nSynchronizing playback directory with $text_bold$(basename "$connection_string")$text_reset" echo -ne "\nSynchronizing playback directory with $text_bold$(basename $connection_string)$text_reset"
# Synchronize local to remote # Synchronize local to remote
rsync -az --delete "$HOME/.cache/strm/" "$connection_string:$directory" rsync -az --delete "$HOME/.cache/strm/" "$connection_string:$directory"