Skip to content

Instantly share code, notes, and snippets.

@kenanpelit
Created November 26, 2024 09:04
Show Gist options
  • Save kenanpelit/40d3c0741e634f3a9d76c4923f0a859d to your computer and use it in GitHub Desktop.
Save kenanpelit/40d3c0741e634f3a9d76c4923f0a859d to your computer and use it in GitHub Desktop.
mpv-youtube-player.sh
#!/bin/bash
# Renkli çıktılar için ANSI renk kodları
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # Rengi sıfırla
# Eğlenceli emojiler
ROCKET="🚀"
MOVIE="🎬"
CHECK=""
WARN="⚠️"
ERROR=""
# Notify-send için fonksiyon
notify() {
if command -v notify-send &> /dev/null; then
notify-send -u normal "$1" "$2" -i video-player
fi
}
# MPV kontrolü
check_mpv() {
echo -e "${BLUE}${ROCKET} MPV kontrolü yapılıyor...${NC}"
if ! command -v mpv &> /dev/null; then
echo -e "${YELLOW}${WARN} MPV bulunamadı. Yüklemeye çalışılacak...${NC}"
notify "MPV Yükleyici" "MPV yükleniyor..."
# İşletim sistemini kontrol et
if command -v apt &> /dev/null; then
sudo apt update && sudo apt install -y mpv
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm mpv
elif command -v dnf &> /dev/null; then
sudo dnf install -y mpv
else
echo -e "${RED}${ERROR} Desteklenmeyen paket yöneticisi!${NC}"
notify "MPV Yükleyici" "Desteklenmeyen paket yöneticisi!"
exit 1
fi
if [ $? -eq 0 ]; then
echo -e "${GREEN}${CHECK} MPV başarıyla yüklendi!${NC}"
notify "MPV Yükleyici" "MPV başarıyla yüklendi!"
else
echo -e "${RED}${ERROR} MPV yüklenirken bir hata oluştu!${NC}"
notify "MPV Yükleyici" "MPV yüklenirken bir hata oluştu!"
exit 1
fi
else
echo -e "${GREEN}${CHECK} MPV zaten yüklü!${NC}"
fi
}
# YouTube URL'sini kontrol et
if [ -z "$1" ]; then
echo -e "${RED}${ERROR} Lütfen bir YouTube URL'si girin!${NC}"
notify "MPV Player" "Lütfen bir YouTube URL'si girin!"
exit 1
fi
# MPV'yi kontrol et ve gerekirse yükle
check_mpv
# Video oynatma
echo -e "${BLUE}${MOVIE} Video oynatılıyor...${NC}"
notify "MPV Player" "Video oynatılıyor... $1"
mpv "$1" || {
echo -e "${RED}${ERROR} Video oynatılırken bir hata oluştu!${NC}"
notify "MPV Player" "Video oynatılırken bir hata oluştu!"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment