diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f4b4156e..058448c9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -15,5 +15,7 @@ Steps to reproduce the behavior: 1. Run command '...' 2. See error +(Ensure that the issue can be reproduced on a clean install, and that there are no missing deps/reqs using `mpvc-installer check-reqs`) + **Expected behavior** A clear and concise description of what you expected to happen. diff --git a/README.md b/README.md index b38cd32d..945e0fce 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,6 @@ Recommended extras: - `notify-send` - `yt-dlp` -Check for missing dependencies using `mpvc-installer check-reqs`. - ## Installation - [Manual](#manual) @@ -76,14 +74,15 @@ Check for missing dependencies using `mpvc-installer check-reqs`. - [Gentoo](#gentoo-mpvc) - [Nix](#nix-mpvc) -Installing is just a matter of fetching the scripts either via [Git](#git)/Curl/etc., scripts can be used directly from the repo, the `mpvc-installer` bit is just there for easiness, to fetch & link them into your `BINDIR=~/bin/` that [mpvc-installer](../../blob/master/extras/mpvc-installer) does by default. +Installing is just a matter of fetching the scripts either via [Git](#git)/Curl/etc., scripts can be used directly from the repo, the `mpvc-installer` bit is just there for easiness, to fetch & link them into your `BINDIR=~/bin/` that [mpvc-installer](../../blob/master/extras/mpvc-installer) does by default. -The easiest for a onetime [Manual](#manual) install, however for @latest version a [Git](#git) install is recommended. +The easiest for a onetime install is the [Manual](#manual), however for @latest version a [Git](#git) install is recommended. +Check for missing dependencies/requirements using `mpvc-installer check-reqs`. ### Manual ```console -curl -fsSL -O https://github.com/lwilletts/mpvc/raw/master/extras/mpvc-installer \ +curl -LO https://github.com/lwilletts/mpvc/raw/master/extras/mpvc-installer \ && BINDIR=$HOME/bin sh ./mpvc-installer fetch-user ``` @@ -99,8 +98,6 @@ This does git clone, and symlinks the mpvc scripts to `BINDIR` (default `~/bin`) (cd mpvc; extras/mpvc-installer link-user) (cd mpvc; extras/mpvc-installer check-reqs) - # use mpvc-fzf to search and play youtube media - mpvc-fzf -p 'kupla mirage' # use mpvc to add/load/save media files or online YT URLs mpvc add /path/to/your/*.mp3 # or your URLs find . -type f -name | mpvc load @@ -111,6 +108,12 @@ This does git clone, and symlinks the mpvc scripts to `BINDIR` (default `~/bin`) mpvc stash push current mpvc stash apply current + # use mpvc-fzf to manage mpvc stash (see mpvc-fzf -h for more) + mpvc-fzf -a + # use mpvc-fzf to search and play youtube media + mpvc-fzf -p 'kupla mirage' + # use mpvc-fzf to browse & play lofi girl music + mpvc-fzf -b https://lofigirl.com/wp-content/uploads/2023/06 # use mpvc-fzf to manage the playlist mpvc-fzf -f # use mpvc-tui to start the tui + desktop notifications @@ -169,7 +172,7 @@ nix-env -i mpvc ### mpvc ```console -usage: mpvc opts # @version v1.5 (c) gmt4 https://github.com/gmt4/mpvc +usage: mpvc opts # @version v1.6 (c) gmt4 https://github.com/gmt4/mpvc -a | --add : Add media to playlist (see --load for stdin). -s | --stop : Always stop playback. -P | --play : Always start playback. @@ -181,29 +184,29 @@ usage: mpvc opts # @version v1.5 (c) gmt4 https://github.com/gmt4/mpvc -v | --vol : Increase/decrease volume relative to current volume. -h | --help : Prints the short help. -H | --long-help : Prints the long help. - *tips: If unsure about where to begin, have a look at https://gmt4.github.io/mpvc - ``` ### mpvc-tui ```console -usage: mpvc-tui -[d:hHktTm:M:nNsSP:u:x] args # @version v1.5 (c) gmt4 https://github.com/gmt4/mpvc - -d : Set the WD to the media directory given as argument - -n : Desktop notification using notify on mpvc events (notify-send*) - -s : Suggest a random media to play based on previous media played - -t : Starts the mpvc-tui to manage the mpv playlist (rlwrap*) - -T : Combo that starts mpvc-tui -t -n, and adds media given as args - -x : Starts mpvc-tui in a new xterm (config $MPVC_TUI_TERM) [combine -x with other opts] - -v : Prints the mpvc-tui version. +usage: mpvc-tui opts # @version v1.6 (c) gmt4 https://github.com/gmt4/mpvc + -d|dir : Set the WD to the media directory given as argument + -n|notify : Desktop notification using notify on mpvc events (notify-send*) + -s|suggest : Suggest a random media to play based on previous media played + -S|scrobler: Starts the mpvc-tui scrobbler + -H|history : Starts the mpvc-tui history + -t|tui : Starts the mpvc-tui to manage the mpv playlist (rlwrap*) + -T|Tui : Combo that starts mpvc-tui -t -n, and adds media given as args + -x|launch : Starts mpvc-tui in a new xterm ($MPVC_TUI_TERM) # combine with + -v|version : Prints the mpvc-tui version. *tips: If unsure about where to begin, start with: mpvc-tui -d /path/to/media/ -T ```` ### mpvc-fzf ```console -usage: mpvc-fzf opts # @version v1.5 (c) gmt4 https://github.com/gmt4/mpvc +usage: mpvc-fzf opts # @version v1.6 (c) gmt4 https://github.com/gmt4/mpvc -b|browse : Browse the provided ytdl-archive URL with fzf -c|chapters : Start fzf to manage the current mpv chapterlist -d|dir : Set the WD to the media directory given as argument @@ -220,7 +223,9 @@ usage: mpvc-fzf opts # @version v1.5 (c) gmt4 https://github.com/gmt4/mpvc -y|related : Search related media on Invidious -Y|Related : Search & play related media using Invidious -x|launch : Starts mpvc-fzf in a new xterm (config $MPVC_TERM) [combine -x with other opts] - -v|version : Prints the mpvc-fzf version. + -v|version : Return the mpvc-fzf version. + now : Return a shareable URL to the now listening playlist + lofi : Search & play Lo-Fi channels somafm : Search & play SomaFM channels radioapi : Search & play Radio-Browser API channels *tips: If unsure about where to begin, start: mpvc-fzf -p 'kupla mirage' @@ -235,6 +240,8 @@ Like any piece of software, mpvc is not perfect: - mpvc depends on shell tools. If your shell is misconfigured or you are using unusual variants of basic UNIX tools, mpvc is not guaranteed to work. However, all effort has been made to make mpvc as POSIX compliant as possible. + Remember to check for missing dependencies/requirements using `mpvc-installer check-reqs`. + Check out the [Issue Tracker](../../issues) for further improvements to be made. diff --git a/docs/index.html b/docs/index.html index e4e2715a..0686b6de 100644 --- a/docs/index.html +++ b/docs/index.html @@ -140,13 +140,15 @@

