• 5 Posts
  • 63 Comments
Joined 3 years ago
cake
Cake day: April 1st, 2022

help-circle




  • While I doubt the concept is unique, the script is: a keyboard shortcut will check the clipboard for a YouTube link and then show launcher options for mpv or yt-dlp, including launch arguments for lower quality format and audio only. It launches that in a terminal for easier handling when yt-dlp doesn’t work properly (much more common if using proxies, but also if a video is age-restricted or deleted).

    So when I see a yt link here, I can just copy it, keyboard shortcut and then it’s playing in my local video player.

    edit: here’s the script. It assumes xsel (clipboard access), rofi (menu creator), gnome-terminal (terminal) and notify-send (system notification on failure) are installed and working, you’ll need to replace any which don’t match your system. My DE just runs it in bash when the shortcut is entered.

    Code (click to expand)
    #!/bin/bash
    
    ARR=()
    ARR+=("mpv full")
    ARR+=("mpv medium")
    ARR+=("yt-dlp")
    
    NORMAL_URL=`xsel -ob | sed -r "s/.*(v=|\/)([a-zA-Z0-9_-]{11}).*/https:\/\/youtube.com\/watch?v=\2/"`
    
    CHOICE=$(printf '%s\n' "${ARR[@]}" | rofi -dmenu -p "mpv + yt-dlp from clipboard")
    DOWNLOAD="false"
    MPV="false"
    OPTIONS=""
    
    if [ "$CHOICE" = "mpv full" ]; then
    	MPV="true"
    fi
    
    if [ "$CHOICE" = "mpv medium" ]; then
    	MPV="true"
    	OPTIONS+="'--ytdl-format=bv*[height<721]+ba' "
    fi
    
    if [ "$CHOICE" = "yt-dlp" ]; then
    	DOWNLOAD="true"
    fi
    
    if [ $MPV == "true" ]; then
    	COMMAND="mpv $OPTIONS $NORMAL_URL"
    	gnome-terminal --title "$NORMAL_URL" -- bash -c "echo $COMMAND;$COMMAND;if [ \$? -ne 0 ]; then notify-send 'yt-dlp failed' $NORMAL_URL; bash; fi;"
    elif [ $DOWNLOAD == "true" ]; then
    	COMMAND="yt-dlp $OPTIONS $NORMAL_URL"
            gnome-terminal --title "$NORMAL_URL" -- bash -c "echo $COMMAND;$COMMAND;if [ \$? -ne 0 ]; then notify-send 'yt-dlp failed' $NORMAL_URL; bash; fi;"
    fi
    




  • “Which FOSS projects have enough funding that we should donate elsewhere?” is more-or-less asking “Which FOSS projects are overfunded?”, making it almost the opposite of “Which worthwhile FOSS projects are underfunded?”

    Plenty of projects I rely on are underfunded or adequately funded, and there are many thousands of underfunded projects. So I’ll have no shortage of projects to consider. By instead asking for the overfunded projects, I can simply cross them off my list of projects to donate to.












  • I felt that way too, but testing it for a few days on one device changed my mind. Their pitch rings true, it has so many basic QoL features that make you wonder why this wasn’t added to bash two decades ago.

    For me, the only bash->fish gripe I’ve had was it took me a little while to get used to having to put quotes around URLs with a ? to stop it trying to wildcard, but again, their rationale makes perfect sense and really I admit it was bad for bash to simply accept that string in the first place.


  • I’m annoyed that a lot of the sites I browse don’t have RSS feeds, and I’ve had to do some really tiresome hacks just to get some to work (for example, even tools like FreshRSS’s HTML parser doesn’t tell you the reason a feed broke, so there’s a dozen different things to adjust blindly until it works).

    RSS saves me so much time, I used to waste hours just cycling through pages to see if any updated.