'bash script youtube filtering

The goal is to be able to send video urls to two metube dockers. One just for YouTube and one for everything else but YouTube.

This script is going to go in my phone for use with termux url opener which opens as a argument $url

#!/bin/bash
# $url will contain a url to a video for processing on youtube-dl

# this will only take youtube urls and not others
if [[ $url =~ ['^(https?\:\/\/)?(www\.youtube\.com)\/.+$'] ]] || [[ $url =~ ['^(https?\:\/\/)?(www\.youtu\.be)\/.+$'] ]]
then 
    #curl -X POST https://metube.domain.com/add -H 'Content-Type: application/json' -d "{\"url\":\"$1\",\"quality\":\"1440p\"}" 
    echo "Sent To Metube"
fi

# this will take any url other then youtube
if [[ "$url" =~ ['^(https?\:\/\/)?(www\.a-zA-Z0-9\.com)\/.+$'] ]]
then
    #curl -X POST https://metube2.domain.com/add -H 'Content-Type: application/json' -d "{\"url\":\"$1\",\"quality\":\"1440p\"}"
    echo "Sent To Metube2"
fi


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source