Logbook

The logbook got big enought to deserve a page on its own, see here: logbook.html

+ +

- Last-Modified: Friday, 13 September 2024 by gmt4 + πŸ“… Sat, 26 Oct 2024 by gmt4 - Powered by #HTML 🧑 πŸ’š πŸ’™ + ⚑ PoweredBy #HTML

diff --git a/docs/logbook.html b/docs/logbook.html index a43fe7de..46d49817 100644 --- a/docs/logbook.html +++ b/docs/logbook.html @@ -57,10 +57,12 @@

Contents

Logbook Entries
@@ -121,7 +128,7 @@

On load/save functionality, 18 Nov 2022

On persistent mpv startup, 20 Nov 2022

-One particular feature where improvement could be done mpvc -a audio.opus, when mpv finishes playing audio.opus, mpv terminates, and, the current playlist is lost. This happens as mpv is started with --idle=once. A solution for this is to start mpv separately with --idle=yes. A shortcut for this is to run `mpvc --mpv` that does exactly this, after this the mpv instance can be manipulated with mpvc, and does not terminate once mpv finishes playing. +One particular feature where improvement could be done is mpvc -a audio.opus, when mpv finishes playing audio.opus, mpv terminates, and, the current playlist is lost. This happens as mpv is started with --idle=once. A solution for this is to start mpv separately with --idle=yes. A shortcut for this is to run mpvc --mpv that does exactly this, after this the mpv instance can be manipulated with mpvc, and does not terminate once mpv finishes playing.

On a minimal mpvc-tui, 03 Dec 2022

@@ -167,7 +174,7 @@

On managing playlists with mpvc autoload/autosave, 15 The above enables to arrange a playlist, and once we are happy with it, save it with `mpvc autosave playlist.m3u`, later, we can replay it again with: `mpvc autoload playlist.m3u`.

-

On customizing mpvc-tui look and feel, 16 Dec 2022

+

On customizing mpvc-tui look and feel, 18 Dec 2022

While using mpvc-tui, one ends up wanting to configure the minimal look and feel that mpvc-tui provides. To this end the file mpvc.conf under $XDG_CONFIG_HOME/mpvc/ provides a place to overwrite the default settings of mpvc-tui.

@@ -324,7 +331,7 @@

Introducing mpvc-equalizer: a basic mpv equalizer for

On applying ffmpeg AV filters using the MPV JSON IPC, 2 June 2023

-Continuing with the topic of the previous post about mpvc-equalizer, one reason for starting mpvc, was to ease was to managing audio from the CLI. In that sense mpv integrates well with ffmpeg to apply AV filters. However you've to, either start mpv specifying the ffmpeg cli flags for the AV-filters, or add keyboard shortcuts into the input.conf to be triggedred during runtime. +Continuing with the topic of the previous post about mpvc-equalizer, one reason for starting mpvc, was to ease was to managing audio from the CLI. In that sense mpv integrates well with ffmpeg to apply AV filters (##https://ffmpeg.org/ffmpeg-filters.html"). However you've to, either start mpv specifying the ffmpeg cli flags for the AV-filters, or add keyboard shortcuts into the input.conf to be triggedred during runtime.

@@ -332,13 +339,13 @@

On applying ffmpeg AV filters using the MPV JSON IPC,
 # start adding a rubberband filter
