Zenity or YAD, for quick adding url to mpv-music list

Another simple stupid script to quickly add url to mpv mb-music list.
Sort url’s out afterwards.

Add this (or similar) at the end of the yt_music_list.csv file

UNSORTED,-

script.sh

#!/bin/bash

# File to append to
CSV_FILE="$HOME/.config/mabox/mb-music/yt_music_list.csv"

# Create the file if it doesn't exist
touch "$CSV_FILE"

# Get URL from user input (using zenity)
URL=$(zenity --entry --title="QUICK Add Youtube Url 
to radio-mpv list" --text="fill in like this: 
Band titel,<paste url here>" )

# Check if the user canceled the input
if [ -z "$URL" ]; then
    exit 0
fi

# Check for video or audio extensions
if true ; then
    # Get the current date and time
    DATE=$(date "+%Y-%m-%d %H:%M:%S")
    # Append to CSV file
    echo "$URL" >> "$CSV_FILE"
    zenity --info --title="URL Added" --text="The URL was added to $CSV_FILE."
else
    # Show an error message if the URL does not match
    zenity --error --title="Invalid URL" --text="The URL does not have a valid video or audio file extension."
fi


An impression on Vimeo.

https://vimeo.com/1041822264?share=copy

:bird:

1 Like

Zenity is ok, … but YAD is great (Zenity on steroids) :wink:

https://yad-guide.ingk.se/

1 Like

It was a spontanius action. It liked the idea of quick adding the urls.
But i will have a look at yad :wink:

It is already there…

Alt + PgUP, Alt + PgDOWN to move lines up or down quickly.

1 Like

I am aware of the geany method,
Thats fine for fine-tuning. Reoganising list.
And absolutly enough :wink:

But sometimes i am to restles :cyclone: to copy paste lines and comma’s with geany
I can be in a flow of collecting new streams, and like to add them easie and quick.

Some streams don’t work and so i can quickly test first if everything is fine.
I stop using Invidious links. They not always stream.

:bird:

Yad version: To quickly add url to mb-music mpv list cvs.

  • Create hotkey for quick launch.
  • Copy url and launch script. Url should be pasted in field automaticly.

Script.sh

#!/bin/bash

# File to append to
CSV_FILE="$HOME/.config/mabox/mb-music/yt_music_list.csv"

# Create the file if it doesn't exist
touch "$CSV_FILE"

# Get clipboard content (requires xclip)
CLIPBOARD=$(xclip -o -selection clipboard)

# Check if clipboard is empty or does not contain a valid URL
if [[ -z "$CLIPBOARD" || ! "$CLIPBOARD" =~ ^https?:// ]]; then

            yad --warning --title="Clipboard Invalid" \
                --window-icon="media-tape"\
                --image="dialog-error"\
                --text="The clipboard does not contain a valid URL. 
Please copy a URL and try again."
    exit 1
fi

# Get artist, title, and URL from user input using yad
ENTRY=$(yad --form --title="Add Stream to Mabox mpv List." \
    --window-icon="media-tape"\
    --image="document-save"\
    --text="Please provide the following details to add stream to the list : \n\n\
Only fill in Category to start new one:"\
            --field="URL :":TEXT "$CLIPBOARD" \
            --field="Artist :":TEXT \
            --field="Title :":TEXT \
            --field="Category :":TEXT )

# Check if the user canceled the input
if [ -z "$ENTRY" ]; then
    exit 0
fi

# Split the input into variables
URL=$(echo "$ENTRY" | cut -d '|' -f 1)
ARTIST=$(echo "$ENTRY" | cut -d '|' -f 2)
TITLE=$(echo "$ENTRY" | cut -d '|' -f 3)
CATEGORY=$(echo "$ENTRY" | cut -d '|' -f 4)



# Validate the input
if [ -z "$ARTIST" ] || [ -z "$TITLE" ] || [ -z "$URL" ] ; then
    yad --error --title="Invalid Input" --text="All fields must be filled."
    exit 1
fi

# Append to CSV file

if [ -z  "$CATEGORY"] ; then
echo "$ARTIST - $TITLE,$URL" >> "$CSV_FILE"
notify-send -i media-tape -t 50000 "$ARTIST - $TITLE" "Added to the playlist"
else
echo "$CATEGORY,-" >> "$CSV_FILE"
echo "$ARTIST - $TITLE,$URL" >> "$CSV_FILE"
notify-send -i media-tape -t 50000 "$ARTIST - $TITLE" "Added To $CATEGORY"
fi



:bird:

Edit:

  • replaced icons

Edit 2 : small changes

  • A bit better flow