Updates for yggdrasil

This commit is contained in:
2025-04-15 13:58:49 -05:00
parent a82bd54091
commit 7962727fb3
10 changed files with 77 additions and 99 deletions

View File

@@ -2,8 +2,9 @@ compile:
@echo Nothing to do
install: clean
rm -Rf yggdrasil-scripts-*
mkdir -p ${pkgdir}/usr/local/bin/
for i in yggdrasil-get yggdrasil-lock yggdrasil-set-music-data yggdrasil-sha256 yggdrasil-sort-shows yggdrasil-unlock; do install -m 0750 -o root -g http $$i ${pkgdir}/usr/local/bin/; done
for i in yggdrasil-*; do install -m 0750 -o root -g http $$i ${pkgdir}/usr/local/bin/; done
mkdir -p ${pkgdir}/usr/lib/systemd/system
for i in *.timer *.service; do install -m 0755 -o root -g root $$i ${pkgdir}/usr/lib/systemd/system; done
@@ -11,8 +12,7 @@ test: compile
@echo Nothing to do
clean:
git clean -fX
git clean -fd
git clean -fdX
diff:
@echo Nothing to do.

View File

@@ -1,4 +1,4 @@
depends=('bash>=4.4')
depends=('bash>=4.4' 'python-mutagen' 'perl-image-exiftool' 'yt-dlp')
makedepends=('make>=4.2')
checkdepends=()
optdepends=()

View File

@@ -2,7 +2,7 @@ This is a collection of scripts we use for managing yggdrasil data.
1. yggdrasil-get: API for pulling data into Yggdrasil.
1. yggdrasil-lock: API for setting permissions safely.
1. yggdrasil-set-music-data: API for updating a music file with the new detected metadata from the path. Assumes `/srv/yggdrasil/Music/$genre/$artist/$album`.
1. yggdrasil-set-music-data: API for updating a music file with the new detected metadata from the path. Assumes `/home/yggdrasil/Music/$genre/$artist/$album`.
1. yggdrasil-sha256: Get a SHA-256 hash of the current library. This is good for checking media changes over time in conjunction with [AniNIX/Aether](/AniNIX/Aether).
1. yggdrasil-sort-shows: Look at `/srv/yggdrasil/new_acquisition` and try to find the right folder in `/srv/yggdrasil/Videos/Shows` to stash it in. Will try to put it under the show name and the season.
1. yggdrasil-sort-shows: Look at `/home/yggdrasil/new_acquisition` and try to find the right folder in `/home/yggdrasil/Videos/Shows` to stash it in. Will try to put it under the show name and the season.
1. yggdrasil-unlock: API for allowing writes to media.

View File

@@ -1,6 +1,6 @@
#!/bin/bash
export YGGDRASIL="/srv/yggdrasil"
export YGGDRASIL="/home/yggdrasil"
option="$1"
path="$2"
newname="$3"
@@ -11,7 +11,7 @@ if [ "$option" == "" ] || [ "$option" == "-h" ] || [ "$option" == "--help" ] ||
echo 'Syntax: yggdrasil-get {dl|yt|mp3|sol|cp|mv} PATH [new file name in $PWD]'
echo "Option:"
echo "-- dl: Use wget"
echo "-- yt: Use youtube-dl"
echo "-- yt: Use yt-dlp"
echo "-- mp3: Use youtube-mp3"
echo "-- sol: Use solarmovie-vodlocker-dl"
echo "-- cp: Copy the file here."
@@ -47,9 +47,9 @@ if [ "$option" == "yt" ]; then
path="$(echo "$path" | cut -f 1 -d '&')"
fi
if [ "$newname" != "" ]; then
youtube-dl -o "$newname" "$path";
yt-dlp -o "$newname" "$path";
else
youtube-dl "$path";
yt-dlp "$path";
fi
fi
if [ "$option" == "mp3" ]; then

View File

@@ -1,5 +1,5 @@
#!/bin/bash
chown -P -R DarkFeather:http /srv/yggdrasil
find -P /srv/yggdrasil/ -type f -exec chmod 0440 {} \;
find -P /srv/yggdrasil/ -type d -exec chmod 0550 {} \;
chmod -R u+w /srv/yggdrasil/new_acquisition
chown -P -R emby:yggdrasil /home/yggdrasil
find -P /home/yggdrasil/ -type f -exec chmod 0440 {} \;
find -P /home/yggdrasil/ -type d -exec chmod 0550 {} \;
chmod -R u+w /home/yggdrasil/new_acquisition

View File

@@ -19,30 +19,21 @@ echo Genre: $pgenre
echo
for i in $@; do
echo Checking "$i"
if [ ! -f "$i" ]; then
echo File doesn\'t exist. $i
continue;
fi
ffartist="$(ffprobe -hide_banner -i $i 2>&1 | grep artist | grep -v 'album_artist' | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' | sed -e 's/*[[:space:]]$//')"
ffalbum="$(ffprobe -hide_banner -i $i 2>&1 | grep album | grep -v 'album_artist' | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' | sed -e 's/*[[:space:]]$//')"
ffgenre="$(ffprobe -hide_banner -i $i 2>&1 | grep genre | head -n 1 | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' | sed -e 's/*[[:space:]]$//')"
echo For \[$i\]...
fartist="$(exiftool -Artist "$i" | sed 's/^Artist\s\+:\s\+//')"
falbum="$(exiftool -Album "$i" | sed 's/^Album\s\+:\s\+//')"
fgenre="$(exiftool -Genre "$i" | sed 's/^Genre\s\+:\s\+//')"
unset tags
echo Found artist \[$ffartist\]
if [ "$partist" != "$ffartist" ]; then
export tags=$tags" -metadata artist=\"$partist\""
if [ "$partist" != "$fartist" ] || [ "$falbum" != "$palbum" ] || [ "$fgenre" != "$pgenre" ]; then
echo Found artist \[$fartist\]
echo Found album \[$falbum\]
echo Found genre \[$fgenre\]
echo Updating...
mid3v2 -a "$partist" -A "$palbum" -g "$pgenre" "$i" &>/dev/null
echo
fi
echo Found album \[$ffalbum\]
if [ "$ffalbum" != "$palbum" ]; then
export tags=$tags" -metadata album=\"$palbum\""
fi
echo Found genre \[$ffgenre\]
if [ "$ffgenre" != "$pgenre" ]; then
export tags=$tags" -metadata genre=\"$pgenre\""
fi
if [ "$tags" != "" ]; then
bash -c "ffmpeg -hide_banner -i \"$i\"$tags \"$i.ffmpeg.mp3\""
mv "$i.ffmpeg.mp3" "$i"
fi
echo
done

