Finalize tagging with beets and importing with funkwhale automatically

master
Quentin Duchemin 2021-05-12 18:45:18 +02:00
parent dfe55a71a8
commit 6431cf651e
Signed by: Chosto
GPG Key ID: 0547178FEEDE7D6B
7 changed files with 55 additions and 5 deletions

View File

@ -18,3 +18,7 @@ traefik_network: proxy
domain_name: chosto.me
letsencrypt_email: quentinduchemin@tuta.io
# When importing to Funkwhale, you must choose a library
# Create a library, get the ID in URL and put it there
funkwhale_import_library_id: 3e772648-0ce1-4dc1-be59-39e8e6f409d6

View File

@ -2,7 +2,6 @@
- hosts: all
become: yes
tasks:
tags: requirements
- name: Install and configure Funkwhale, deezloader and beets
include_role:
name: music

View File

@ -7,6 +7,9 @@
mode: 0644
- name: Download required albums
# So that files are written with base user perms
become: yes
become_user: "{{ base_user_name }}"
shell:
cmd: "deez-dw.py --recursive_download True --recursive_quality True --output {{ deezloader_songs_path }} --not_gui False --link {{ item }}"
chdir: "{{ deezloader_folder_path }}"

View File

@ -6,6 +6,8 @@
loop:
- deezloader
- beets
- pexpect
- pylast
- name: Create deezloader and beets directories
file:

View File

@ -2,3 +2,34 @@
template:
src: beets_config.yaml.j2
dest: "{{ beets_config_folder }}/config.yaml"
owner: "{{ base_user_name }}"
group: "{{ base_user_name }}"
mode: 0644
- name: Make sure logs are writable
file:
path: "{{ beets_log_file }}"
state: touch
owner: "{{ base_user_name }}"
group: "{{ base_user_name }}"
mode: 0644
- name: Tag music (auto-tag when confidence > 80%, use as-is otherwise)
# So that files are written with user perms
become: yes
become_user: "{{ base_user_name }}"
shell:
# Quiet mode = do not ask anything to the user
# Default are in configuration file
cmd: "beet -c {{ beets_config_folder }}/config.yaml import -q {{ deezloader_songs_path }}"
- name: Import music into Funkwhale
shell:
# funkwhale_import_music_directory is the mounted version of tagged
# files at previous step
cmd: "docker-compose run --rm api python manage.py import_files {{ funkwhale_import_library_id }} {{ funkwhale_import_music_directory }} --recursive --noinput --prune"
chdir: "{{ funkwhale_folder_name }}"
- name: Delete files once imported
shell:
cmd: "rm -rf {{ funkwhale_import_music_directory_host }}/*"

View File

@ -3,8 +3,8 @@ threaded: yes
plugins: lyrics ftintitle embedart duplicates fetchart lastgenre acousticbrainz lyrics
match:
# Allow 90% confidence for auto-tagging
strong_rec_thresh: 0.10
# Allow 80% confidence for auto-tagging
strong_rec_thresh: 0.20
max_rec:
media: strong
label: strong
@ -23,6 +23,16 @@ ui:
color: yes
import:
write: yes
# Always move files to Funkwhale import directory
move: yes
log: /var/log/beets.log
# Previous import interrupted, start for the begining
# Should not really change because files are deleted after import
resume: no
# Merge albums if they look the same
duplicate_action: merge
# Use-as-is if no release found (could be then added to MusicBrainz)
# Reasonable because Deezer metadata is good enough in most cases
quiet_fallback: asis
log: {{ beets_log_file }}
# Preferred languages for aliases (in case of foreign artist with another alphabet for example)
languages: fr en

View File

@ -13,3 +13,4 @@ redis_version: 6
deezloader_folder_path: /home/{{ base_user_name }}/deezloader
deezloader_songs_path: "{{ deezloader_folder_path }}/songs"
beets_config_folder: "/home/{{ base_user_name }}/.config/beets"
beets_log_file: "/var/log/beets.log"