-mpvc cmdr af toggle "@rubberband:lavfi=[rubberband=pitch=1:tempo=1]"
+mpvc cmdr af toggle '@rubberband:lavfi=[rubberband=pitch=1:tempo=1]'
 # Change the AV filter is easy, rerun the command with the changes
-mpvc cmdr af toggle "@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]"
+mpvc cmdr af toggle '@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]'
 # Removing the filter is as expected
-mpvc cmdr af remove "@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]"
+mpvc cmdr af remove '@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]'
 # Another option is toggling the AV filters on and off with
-mpvc cmdr af toggle "@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]"
+mpvc cmdr af toggle '@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]'
 
 # The same goes for what filters are currently applied
 mpvc getr af | jq
@@ -351,24 +358,40 @@ 

On applying ffmpeg AV filters using the MPV JSON IPC, mpvc setr msg-level all=warn mpvc setr msg-level all=info -# Some af filters -mpvc cmdr af toggle "@afade:lavfi=[afade=t=in:ss=0:d=15]" -mpvc cmdr af toggle "@flanger:lavfi=[flanger=delay=1]" -mpvc cmdr af toggle "@tremolo:lavfi=[tremolo]" -mpvc cmdr af toggle "@vibrato:lavfi=[vibrato]" -mpvc cmdr af toggle "@apulsator:lavfi=[apulsator]" -mpvc cmdr af toggle "@aphaser:lavfi=[aphaser]" -mpvc cmdr af toggle "@aecho:lavfi=[aecho=in_gain=0.9:out_gain=0.9:delays=1:decays=0.9]" - -# Some vf filters -mpvc cmdr vf toggle "@life:lavfi=[life]" -mpvc cmdr vf toggle "@showvolume:lavfi=[showvolume]" -mpvc cmdr vf toggle "@showwaves:lavfi=[showwaves]" -mpvc cmdr vf toggle "@showspectrum:lavfi=[showspectrum]" -mpvc cmdr vf toggle "@avectorscope:lavfi=[avectorscope]" +# Some af filters (see mpv --af=help) +mpvc cmdr af toggle '@dynaudnorm:lavfi=[dynaudnorm]' +mpvc cmdr af toggle '@afade:lavfi=[afade=t=in:ss=0:d=15]' +mpvc cmdr af toggle '@flanger:lavfi=[flanger=delay=1]' +mpvc cmdr af toggle '@tremolo:lavfi=[tremolo]' +mpvc cmdr af toggle '@vibrato:lavfi=[vibrato]' +mpvc cmdr af toggle '@apulsator:lavfi=[apulsator]' +mpvc cmdr af toggle '@aphaser:lavfi=[aphaser]' +mpvc cmdr af toggle '@aphasemeter:lavfi=[aphasemeter]' +mpvc cmdr af toggle '@aecho:lavfi=[aecho=in_gain=0.9:out_gain=0.9:delays=1:decays=0.9]' +mpvc cmdr af toggle '@lofi:lavfi=[ladspa=cmt:lofi:controls=c0=80|c1=20|c2=9000]' + +# Some vf filters (see mpv --vf=help) +mpvc cmdr vf toggle '@life:lavfi=[life]' +mpvc cmdr vf toggle '@showvolume:lavfi=[showvolume]' +mpvc cmdr vf toggle '@showwaves:lavfi=[showwaves]' +mpvc cmdr vf toggle '@showspectrum:lavfi=[showspectrum]' +mpvc cmdr vf toggle '@avectorscope:lavfi=[avectorscope]' +mpvc cmdr vf toggle '@oscilloscope:lavfi=[oscilloscope]' + +mpvc cmdr vf toggle '@mirrorbottom:lavfi=[[vid1]split[main][tmp];[tmp]crop=iw:ih/2:0:ih/2,vflip[flip];[main][flip]overlay[vo]]' +mpvc cmdr vf toggle '@mirrorleft:lavfi=[[vid1]split[main][tmp];[tmp]crop=iw/2:ih:0:0,hflip[flip];[main][flip]overlay=W/2[vo]]' +mpvc cmdr vf toggle '@mirrorright:lavfi=[[vid1]split[main][tmp];[tmp]crop=iw/2:ih:iw/2:0,hflip[flip];[main][flip]overlay[vo]]' +mpvc cmdr vf toggle '@hstack:lavfi=[[vid1]split[v1][v2];[v1][v2]hstack[t]]' +mpvc cmdr vf toggle '@vstack:lavfi=[[vid1]split[v1][v2];[v1][v2]vstack[t]]'

+For more on this, the above filters can be piped to mpvc-fzf to applied using (c-o apply): + +
+grep '^mpvc cmdr' docs/logbook.html | mpvc-fzf cmds
+
+

Introducing mpvc-web: a mpvc-tui like hack for the web/browser, 21 July 2023

A few things have been going on lately, among them, the most recent has been adding mpvc-web that is just a quick hack to control a running mpv instance from when no mpvc cli is available, a typical example is when you just have a phone or tablet with no cli. To this I resorted to mimic mpvc-tui interface but making it available through HTTP using python3 -m http.server. This seems to work fine for simple things like toggling music on and off, moving to next/prev entry in the playlist, and raising/lowering volume. @@ -379,7 +402,7 @@

Introducing mpvc-web: a mpvc-tui like hack for the web As a minor thing I've started aliasing mpvc commands that I use frequently to their "m" counterparts in bash, not perfect, but handy enough, and saves some typing:
 $ grep mpvc ~/.bashrc
