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 @echo Nothing to do
install: clean install: clean
rm -Rf yggdrasil-scripts-*
mkdir -p ${pkgdir}/usr/local/bin/ 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 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 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 @echo Nothing to do
clean: clean:
git clean -fX git clean -fdX
git clean -fd
diff: diff:
@echo Nothing to do. @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') makedepends=('make>=4.2')
checkdepends=() checkdepends=()
optdepends=() 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-get: API for pulling data into Yggdrasil.
1. yggdrasil-lock: API for setting permissions safely. 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-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. 1. yggdrasil-unlock: API for allowing writes to media.

View File

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

View File

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

View File

@@ -19,30 +19,21 @@ echo Genre: $pgenre
echo echo
for i in $@; do for i in $@; do
echo Checking "$i"
if [ ! -f "$i" ]; then if [ ! -f "$i" ]; then
echo File doesn\'t exist. $i echo File doesn\'t exist. $i
continue; continue;
fi 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:]]$//')" fartist="$(exiftool -Artist "$i" | sed 's/^Artist\s\+:\s\+//')"
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:]]$//')" falbum="$(exiftool -Album "$i" | sed 's/^Album\s\+:\s\+//')"
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:]]$//')" fgenre="$(exiftool -Genre "$i" | sed 's/^Genre\s\+:\s\+//')"
echo For \[$i\]...
unset tags unset tags
echo Found artist \[$ffartist\] if [ "$partist" != "$fartist" ] || [ "$falbum" != "$palbum" ] || [ "$fgenre" != "$pgenre" ]; then
if [ "$partist" != "$ffartist" ]; then echo Found artist \[$fartist\]
export tags=$tags" -metadata artist=\"$partist\"" echo Found album \[$falbum\]
fi echo Found genre \[$fgenre\]
echo Found album \[$ffalbum\] echo Updating...
if [ "$ffalbum" != "$palbum" ]; then mid3v2 -a "$partist" -A "$palbum" -g "$pgenre" "$i" &>/dev/null
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 echo
fi
done 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 #!/bin/bash
baseDir="/srv/yggdrasil/Videos/Shows" baseDir="/home/yggdrasil/Videos/Shows"
# Helptext # Helptext
function usage() { 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
echo Usage: $0 '[ -h ] [ -f fileToUse ] [ -c ] [ -n ] [ -q ] [ -v ]' echo Usage: $0 '[ -h ] [ -f fileToUse ] [ -c ] [ -n ] [ -q ] [ -v ]'
echo ' -c: Create sample sort file' echo ' -c: Create sample sort file'
@@ -21,7 +21,7 @@ function HandleFile() {
file="$1" file="$1"
# Sort out file metadata # Sort out file metadata
dirtyshowname="$(echo "$file" | sed 's/.[Ss][0-9].[Ee][0-9].*$//')" 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)" epinfo="$(echo "$file" | sed "s/^${dirtyshowname}.//" | head -c 6)"
season="$(echo "$epinfo" | head -c 3 | tail -c 2)" season="$(echo "$epinfo" | head -c 3 | tail -c 2)"
episode="$(echo -n "$epinfo" | tail -c 2)" episode="$(echo -n "$epinfo" | tail -c 2)"
@@ -57,7 +57,7 @@ while getopts 'b:cf:hnqv' OPTION; do
esac esac
done done
cd /srv/yggdrasil/new_acquisition cd /home/yggdrasil/new_acquisition
echo INFO Unlocking filestore echo INFO Unlocking filestore
if [ `whoami` != "root" ]; then yggdrasil-unlock; fi if [ `whoami` != "root" ]; then yggdrasil-unlock; fi

View File

@@ -1,2 +1,2 @@
#!/bin/bash #!/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,21 +1,32 @@
--- ---
- name: Yggdrasil packages - name: Yggdrasil packages
become: yes become: true
package: ansible.builtin.package:
name: name:
- emby-server - emby-server
- perl-image-exiftool
- ffmpeg - ffmpeg
- yggdrasil-scripts # Sub dependencies included in the PKGBUILD
- name: Ensure group
ansible.builtin.group:
name: yggdrasil
state: present
- name: Ensure emby user is in group
ansible.builtin.user:
name: emby
append: true
groups: yggdrasil
- name: Yggdrasil directories - name: Yggdrasil directories
become: yes become: true
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
owner: http owner: emby
group: http group: yggdrasil
mode: 2750 mode: "2550"
loop: loop:
- /home/yggdrasil - /home/yggdrasil
- /home/yggdrasil/Digital_Library - /home/yggdrasil/Digital_Library
@@ -26,14 +37,16 @@
- /home/yggdrasil/Software - /home/yggdrasil/Software
- name: LiveTV channels - 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 '^--$'" # 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 register: livetv_channels
- name: Write to file - name: Write to file
become: yes become: true
copy: ansible.builtin.copy:
content: "{{ livetv_channels.stdout }}" content: "{{ livetv_channels.stdout }}"
dest: /var/lib/emby/local-channels.m3u dest: /var/lib/emby/local-channels.m3u
owner: emby owner: emby
group: http group: yggdrasil
mode: 0640 mode: "0640"