update shebangs and add some music scripts
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function install() {
|
||||
name=$1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
project_dir="$HOME/projects"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
font="$(fc-list | fzf)"
|
||||
|
||||
|
||||
160
private_dot_local/bin/executable_music_gen_playlists
Normal file
160
private_dot_local/bin/executable_music_gen_playlists
Normal file
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "[playlist]" >Playlists/all.pls
|
||||
echo "[playlist]" >Playlists/le.pls
|
||||
echo "[playlist]" >Playlists/lme.pls
|
||||
echo "[playlist]" >Playlists/me.pls
|
||||
echo "[playlist]" >Playlists/mhe.pls
|
||||
echo "[playlist]" >Playlists/he.pls
|
||||
echo "[playlist]" >Playlists/lofi.pls
|
||||
echo "[playlist]" >Playlists/le_lofi.pls
|
||||
echo "[playlist]" >Playlists/unkown.pls
|
||||
echo "[playlist]" >Playlists/dnp.pls
|
||||
|
||||
. ~/.local/python-venv/bin/activate
|
||||
|
||||
files="$(find . -type f -name '*.mp3' -o -name '*.flac' | sed -e 's/ /%20/g')"
|
||||
|
||||
list_artist=""
|
||||
list_artist_i=1
|
||||
list_album=""
|
||||
list_album_i=1
|
||||
|
||||
list_songs=""
|
||||
|
||||
for file in $(echo $files)
|
||||
do
|
||||
path="$(echo $file | sed -e 's/%20/ /g')"
|
||||
metadata="flac"
|
||||
genre="$(ffmpeg -i "${path}" 2>&1 | grep GENRE | sed -e 's/^.*: //')"
|
||||
artist="$(ffmpeg -i "${path}" 2>&1 | grep ARTIST | sed -e 's/^.*: //')"
|
||||
album="$(ffmpeg -i "${path}" 2>&1 | grep ALBUM | sed -e 's/^.*: //')"
|
||||
title="$(ffmpeg -i "${path}" 2>&1 | grep TITLE | sed -e 's/^.*: //')"
|
||||
blockLevel="0"
|
||||
likeLevel="3"
|
||||
if [[ "$(echo "${path}" | sed -e 's/^.*\.\([^\.]*\)$/\1/')" == "mp3" ]]
|
||||
then
|
||||
metadata="mp3"
|
||||
genre="$(id3v2 -l "${path}" | grep '^TCON' | sed -e 's/^.*: //')"
|
||||
artist="$(id3v2 -l "${path}" | grep '^TPE2' | sed -e 's/^.*: //')"
|
||||
album="$(id3v2 -l "${path}" | grep '^TALB' | sed -e 's/^.*: //')"
|
||||
title="$(id3v2 -l "${path}" | grep '^TIT2' | sed -e 's/^.*: //')"
|
||||
fi
|
||||
if [[ "$genre" == "" ]]
|
||||
then
|
||||
genre="Unkown"
|
||||
fi
|
||||
echo "$genre: ${path}"
|
||||
if [[ "${genre,,}" == "lofi" ]]
|
||||
then
|
||||
echo "file$(cat Playlists/lofi.pls | wc -l)=.${path}" >>Playlists/lofi.pls
|
||||
echo "file$(cat Playlists/le_lofi.pls | wc -l)=.${path}" >>Playlists/le_lofi.pls
|
||||
elif [[ "$(echo ${genre} | grep --no-ignore-case LE)" != "" ]]
|
||||
then
|
||||
echo "file$(cat Playlists/all.pls | wc -l)=.${path}" >>Playlists/all.pls
|
||||
echo "file$(cat Playlists/le.pls | wc -l)=.${path}" >>Playlists/le.pls
|
||||
echo "file$(cat Playlists/lme.pls | wc -l)=.${path}" >>Playlists/lme.pls
|
||||
echo "file$(cat Playlists/le_lofi.pls | wc -l)=.${path}" >>Playlists/le_lofi.pls
|
||||
elif [[ "$(echo ${genre} | grep --no-ignore-case ME)" != "" ]]
|
||||
then
|
||||
echo "file$(cat Playlists/all.pls | wc -l)=.${path}" >>Playlists/all.pls
|
||||
echo "file$(cat Playlists/me.pls | wc -l)=.${path}" >>Playlists/me.pls
|
||||
echo "file$(cat Playlists/lme.pls | wc -l)=.${path}" >>Playlists/lme.pls
|
||||
echo "file$(cat Playlists/mhe.pls | wc -l)=.${path}" >>Playlists/mhe.pls
|
||||
elif [[ "$(echo ${genre} | grep --no-ignore-case HE)" != "" ]]
|
||||
then
|
||||
echo "file$(cat Playlists/all.pls | wc -l)=.${path}" >>Playlists/all.pls
|
||||
echo "file$(cat Playlists/he.pls | wc -l)=.${path}" >>Playlists/he.pls
|
||||
echo "file$(cat Playlists/mhe.pls | wc -l)=.${path}" >>Playlists/mhe.pls
|
||||
elif [[ "$(echo ${genre} | grep --no-ignore-case DNP)" == "" ]]
|
||||
then
|
||||
echo "file$(cat Playlists/all.pls | wc -l)=.${path}" >>Playlists/all.pls
|
||||
echo "file$(cat Playlists/unkown.pls | wc -l)=.${path}" >>Playlists/unkown.pls
|
||||
else
|
||||
echo "file$(cat Playlists/dnp.pls | wc -l)=.${path}" >>Playlists/dnp.pls
|
||||
blockLevel="1"
|
||||
fi
|
||||
|
||||
if [[ "$(echo ${genre} | grep --no-ignore-case 'L[0-3]')" != "" ]]
|
||||
then
|
||||
likeLevel="$(echo ${genre} | grep --no-ignore-case -o 'L[0-3]' | grep -o '[0-3]')"
|
||||
fi
|
||||
if [[ "$(echo ${genre} | grep --no-ignore-case 'B[0-3]')" != "" ]]
|
||||
then
|
||||
blockLevel="$(echo ${genre} | grep --no-ignore-case -o 'B[0-3]' | grep -o '[0-3]')"
|
||||
fi
|
||||
|
||||
if [[ "$(echo $list_artist | grep ":$artist")" = "" ]]
|
||||
then
|
||||
list_artist="${list_artist};${list_artist_i}:$artist"
|
||||
list_artist_i=$(( $list_artist_i + 1 ))
|
||||
fi
|
||||
|
||||
if [[ "$(echo $list_album | grep ":${album}:")" = "" ]]
|
||||
then
|
||||
list_album="${list_album};${list_album_i}:$album:$artist"
|
||||
list_album_i=$(( $list_album_i + 1 ))
|
||||
fi
|
||||
|
||||
list_songs="$list_songs\
|
||||
\"/storage/emulated/0/Music/$(echo $path | sed -e 's/^..//')\": {\
|
||||
\"title\": \"$title\",\
|
||||
\"album\": \"$album\",\
|
||||
\"artist\": \"$artist\",\
|
||||
\"albumId\": $(echo $list_album | tr ';' '\n' | grep ":${album}:" | sed -e 's/^\([0-9]*\).*$/\1/'),\
|
||||
\"blockLevel\": $blockLevel,\
|
||||
\"next\": false,\
|
||||
\"previous\": false,\
|
||||
\"likeCount\": $likeLevel,\
|
||||
\"playCount\": 0,\
|
||||
\"timeAdded\": $(date +%s)000\
|
||||
},"
|
||||
done
|
||||
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/all.pls | wc -l) - 1))\nVersion=2" >>Playlists/all.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/le.pls | wc -l) - 1))\nVersion=2" >>Playlists/le.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/lme.pls | wc -l) - 1))\nVersion=2" >>Playlists/lme.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/me.pls | wc -l) - 1))\nVersion=2" >>Playlists/me.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/mhe.pls | wc -l) - 1))\nVersion=2" >>Playlists/mhe.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/he.pls | wc -l) - 1))\nVersion=2" >>Playlists/he.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/le_lofi.pls | wc -l) - 1))\nVersion=2" >>Playlists/le_lofi.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/lofi.pls | wc -l) - 1))\nVersion=2" >>Playlists/lofi.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/unkown.pls | wc -l) - 1))\nVersion=2" >>Playlists/unkown.pls
|
||||
echo -e "NumberOfEntries=$(($(cat Playlists/dnp.pls | wc -l) - 1))\nVersion=2" >>Playlists/dnp.pls
|
||||
|
||||
|
||||
pls_all="{\"id\": 1, \"name\":\"all\", \"songs\":[$(grep '^file[0-9]' 'Playlists/all.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_le="{\"id\": 2, \"name\":\"le\", \"songs\":[$(grep '^file[0-9]' 'Playlists/le.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_lme="{\"id\": 3, \"name\":\"lme\", \"songs\":[$(grep '^file[0-9]' 'Playlists/lme.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_me="{\"id\": 4, \"name\":\"me\", \"songs\":[$(grep '^file[0-9]' 'Playlists/me.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_mhe="{\"id\": 5, \"name\":\"mhe\", \"songs\":[$(grep '^file[0-9]' 'Playlists/mhe.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_he="{\"id\": 6, \"name\":\"he\", \"songs\":[$(grep '^file[0-9]' 'Playlists/he.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_le_lofi="{\"id\": 7, \"name\":\"le_lofi\",\"songs\":[$(grep '^file[0-9]' 'Playlists/le_lofi.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_lofi="{\"id\": 8, \"name\":\"lofi\", \"songs\":[$(grep '^file[0-9]' 'Playlists/lofi.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_unkown="{\"id\": 9, \"name\":\"unkown\", \"songs\":[$(grep '^file[0-9]' 'Playlists/unkown.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
pls_dnp="{\"id\": 10,\"name\":\"dnp\", \"songs\":[$(grep '^file[0-9]' 'Playlists/dnp.pls' | sed -e 's/^.*=..\(.*\)$/"\/storage\/emulated\/0\/Music\1",/' | tr -d '\n\r' | sed -e 's/,$//')]}"
|
||||
|
||||
all_pls="[$pls_all,$pls_le,$pls_lme,$pls_me,$pls_mhe,$pls_he,$pls_le_lofi,$pls_lofi,$pls_unkown,$pls_dnp]"
|
||||
|
||||
echo "{\"epoch\":$(date +%s000),\"playlists\":$all_pls}" \
|
||||
>Playlists/mucke.json.jinja2.data
|
||||
|
||||
# echo $list_album
|
||||
albums="$(echo $list_album | tr ';' '\n' | sed -e 's/^\(.*\):\(.*\):\(.*\)$/\\"\1\\":{\\"title\\":\\"\2\\",\\"artist\\":\\"\3\\"},/' | tr -d '\n' | sed -e 's/,$//')"
|
||||
artists="$(echo $list_artist | tr ';' '\n' | sed -e 's/^\(.*\):\(.*\)$/\\"\1\\":{\\"name\\":\\"\2\\"},/' | tr -d '\n' | sed -e 's/,$//')"
|
||||
|
||||
echo "{\"epoch\":$(date +%s000),\"songs\":\"$(echo $list_songs | sed -e 's/,$//' -e 's/"/\\"/g')\",\"albums\":\"$albums\",\"artists\":\"$artists\",\"playlists\":$all_pls}" \
|
||||
>Playlists/mucke2.json.jinja2.data
|
||||
|
||||
jinja \
|
||||
--data Playlists/mucke.json.jinja2.data \
|
||||
--format json \
|
||||
--output Playlists/mucke.json \
|
||||
Playlists/mucke.json.jinja2
|
||||
|
||||
jinja \
|
||||
--data Playlists/mucke2.json.jinja2.data \
|
||||
--format json \
|
||||
--output Playlists/mucke2.json \
|
||||
Playlists/mucke2.json.jinja2
|
||||
|
||||
133
private_dot_local/bin/executable_music_import_mucke
Normal file
133
private_dot_local/bin/executable_music_import_mucke
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DATA="$(cat "$1")"
|
||||
|
||||
set -e
|
||||
|
||||
. "$HOME/.local/share/music/common.sh"
|
||||
|
||||
function get_songs_from_playlists() {
|
||||
local data="$1"
|
||||
local song_paths=""
|
||||
|
||||
for playlist in $(echo "$data" | jq -c '.PLAYLISTS[]' | sed -e 's/ /%20;/g')
|
||||
do
|
||||
playlist="$(echo "$playlist" | sed -e 's/%20;/ /g')"
|
||||
|
||||
for song_path in $(echo "$playlist" | jq -c '.SONGS[]' | sed -e 's/ /%20;/g')
|
||||
do
|
||||
local song_path="$(echo "$song_path" | sed -e 's/%20;/ /g' -e 's/^"//' -e 's/"$//' )"
|
||||
if [[ -f "$song_path" ]]
|
||||
then
|
||||
song_paths="$song_paths
|
||||
$song_path"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "$song_paths" | sort | uniq
|
||||
}
|
||||
|
||||
function search_artist_index() {
|
||||
local name="$(echo "$1" | sed -e 's/^"//' -e 's/"$//')"
|
||||
|
||||
for artist in $(echo "$DATA" | jq -c '.ARTISTS' | sed -e 's/^{//' -e 's/}$//' -e 's/},"/}\n"/g' -e 's/ /%20;/g')
|
||||
do
|
||||
artist="$( echo "$artist" | sed -e 's/%20;/ /g' )"
|
||||
|
||||
local artist_name="$(echo "$artist" | sed -e 's/^.*"\([^"]*\)"}$/\1/')"
|
||||
if [[ "$name" == "$artist_name" ]]
|
||||
then
|
||||
echo "$artist" | sed -e 's/^"\([0-9]*\)".*$/\1/'
|
||||
return
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function search_album_index() {
|
||||
local name="$1"
|
||||
local artist="$2"
|
||||
|
||||
for album in $(echo "$DATA" | jq -c '.ALBUMS' | sed -e 's/^{//' -e 's/}$//' -e 's/},"/}\n"/g' -e 's/ /%20;/g')
|
||||
do
|
||||
album="$( echo "{$album}" | sed -e 's/%20;/ /g' )"
|
||||
|
||||
local album_name="$(echo "$album" | jq -c '.[].title' || error_here)"
|
||||
if [[ "$name" == "$album_name" ]]
|
||||
then
|
||||
local index="$(echo "$album" | jq -c 'keys[0]' | tr -dc '0-9')"
|
||||
echo "$(echo "$album" | jq -c '.[]' || error_here) {\"index\":$index}" | jq -c -s add || error_here
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo "{\"title\":$name,\"artist\":$artist,\"index\":-1}"
|
||||
}
|
||||
|
||||
song_db_old=""
|
||||
song_db_new=""
|
||||
|
||||
song_paths="$(echo "$DATA" | jq -c '.SONGS | keys | @csv' | sed -e 's/^"\\\"//' -e 's/\\\""$//')"
|
||||
for mucke_path in $(echo "$song_paths" | sed -e 's/\\\",\\\"/\n/g' -e 's/ /%20;/g' | grep -v 'Movies/Dadi')
|
||||
do
|
||||
mucke_path="$(echo "$mucke_path" | sed -e 's/%20;/ /g')"
|
||||
song_path="$MUSIC_DIR/$(echo "$mucke_path" | sed -e 's|^/storage/emulated/0/Music/||')"
|
||||
|
||||
|
||||
song_info="$(music_get_song_info_from_file "$song_path" || echo)"
|
||||
if [[ "$(echo "$song_info" | head -c1)" != "{" ]]
|
||||
then
|
||||
echo "$song_info"
|
||||
exit 1
|
||||
fi
|
||||
song_info="$(music_process_genre "$song_info")"
|
||||
|
||||
artist_name="$(echo "$song_info" | jq -c '.artist' || error_here)"
|
||||
artistId="-1"
|
||||
artist=""
|
||||
if [[ "$artist_name" == "\"\"" || "$artist_name" == "" ]]
|
||||
then
|
||||
artist="{\"artist\":\"\",\"index\":-1}"
|
||||
else
|
||||
artistId="$(search_artist_index "$artist_name")"
|
||||
artist="{\"artist\":$artist_name,\"index\":$artistId}"
|
||||
fi
|
||||
|
||||
album="$(echo "$song_info" | jq -c '.album' || error_here)"
|
||||
album_artist="$artist_name"
|
||||
if [[ "$album" == "\"\"" || "$album" == "" ]]
|
||||
then
|
||||
album="{\"title\":\"\",\"artist\":$artist_name,\"index\":-1}"
|
||||
else
|
||||
album="$(search_album_index "$album" "$artist_name")"
|
||||
album_artist="$(echo "$album" | jq -c '.artist' || error_here)"
|
||||
fi
|
||||
|
||||
song_info="$(echo "$song_info {\"artist\":$artist,\"album\":$album}" | jq -c -s add || error_here)"
|
||||
song_db_old="$song_db_old,$(echo "$song_info" | jq '.path.mpd' || error_here):$song_info"
|
||||
|
||||
mucke_song="$(echo "$DATA" | jq -c ".SONGS.\"$mucke_path\"" || error_here)"
|
||||
mucke_song="$(echo "$mucke_song" | jq -c ". | {\"title\":.title,\"album\":{\"title\":.album,\"artist\":$album_artist,\"index\":.albumId},\"artist\":{\"artist\":.artist,\"index\":$artistId},\"blockLevel\":.blockLevel,\"likeLevel\":.likeCount}" || error_here)"
|
||||
|
||||
new_info="$(echo "$song_info $mucke_song" | jq -c -s add || error_here)"
|
||||
song_db_new="$song_db_new,$(echo "$new_info" | jq '.path.mpd' || error_here):$new_info"
|
||||
|
||||
tmp_old="$(mktemp)"
|
||||
# echo "song_info: '$song_info'"
|
||||
echo "$song_info" | jq >"$tmp_old" || error_here
|
||||
tmp_new="$(mktemp)"
|
||||
# echo "new_info: '$new_info'"
|
||||
echo "$new_info" | jq >"$tmp_new" || error_here
|
||||
|
||||
echo "$song_path"
|
||||
diff "$tmp_old" "$tmp_new" &>/dev/null || {
|
||||
diff "$tmp_old" "$tmp_new" || echo
|
||||
echo
|
||||
}
|
||||
rm "$tmp_old" "$tmp_new"
|
||||
done
|
||||
|
||||
echo "{$(echo "$song_db_old" | tail -c+2)}" | jq >"$HOME/.local/share/music/songs.json" \
|
||||
|| echo "{$(echo "$song_db_old" | tail -c+2)}" >"$HOME/.local/share/music/songs.json"
|
||||
echo "{$(echo "$song_db_new" | tail -c+2)}" | jq >"$HOME/.local/share/music/songs_new.json" \
|
||||
|| echo "{$(echo "$song_db_new" | tail -c+2)}" >"$HOME/.local/share/music/songs_new.json"
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function update_remote() {
|
||||
local repo="$1"
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PLAYLIST="$1"
|
||||
COUNT="$2"
|
||||
|
||||
set -e
|
||||
|
||||
SONGS="$(find $HOME/Music -type f)"
|
||||
SONG_COUNT="$(echo "$SONGS" | wc -l)"
|
||||
PLAYLIST_DIR="$HOME/Music/Playlists"
|
||||
|
||||
function rand_num() {
|
||||
cat /dev/urandom | tr -dc '0-9' | head -c 10 | sed -e 's/^0*//'
|
||||
}
|
||||
|
||||
function pick_song() {
|
||||
num=$(( 1 + $RANDOM % $SONG_COUNT ))
|
||||
echo "$SONGS" | sed "${num}q;d"
|
||||
playlist="$1"
|
||||
|
||||
playlist_path="$PLAYLIST_DIR/$playlist.pls"
|
||||
if [[ ! -f "$playlist_path" ]]
|
||||
then
|
||||
echo "error: playlist $playlist not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
songs="$(cat "$playlist_path" | grep '^file' | sed -e 's|^[^=]*=\.\./||')"
|
||||
|
||||
num=$(( 1 + $(rand_num) % $(echo "$songs" | wc -l) ))
|
||||
song="$(echo "$songs" | sed "${num}q;d")"
|
||||
echo "$(dirname "$PLAYLIST_DIR")/$song"
|
||||
}
|
||||
|
||||
function get_flags() {
|
||||
@@ -24,30 +40,6 @@ function get_flags() {
|
||||
echo $genre
|
||||
}
|
||||
|
||||
function in_playlist() {
|
||||
flags="$1"
|
||||
playlist="$2"
|
||||
|
||||
playlists="
|
||||
ALL:(HE|ME|LE)
|
||||
HE:HE
|
||||
MHE:(ME|HE)
|
||||
ME:ME
|
||||
LME:(LE|ME)
|
||||
LE:LE
|
||||
LOFI:LOFI
|
||||
LE_LOFI:(LE|LOFI)
|
||||
"
|
||||
query="$(echo "$playlists" | grep --ignore-case " ${playlist}:" | sed 's/^.*://')"
|
||||
|
||||
if [[ "$(echo "$flags" | grep -E --no-ignore-case "$query")" != "" ]]
|
||||
then
|
||||
echo true
|
||||
else
|
||||
echo false
|
||||
fi
|
||||
}
|
||||
|
||||
function get_like_level() {
|
||||
flags="$1"
|
||||
|
||||
@@ -55,17 +47,18 @@ function get_like_level() {
|
||||
if [[ "$level" == "$(echo "$level" | tr -dc '0-3')" ]]
|
||||
then
|
||||
echo $level
|
||||
else
|
||||
echo 2 # default like level
|
||||
fi
|
||||
}
|
||||
|
||||
function shuffle() {
|
||||
playlist="$1"
|
||||
|
||||
song="$(pick_song)"
|
||||
song="$(pick_song "$playlist")"
|
||||
flags="$(get_flags "$song")"
|
||||
in_list=$(in_playlist "$flags" "$playlist")
|
||||
like=$(get_like_level "$flags")
|
||||
like_min=$(( 1 + $RANDOM % 3 ))
|
||||
like_min=$(( 1 + $(rand_num) % 3 ))
|
||||
|
||||
if [[ "$in_list" == "false" || "$like" -lt "$like_min" ]]
|
||||
then
|
||||
@@ -77,5 +70,22 @@ function shuffle() {
|
||||
fi
|
||||
}
|
||||
|
||||
echo "$(shuffle $PLAYLIST)"
|
||||
if [[ -z "$PLAYLIST" ]]
|
||||
then
|
||||
PLAYLIST=all
|
||||
fi
|
||||
|
||||
# pick_song "$PLAYLIST"
|
||||
|
||||
if [[ -z "$COUNT" ]]
|
||||
then
|
||||
echo "add one song to que from $PLAYLIST"
|
||||
echo "$(shuffle $PLAYLIST)"
|
||||
else
|
||||
echo "add $COUNT songs to que from $PLAYLIST"
|
||||
for i in $(seq 1 $COUNT)
|
||||
do
|
||||
echo "$(shuffle $PLAYLIST)"
|
||||
# echo $i
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rclone sync pdrive: "/mnt/backup/proton/" --verbose --progress \
|
||||
--filter-from "$HOME/.config/rclone/bisync_backup.filter" $*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rclone bisync "$HOME/Documents" pdrive:Documents --verbose --progress \
|
||||
--filter-from "$HOME/.config/rclone/bisync_documents.filter" $*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rclone bisync "$HOME" pdrive: --verbose --progress \
|
||||
--filter-from "$HOME/.config/rclone/bisync_home.filter" $*
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rclone bisync "$HOME/Music" pdrive:Music --verbose --progress $*
|
||||
|
||||
84
private_dot_local/share/music/common.sh
Normal file
84
private_dot_local/share/music/common.sh
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
MUSIC_DIR="$HOME/Music"
|
||||
|
||||
function music_get_song_info_from_file() {
|
||||
local path="$1"
|
||||
|
||||
local mpd_path="$path"
|
||||
if [[ ! -f "$path" && -f "$MUSIC_DIR/$path" ]]
|
||||
then
|
||||
path="$MUSIC_DIR/$path"
|
||||
else
|
||||
mpd_path="$(echo "$path" | tail -c+$(( $(echo "$MUSIC_DIR" | wc -c) + 1 )))"
|
||||
fi
|
||||
if [[ ! -f "$path" ]]
|
||||
then
|
||||
echo "ERROR: music_get_song_info_from_file: file not found: $path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$(echo "${path}" | sed -e 's/^.*\.\([^\.]*\)$/\1/')" == "mp3" ]]
|
||||
then
|
||||
local metadata="mp3"
|
||||
local data="$(id3v2 -l "${path}")"
|
||||
local genre="$(echo "$data" | grep '^TCON' | sed -e 's/^.*: //' -e 's/ ([0-9]*)$//')"
|
||||
local artist="$(echo "$data" | grep '^TPE2' | sed -e 's/^.*: //')"
|
||||
local album="$(echo "$data" | grep '^TALB' | sed -e 's/^.*: //')"
|
||||
local title="$(echo "$data" | grep '^TIT2' | sed -e 's/^.*: //')"
|
||||
else
|
||||
local metadata="flac"
|
||||
local data="$(ffmpeg -i "${path}" 2>&1)"
|
||||
local genre="$(echo "$data" | grep GENRE | sed -e 's/^.*: //')"
|
||||
local artist="$(echo "$data" | grep ARTIST | sed -e 's/^.*: //')"
|
||||
local album="$(echo "$data" | grep ALBUM | sed -e 's/^.*: //')"
|
||||
local title="$(echo "$data" | grep TITLE | sed -e 's/^.*: //')"
|
||||
fi
|
||||
|
||||
echo "{\"path\":{\"file\":\"$path\",\"mpd\":\"$mpd_path\"},\"title\":\"$title\",\"album\":\"$album\",\"artist\":\"$artist\",\"genre\":\"$genre\"}"
|
||||
}
|
||||
|
||||
function music_process_genre() {
|
||||
local song="$1"
|
||||
|
||||
local genre="$(echo "$song" | jq -c '.genre' || error_here)"
|
||||
|
||||
local likeLevel="2"
|
||||
local blockLevel="0"
|
||||
if [[ "$(echo "$genre" | grep --no-ignore-case 'L[0-3]')" != "" ]]
|
||||
then
|
||||
likeLevel="$(echo "$genre" | grep --no-ignore-case -o 'L[0-3]' | grep -o '[0-3]')"
|
||||
genre="$(echo $genre | sed -e 's/L[0-3]//' -e 's/ / /g' -e 's/^" */"/' -e 's/ *"$/"/')"
|
||||
fi
|
||||
if [[ "$(echo "$genre" | grep --no-ignore-case 'B[0-3]')" != "" ]]
|
||||
then
|
||||
blockLevel="$(echo "$genre" | grep --no-ignore-case -o 'B[0-3]' | grep -o '[0-3]')"
|
||||
genre="$(echo $genre | sed -e 's/B[0-3]//' -e 's/ / /g' -e 's/^" */"/' -e 's/ *"$/"/')"
|
||||
fi
|
||||
|
||||
local playlist="all"
|
||||
if [[ "${genre,,}" == "lofi" ]]
|
||||
then
|
||||
playlist="lofi"
|
||||
elif [[ "$(echo ${genre} | grep --no-ignore-case LE)" != "" ]]
|
||||
then
|
||||
playlist="le"
|
||||
genre="$(echo $genre | sed -e 's/LE//' -e 's/ / /g' -e 's/^" */"/' -e 's/ *"$/"/')"
|
||||
elif [[ "$(echo ${genre} | grep --no-ignore-case ME)" != "" ]]
|
||||
then
|
||||
playlist="me"
|
||||
genre="$(echo $genre | sed -e 's/ME//' -e 's/ / /g' -e 's/^" */"/' -e 's/ *"$/"/')"
|
||||
elif [[ "$(echo ${genre} | grep --no-ignore-case HE)" != "" ]]
|
||||
then
|
||||
playlist="he"
|
||||
genre="$(echo $genre | sed -e 's/HE//' -e 's/ / /g' -e 's/^" */"/' -e 's/ *"$/"/')"
|
||||
elif [[ "$(echo ${genre} | grep --no-ignore-case DNP)" == "" ]]
|
||||
then
|
||||
playlist="dnp"
|
||||
genre="$(echo $genre | sed -e 's/DNP//' -e 's/ / /g' -e 's/^" */"/' -e 's/ *"$/"/')"
|
||||
fi
|
||||
|
||||
echo "$song {\"genre\":$genre,\"blockLevel\":$blockLevel,\"likeLevel\":$likeLevel,\"playlist\":\"$playlist\"}" \
|
||||
| jq -c -s add || error_here
|
||||
}
|
||||
|
||||
|
||||
9034
private_dot_local/share/music/mucke.json.jinja2
Normal file
9034
private_dot_local/share/music/mucke.json.jinja2
Normal file
File diff suppressed because it is too large
Load Diff
39
private_dot_local/share/music/mucke2.json.jinja2
Normal file
39
private_dot_local/share/music/mucke2.json.jinja2
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"APP_VERSION": "1.5.1",
|
||||
"BUILD_NUMBER": "123",
|
||||
"DB_VERSION": 18,
|
||||
"SETTING_ALLOWED_EXTENSIONS": "mp3,flac,wav,ogg,opus",
|
||||
"BLOCKED_FILES": [],
|
||||
"LIBRARY_FOLDERS": [
|
||||
"/storage/emulated/0/Music"
|
||||
],
|
||||
"SONGS": {
|
||||
{{ songs }}
|
||||
},
|
||||
"ALBUMS": {
|
||||
{{ albums }}
|
||||
},
|
||||
"ARTISTS": {
|
||||
{{ artists }}
|
||||
},
|
||||
"SMARTLISTS": [],
|
||||
"PLAYLISTS": [
|
||||
{% for item in playlists -%}
|
||||
{
|
||||
"id": {{ item.id }},
|
||||
"name": "{{ item.name }}",
|
||||
"iconString": "alarm_rounded",
|
||||
"gradientString": "purplelake",
|
||||
"timeCreated": {{ epoch }},
|
||||
"timeChanged": {{ epoch }},
|
||||
"timeLastPlayed": {{ epoch }},
|
||||
"shuffleMode": null,
|
||||
"SONGS": [
|
||||
{% for song in item.songs -%}
|
||||
"{{ song }}"{{ "," if not loop.last }}
|
||||
{%- endfor %}
|
||||
]
|
||||
}{{ "," if not loop.last }}
|
||||
{%- endfor %}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user