-    alias m="mpvc"
+    alias m="mpvc lowfi"
     alias mh="alias | grep mpvc"
     alias mi="mpvc -i"
     alias mI="mpvc -I"
@@ -401,6 +424,7 @@ 

Introducing mpvc-web: a mpvc-tui like hack for the web alias mffd="mpvc-fzf -d" # fzf on -d /path/to/music/ alias mffe="mpvc-fzf -e" # fzf on mpvc-equalizer alias mfff="mpvc-fzf -f" # fzf on mpvc play-list + alias mffF="mpvc-fzf -F" # fzf on mpvc play-list alias mffg="mpvc-fzf -g" # fzf get/fetch ytid URL to ytdl-archive alias mffG="mpvc-fzf -G" # bis alias mffl="mpvc-fzf -l" # fzf over local files @@ -536,8 +560,8 @@

On the security of mpvc-web, 17 Nov 2023

The solution has been to change the defaults: so now mpvc-web runs by default on localhost, and, a new option: `MPVC_WEB_SSL_ENABLE=1 mpvc-web` -setups a `stunnel(1)` HTTPS connection, this allows to address the HTTPS security part. -Next, to address the authentication part, `stunnel(1)` provides peer +setups a `socat(1)` HTTPS connection, this allows to address the HTTPS security part. +Next, to address the authentication part, `socat(1)` provides peer certificate verification, so using the new option `MPVC_WEB_SSL_ENABLE=1 MPVC_WEB_SSL_VERIFY=2 mpvc-web` only clients that provide a valid peer certificate can connect to mpvc-web.

@@ -557,7 +581,7 @@