View File

@@ -1,26 +0,0 @@
#!/bin/bash
set -x
basedir="/srv/yggdrasil"
shafile="$basedir""/library.sha256"
option="$1"
if [ "$option" == "-h" ] || [ "$option" == "--help" ]; then
echo Usage: $0 '[verify]'
exit 1
fi
if [[ "$option" != "verify" ]]; then
chmod u+w "$basedir"
touch "$shafile"
chmod u+w "$shafile"
find "$basedir" -type f -exec sha256sum {} \; > "$shafile"
chmod u-w "$basedir" "$shafile"
exit 0;
else
echo "These files have problems:"
sha256sum -c "$shafile";
exit $?;
fi

View File

@@ -1,10 +1,10 @@
#!/bin/bash
baseDir="/srv/yggdrasil/Videos/Shows"
baseDir="/home/yggdrasil/Videos/Shows"
# Helptext
function usage() {
echo Sort files from /srv/yggdrasil/new_acquisition into appropriate show directories.
echo Sort files from /home/yggdrasil/new_acquisition into appropriate show directories.
echo
echo Usage: $0 '[ -h ] [ -f fileToUse ] [ -c ] [ -n ] [ -q ] [ -v ]'
echo ' -c: Create sample sort file'
@@ -21,7 +21,7 @@ function HandleFile() {
file="$1"
# Sort out file metadata
dirtyshowname="$(echo "$file" | sed 's/.[Ss][0-9].[Ee][0-9].*$//')"
showname="$(ls -1 "$baseDir" | grep -iE "$dirtyshowname")"
showname="$(ls -1 "$baseDir" | grep -E -i "$dirtyshowname")"
epinfo="$(echo "$file" | sed "s/^${dirtyshowname}.//" | head -c 6)"
season="$(echo "$epinfo" | head -c 3 | tail -c 2)"
episode="$(echo -n "$epinfo" | tail -c 2)"
@@ -57,7 +57,7 @@ while getopts 'b:cf:hnqv' OPTION; do
esac
done
cd /srv/yggdrasil/new_acquisition
cd /home/yggdrasil/new_acquisition
echo INFO Unlocking filestore
if [ `whoami` != "root" ]; then yggdrasil-unlock; fi

View File

@@ -1,2 +1,2 @@
#!/bin/bash
find -P /srv/yggdrasil -type d -exec chmod u+w {} \;
find -P /home/yggdrasil -type d -exec chmod g+w {} \;

View File

@@ -1,39 +1,52 @@
---
- name: Yggdrasil packages
become: yes
package:
name:
- emby-server
- perl-image-exiftool
- ffmpeg
- name: Yggdrasil packages
become: true
ansible.builtin.package:
name:
- emby-server
- ffmpeg
- yggdrasil-scripts # Sub dependencies included in the PKGBUILD
- name: Yggdrasil directories
become: yes
file:
path: "{{ item }}"
state: directory
owner: http
group: http
mode: 2750
loop:
- /home/yggdrasil
- /home/yggdrasil/Digital_Library
- /home/yggdrasil/Music
- /home/yggdrasil/Videos
- /home/yggdrasil/Videos/Shows
- /home/yggdrasil/Videos/Movies
- /home/yggdrasil/Software
- name: Ensure group
ansible.builtin.group:
name: yggdrasil
state: present
- name: LiveTV channels
command: /bin/bash -c "curl -s https://raw.githubusercontent.com/iptv-org/iptv/master/streams/us.m3u | grep -A 1 -E '{{ iptv_location }}' 2>&1 | grep -vE '^--$'"
register: livetv_channels
- name: Ensure emby user is in group
ansible.builtin.user:
name: emby
append: true
groups: yggdrasil
- name: Write to file
become: yes
copy:
content: "{{ livetv_channels.stdout }}"
dest: /var/lib/emby/local-channels.m3u
owner: emby
group: http
mode: 0640
- name: Yggdrasil directories
become: true
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: emby
group: yggdrasil
mode: "2550"
loop:
- /home/yggdrasil
- /home/yggdrasil/Digital_Library
- /home/yggdrasil/Music
- /home/yggdrasil/Videos
- /home/yggdrasil/Videos/Shows
- /home/yggdrasil/Videos/Movies
- /home/yggdrasil/Software
- name: LiveTV channels
# noqa: no-changed-when
ansible.builtin.command:
cmd: bash -c "curl -s https://raw.githubusercontent.com/iptv-org/iptv/master/streams/us.m3u | grep -A1 -E '{{ iptv_location }}' 2>&1 | grep -vE '^--$' || true"
register: livetv_channels
- name: Write to file
become: true
ansible.builtin.copy:
content: "{{ livetv_channels.stdout }}"
dest: /var/lib/emby/local-channels.m3u
owner: emby
group: yggdrasil
mode: "0640"