On the security of mpvc-web, 17 Nov 2023

  • If additionally, the environment can get attacks from malicious users, then require the use of peer certificates, therefore, limiting access only to those - clients/peers that have present valid `stunnel(1)` certificate with: + clients/peers that have present valid `socat(1)` certificate with: `MPVC_WEB_HOST=0 MPVC_WEB_SSL_ENABLE=1 MPVC_WEB_SSL_VERIFY=2 mpvc-web`
  • @@ -604,10 +628,11 @@

    On MPRIS support, 14 Feb 2024

    Check mpv-mpris for docs/setup, below is a quick setup: -

    -mkdir -p ~/.config/mpv/scripts
    +
    +mkdir -p ~/.config/mpv/scripts;
    +
     curl -fsSL -o ~/.config/mpv/scripts/mpris.so https://github.com/hoyon/mpv-mpris/releases/download/1.0/mpris.so
    -
    + Then, start a new instance of mpv player that loads `mpris.so`
    @@ -644,9 +669,10 @@

    Introducing mpvc-chapter: helper for managing chapters

    Introducing mpvc-osd: interfacing mpvc with a 4x20 USB LCD, 5 May 2024

    While mpvc was playing `The Number 4` from Khruangbin's EP `The Infamous Bill` decided it would be fun to interface mpvc with a USB LCD on the Raspberry PI that acts as a jukebox, so each time a track starts output what's playing now for some seconds, and then poweroff the LCD. Turned out nice and easy by using mpvc-tui -S scrobbling code, and masaging the output to pipe it to the USB LCD for presentation. For the record the output from mpvc-tui is: -

    +
         mpvc-tui -S 'echo $(date +"T%H:%M") $(mpvc -f "[%status%] #%position%/%playlistlength% %time% %artist% - %title% - %path%")' 'false'
    -
    +. + And this is how it looks:

    mpvc-osd usblcd @@ -687,18 +713,49 @@

    Some notes on my current mpvc setup, 4 July 2024

     ssh -X $USER@$HOST x2x -west -to :0 # be sure to read x2x(1)
     
    +

    + +

    On mpvc lowfi and mpvc-fzf URL browser, 26 October 2024

    +

    +Recently landed mpvc lowfi which features a minimal mpvc status that leverages emojis to represent a one-line compressed playing status (aliased to m="mpvc lowfi" above #logbook-20230721): +

    +
    +[play] β–· Polaris 🎢 02:35/04:50 #3/33 πŸ”Š60% πŸ”‚ πŸ”„ 🎧
    +
    +
    +This goes hand in hand with the hability to browse HTTP server listings and add music as in: +
    +
    +% mpvc-fzf -b https://lofigirl.com/wp-content/uploads/2023/05
    +Adding https://lofigirl.com/wp-content/uploads/2023/05/6.Downtown-Binary-_-The-Present-Sound-Polaris.mp3
    +[play] β–· Polaris 🎢 02:35/04:50 #3/33 πŸ”Š60% πŸ”‚ πŸ”„ 🎧
    +
    +
    +The mpvc-fzf -b [URL] browser works as follows: + +
      +
    • 1) gets all hrefs and outputs all the links that point to the current host,
    • +
    • 2) if the link is a media file (say opus/mp3 file) then it can be added with ctrl+t),
    • +
    • 3) if the link points to another directory/page, then it can be browsed with ctrl+[yu]
    • +
    + +The above ctrl+[tyu] shortcuts for mpvc-fzf work as well for local, remote, and other media URLs.

    +

    The End

    + +Return to the Start +

    - Last-Modified: Thursday, 4 July 2024 by gmt4 + πŸ“… Sat, 26 Oct 2024 by gmt4 - Powered by #HTML 🧑 πŸ’š πŸ’™ + ⚑ PoweredBy #HTML

    diff --git a/docs/mpv.conf b/docs/mpv.conf index c321f11f..97141538 100644 --- a/docs/mpv.conf +++ b/docs/mpv.conf @@ -27,7 +27,7 @@ ytdl-raw-options-append=download-archive=~/.config/mpvc/ytdl-archive.txt [mpvc-normalize-volume] profile-desc="Normalize audio volume" -af=lavfi=[dynaudnorm] +af=@dynaudnorm:lavfi=[dynaudnorm] #af=lavfi=[loudnorm=I=-16:TP=-3:LRA=4] volume=70 diff --git a/docs/mpvc.conf b/docs/mpvc.conf new file mode 100644 index 00000000..d7bb4688 --- /dev/null +++ b/docs/mpvc.conf @@ -0,0 +1,20 @@ +# +# @file mpvc.conf example +# @url github.com/gmt4/mpvc +# + +# mpvc config +MPVC_MPV=mpv +MPVC_SOCAT=socat + +MPVC_LOCAL_CACHE="true" +MPVC_FMTSTR_LOFI='[%status%] %statuslofi% %title% 🎢 %time%/%length% #%position%/%playlistlength% %=chapter%/%chapters% %mutelofi%%volume%%% %singlelofi%%repeatlofi%%idlelofi%%videolofi%' +MPVC_FMTSTR='[%status%] %statuslofi% %title% 🎢 %time%/%length% #%position%/%playlistlength% %=chapter%/%chapters% %mutelofi%%volume%%% %singlelofi%%repeatlofi%%idlelofi%%videolofi%' + +# mpvc-tui config +MPVC_TUI_COLOR0='\033[1;36m' +MPVC_TUI_COLOR1='\033[1;37m' +MPVC_TUI_COLOR2='\033[0;36m' + +MPVC_TUI_UPDATEC=4 +MPVC_TUI_CLEARC=8 diff --git a/docs/now/index.html b/docs/now/index.html index 24521dd8..7be40745 100644 --- a/docs/now/index.html +++ b/docs/now/index.html @@ -107,15 +107,18 @@

    Scrobbling Code

    } + +

    - Last-Modified: Thursday, 29 February 2023 by gmt4 + πŸ“… Tue, 19 Now 2024 by gmt4 - Powered by #HTML 🧑 πŸ’š πŸ’™ + ⚑ PoweredBy #HTML

    + diff --git a/extras/mpvc-autostart b/extras/mpvc-autostart index 2faef340..25d5ffbb 100755 --- a/extras/mpvc-autostart +++ b/extras/mpvc-autostart @@ -8,7 +8,7 @@ # PROGNAME=${0##*/} -PROGVERSION="v1.5" +PROGVERSION="v1.6" PROGAUTHOR=gmt4 PROGURL="https://github.com/gmt4/mpvc" @@ -53,13 +53,15 @@ mpvc_autoscan() optflags="hi:n:p:m:M:" usage() { - echo "usage: $PROGNAME -[$optflags] args # @version $PROGVERSION (c) $PROGAUTHOR $PROGURL" - echo " -i : The IP of the device to detect ping presence for $PROGNAME (*required)" - echo " -p : The number of seconds between ping presence checks" - echo " -n : The number of failed ping presence checks after which to pause mpvc" - echo " -m : The minimum hour when to start ping presence (for example morning: 7 AM)" - echo " -M : The maximum hour when to stop ping presence (for example night: 20 PM)" - echo "*tips: If unsure where to begin, run: $PROGNAME -i 192.168.0.2 # your tablet/phone LAN IP" + cat <.*<\/a>/ { h=$0;sub("^.*href=\"","",h);sub("\".*$","",h);print h }' + awk -v url="$url" ' + /.*<\/a>/ { + match(url, "https?://[^/]+/", host); + href=$0; sub("^.*href=\"", "", href) sub("\".*$", "", href) + if (href ~ "^/") href = host[0]"/"href + print (href !~ host[0]) ? url"/"href : href + } + ' } mpvcfzf_urlbrowser() { url=${1:-https://localhost:8443/ytdl-archive/} mpvcfzf_urlget "$url" | - mpvcfzf_preview --prompt="(urlbrowse) " | - awk -v url="$url" '{ print url$0 }' + mpvcfzf_preview --prompt="(urlbrowse) " +} + +mpvcfzf_cmds() +{ + mpvcfzf_preview --prompt '(cmds)' --bind='ctrl-o:execute(sh -c {})' "$@"; } mpvcfzf_equalizer() @@ -345,8 +335,8 @@ mpvcfzf_equalizer() mpvc-equalizer preset | mpvcfzf_preview --prompt="(equalizer) " \ --header="$PROGNAME help: $MPVC_FZF_BIND_HELP" \ - --bind='ctrl-x:execute(mpvc-equalizer dec {1} &)' \ - --bind='ctrl-v:execute(mpvc-equalizer inc {1} &)' \ + --bind='ctrl-x:execute-silent(mpvc-equalizer dec {1} &)' \ + --bind='ctrl-v:execute-silent(mpvc-equalizer inc {1} &)' \ --bind='ctrl-space:execute-silent(mpvc-equalizer reset)' \ --bind='ctrl-o:execute-silent(mpvc-equalizer preset {-1} | mpvc-equalizer load)' \ --bind='ctrl-s:reload(mpvc-equalizer bars)' \ @@ -360,30 +350,35 @@ mpvcfzf_ddg() echo "$url_search" mpvcfzf_curl "$url_search" | - awk ' - function urldecode(url) + awk ' + function urldecode(url) + { + for (y=0; y < 127; y++) { - for (y=0; y < 127; y++) - { - if (y != 37) - gsub(sprintf("%%%02x|%%%02X", y, y), y==38 ? "\\&" : sprintf("%c", y), url); - gsub(/%25/, "%", url); - } - return url + if (y != 37) + gsub(sprintf("%%%02x|%%%02X", y, y), y==38 ? "\\&" : sprintf("%c", y), url); + gsub(/%25/, "%", url); } + return url + } - /result__a/ { - gsub("", " "); - gsub("",""); - - gsub("%3A",":"); gsub("%2F","/"); gsub("%3F","?"); gsub("%3D","="); - gsub("^ *",""); - #print urldecode($0) - print - }' + /result__a/ { + gsub("", " "); + gsub("",""); + + gsub("%3A",":"); gsub("%2F","/"); gsub("%3F","?"); gsub("%3D","="); + gsub("^ *",""); + #print urldecode($0) + print + }' +} + +mpvcfzf_lofi() +{ + mpvcfzf_urlbrowser "${1:-https://lofigirl.com/wp-content/uploads/2023/06/}" } mpvcfzf_somafm() @@ -426,6 +421,7 @@ mpvcfzf_radioapi_search() mpvcfzf_now_geturls() { mpvc saven; } mpvcfzf_now_getvids() { echo "$@" | awk '/youtube|yewtu/ { sub("^.*/",""); sub(".*=",""); sub("^","\\&v="); printf $0; }'; } + mpvcfzf_now() { date=$(date -Idate) @@ -436,7 +432,7 @@ mpvcfzf_now() echo "$now?t=$date$vids" echo - awk -v u="$urls" -v l="$list" 'END{ split(u, au,"\n"); split(l, al,"\n"); for(u in au) {print au[u], al[u]}; }' /dev/null + gawk -v u="$urls" -v l="$list" 'END{ split(u,au,"\n"); split(l,al,"\n"); for(u in au) {print au[u], al[u]}; }' /dev/null } mpvcfzf_launch_term() @@ -451,31 +447,34 @@ mpvcfzf_version() mpvcfzf_usage() { - echo "usage: $PROGNAME opts # @version $PROGVERSION (c) $PROGAUTHOR $PROGURL" - echo " -b|browse : Browse the provided ytdl-archive URL with fzf" - echo " -c|chapters : Start fzf to manage the current mpv chapterlist" - echo " -d|dir : Set the WD to the media directory given as argument" - echo " -e|eqz : Start fzf to manage the equalizer settings" - echo " -f|playlist : Start fzf to manage the current mpv playist" - echo " -g|fetch : Fetch the given YT URL, and store locally" - echo " -G|Fetch : Search on Invidious, fetch, and store locally" - echo " -i|lyrics : Search given media lyrics on Invidious" - echo " -k|dplay : Search & play DuckDuckGo videos" - echo " -K|dsearch : Search DuckDuckGo videos" - echo " -l|local : Search & play local media" - echo " -s|search : Search on Invidious" - echo " -p|splay : Search & play media found using Invidious" - echo " -y|related : Search related media on Invidious" - echo " -Y|Related : Search & play related media using Invidious" - echo " -x|launch : Starts $PROGNAME in a new $MPVC_TERM (config \$MPVC_TERM) [combine -x with other opts]" - echo " -v|version : Return the $PROGNAME version." - echo " now : Return a shareable URL to the "now listening" playlist" - echo " somafm : Search & play SomaFM channels" - echo " radioapi : Search & play Radio-Browser API channels" - echo "*tips: If unsure about where to begin, start: $PROGNAME -p 'kupla mirage'" + cat <&1) - if [ $(( count % MPVC_TUI_CLEARC )) -eq 0 ]; then printf "${MPVC_TUI_CLEAR}"; fi + if [ $(( mpvctui_count % MPVC_TUI_CLEARC )) -eq 0 ]; then printf "${MPVC_TUI_CLEAR}"; fi printf "${MPVC_TUI_CUP}" echo "$output" - count=$(( count + 1 )) + mpvctui_count=$(( mpvctui_count + 1 )) sleep $MPVC_TUI_UPDATEC done } +mpvctui_watch_auto() +{ + mpvc -q --mpv & + ( sleep 2 && if [ "$#" -gt 0 ]; then mpvc --append "$@"; fi ) + ( sleep 1; pgrep -f "$PROGNAME -n" || setsid "$0" -n ) & + mpvctui_watch +} + mpvctui_mouse() { clear @@ -261,26 +275,23 @@ mpvctui_mouse_events() mpvctui_notify() { # $MPVC_TUI_SCROBBLER: scrobbling file contains one entry per line with tab-separated fields - cmd_notify='notify-send -u normal -i info "$(mpvc)";' cmd_scrobble='echo $(mpvc expand-text "$(date +%s)\t\\${=duration}\t\\${path}\t\\${media-title}") >> '"$MPVC_TUI_SCROBBLER" + cmd_notify='notify-send -u normal -i "'"$MPVC_TUI_ICON"'" "mpvc" "$(mpvc)";' awk -v cmd_scrobble="${1:-$cmd_scrobble}" -v cmd_notify="${2:-$cmd_notify}" ' - BEGIN { ot = otn = systime(); do_print = cmd_notify != "false" && cmd_scrobble != "false"; } + BEGIN { ot = systime(); do_print = (cmd_notify != "false" && cmd_scrobble != "false"); } - /playback-restart|chapter-change|metadata-update/ { - tn=systime() - if (tn - otn > 1) - system(cmd_notify); - otn=tn - if (do_print) print tn, $0, "notify" - } - - /playback-restartproperty-change||metadata-update/ { + /playback-restart|property-change|metadata-update/ { + #print "notify",$0 t=systime() if (t - ot > 1) + { system(cmd_scrobble); + system(cmd_notify); + } + if (do_print) print t, $0, "scrobble"; + if (do_print) print t, $0, "notify"; ot=t - if (do_print) print t, $0, "scrobble" } ' } @@ -329,46 +340,45 @@ mpvctui_launch() mpvctui_usage() { - echo "usage: $PROGNAME -[$optflags] args # @version $PROGVERSION (c) $PROGAUTHOR $PROGURL" - echo " -d : Set the WD to the media directory given as argument" - echo " -n : Desktop notification using notify on mpvc events (notify-send*)" - echo " -s : Suggest a random media to play based on previous media played" - echo " -t : Starts the $PROGNAME to manage the mpv playlist (rlwrap*)" - echo " -T : Combo that starts $PROGNAME -t -n, and adds media given as args" - echo " -x : Starts $PROGNAME in a new $MPVC_TUI_TERM (config \$MPVC_TUI_TERM) [combine -x with other opts]" - echo " -v : Prints the $PROGNAME version." - echo "*tips: If unsure about where to begin, start with: $PROGNAME -d /path/to/media/ -T" + cat < + -v|version : Prints the $PROGNAME version. +*tips: If unsure about where to begin, start with: $PROGNAME -d /path/to/media/ -T +EOF exit; } -optflags="d:hHktTm:M:nNsSP:u:x" mpvctui_main() { mpvctui_config if [ $# -eq 0 ]; then mpvctui_usage; fi - while getopts "$optflags" flag; + for arg in "$@"; do - case "$flag" in - d) MPVC_TUI_DIR="$OPTARG"; cd "$MPVC_TUI_DIR" || return;; - h) shift; mpvctui_usage ;; - H) shift; cat $MPVC_TUI_SCROBBLER ;; - t) shift; mpvctui_watch ;; - T) shift; - mpvc -q --mpv & - ( sleep 2 && if [ "$#" -gt 0 ]; then mpvc --append "$@"; fi ) - ( sleep 1; pgrep -f "$PROGNAME -n" || setsid "$0" -n ) & - mpvctui_watch - ;; - M) shift; mpvctui_launch "-m$OPTARG"; exit ;; # -g 15x1 - m) shift; mpvctui_mouse "$OPTARG" ;; - n) shift; mpvctui_notify_loop "${1:-}" ;; - N) shift; mpvctui_notify "${@}" ;; - k) shift; pkill -f "$PROGNAME" ;; - s) shift; mpvctui_suggest ;; - S) shift; mpvctui_notify_loop_cli "${1:-}" ;; - u) shift; MPVC_TUI_UPDATEC="$OPTARG" ;; - x) shift; mpvctui_launch "$@"; exit ;; + arg1="${2:-}" + case "$arg" in + -d|dir) shift; MPVC_TUI_DIR="$arg1"; cd "$MPVC_TUI_DIR" || return;; + -h|help) shift; mpvctui_usage ;; + -H|history) shift; cat "$MPVC_TUI_SCROBBLER" ;; + -t|tui) shift; mpvctui_watch ;; + -T|Tui) shift; mpvctui_watch_auto "$@" ;; + -M|Mouse) shift; mpvctui_launch "-m$arg1"; exit ;; # -g 15x1 + -m|mouse) shift; mpvctui_mouse "$arg1" ;; + -n|Notify) shift; mpvctui_notify_loop "${1:-}" ;; + -N|notify) shift; mpvctui_notify "$@" ;; + -k|kill) shift; pkill -f "$PROGNAME" ;; + -s|suggest) shift; mpvctui_suggest ;; + -S|scrobler) shift; mpvctui_notify_loop_cli "${1:-}" ;; + -u|updatec) shift; MPVC_TUI_UPDATEC="$arg1" ;; + -x|launch) shift; mpvctui_launch "$@"; exit ;; *) mpvctui_usage;; esac diff --git a/extras/mpvc-web b/extras/mpvc-web index 43fa02f8..bd3abc50 100755 --- a/extras/mpvc-web +++ b/extras/mpvc-web @@ -16,7 +16,7 @@ PROGNAME=${0##*/} PROGDIR=${0%/*} -PROGVERSION="v1.5" +PROGVERSION="v1.6" PROGAUTHOR=gmt4 PROGURL="https://github.com/gmt4/mpvc" PROGINFO="A hack to remotely control mpvc from web # DISCLAIMER * Use at Your Own Risk *" @@ -36,9 +36,8 @@ mpvc_web_defaults() MPVC_WEB_PORT=${MPVC_WEB_PORT:-8000} MPVC_WEB_ROOT=${MPVC_WEB_ROOT:-/tmp/mpvc-web/root} MPVC_WEB_SSL_PORT=${MPVC_WEB_SSL_PORT:-8443} - MPVC_WEB_SSL_PEM=${MPVC_WEB_SSL_PEM:-$MPVC_WEB_ROOT/../stunnel.pem} - MPVC_WEB_SSL_CFG=${MPVC_WEB_SSL_CFG:-$MPVC_WEB_ROOT/../stunnel.cfg} - MPVC_WEB_SSL_PID=${MPVC_WEB_SSL_PID:-$MPVC_WEB_ROOT/../stunnel.pid} + MPVC_WEB_SSL_PEM=${MPVC_WEB_SSL_PEM:-$MPVC_WEB_ROOT/../ssl.pem} + MPVC_WEB_SSL_PID=${MPVC_WEB_SSL_PID:-$MPVC_WEB_ROOT/../ssl.pid} MPVC_WEB_SSL_ENABLE=${MPVC_WEB_SSL_ENABLE:-} MPVC_WEB_SSL_VERIFY=${MPVC_WEB_SSL_VERIFY:-0} MPVC_WEB_ARCHIVE_ENABLE=${MPVC_WEB_ARCHIVE_ENABLE:-} @@ -82,17 +81,17 @@ mpvc_web_config() echo "$PROGNAME: Error: No python3 found, install to continue." exit fi - if ! command -v stunnel >/dev/null; then - echo "$PROGNAME: Warning: No stunnel found, install to support SSL." + if ! command -v socat >/dev/null; then + echo "$PROGNAME: Warning: No socat found, install to support SSL." fi } mpvc_web_style() { cat <<-EOF -:root { --body-font-family: monospace; --body-color: #222; --body-background: #fff; --link-color: #a0a; } -@media (max-width: 768px) { :root { --body-font-size: 1.06em; } } -@media (min-width: 768px) { :root { --body-font-size: 1.10em; } } +:root { --body-font-family: monospace,monospace; --body-color: #222; --body-background: #fff; --link-color: #a0a; } +@media (max-width: 768px) { :root { --body-font-size: 0.92em; } } +@media (min-width: 768px) { :root { --body-font-size: 1.00em; } } @media (prefers-color-scheme: light) { html { filter: invert(0.0); } :root { } } @media (prefers-color-scheme: dark) { html { filter: invert(0.85); } :root { } } @@ -132,7 +131,7 @@ mpvc_web_select_form() mpvc_web_yts() { cat < + EOF @@ -150,6 +149,12 @@ EOF mpvc_web_index_js() { cat < 🎧$MPVC_WEB_HOSTNAME mpvc - @@ -389,16 +394,16 @@ mpvc_web_index() ch+
  • - $(echo "-15\n-10\n-5\n-2\n-1\n0\n+1\n+2\n+5\n+10\n+15" | mpvc_web_select_form "mpvc -q track" "${MPVC_WEB_SHORTCUT_TRACK}") + $(printf " -15\n-10\n-5\n-2\n-1\n0\n+1\n+2\n+5\n+10\n+15" | mpvc_web_select_form "mpvc -q track" "${MPVC_WEB_SHORTCUT_TRACK}")
  • - $(echo "-30\n-20\n-10\n-5\n-1\n0\n+1\n+5\n+10\n+20\n+30" | mpvc_web_select_form "mpvc -q cplay") + $(printf " -30\n-20\n-10\n-5\n-1\n0\n+1\n+5\n+10\n+20\n+30" | mpvc_web_select_form "mpvc -q cplay")
  • - $(echo "-30\n-20\n-10\n-5\n0\n+5\n+10\n+20\n+30" | mpvc_web_select_form "mpvc -q vol" "${MPVC_WEB_SHORTCUT_VOL}") + $(printf " -30\n-20\n-10\n-5\n0\n+5\n+10\n+20\n+30" | mpvc_web_select_form "mpvc -q vol" "${MPVC_WEB_SHORTCUT_VOL}")
  • - $(echo "-120\n-60\n-25\n+25\n+60\n+120" | mpvc_web_select_form "mpvc -q seek" "${MPVC_WEB_SHORTCUT_SEEK}") + $(printf " -120\n-60\n-25\n+25\n+60\n+120" | mpvc_web_select_form "mpvc -q seek" "${MPVC_WEB_SHORTCUT_SEEK}")
  • $(if [ -n "$MPVC_WEB_ARCHIVE_ENABLE" ]; then find "ytdl-archive/" | awk -F/ '{print "https://"$NF}' | mpvc_web_select_form "mpvc -q add" "${MPVC_WEB_SHORTCUT_ARCHIVE}"; fi) @@ -413,26 +418,28 @@ mpvc_web_index() t4 t6 t8 - cycle + tg rst +
  • [ Status + #related #lyrics #file ]
    - + [ Playlist full raw chapters - load + load ]
    - -