I’m on it, mthe script is already starting a non running SK docker container, and is correctly parsing the monhtly and daily folders.
May I ask you to remember me the right sonkong.sh syntax to use to start a fix songs task ?
fyi here is how the script loos like for now
import os
import subprocess
import time
from datetime import datetime
import requests
# Configuration for the folders
HOST_FOLDER = "/mnt/user/MURRAY/Music/Music_dump"
DOCKER_CONTAINER_NAME = "songkong"
DOCKER_FOLDER = "/music/Music_dump"
# Pushover connection information
pushover_user_key = "xxxx"
pushover_api_token = "xxxx"
def send_pushover_notification(message):
log_action("Sending Pushover notification: {}".format(message))
if pushover_user_key and pushover_api_token:
url = "https://api.pushover.net/1/messages.json"
data = {
"token": pushover_api_token,
"user": pushover_user_key,
"message": message
}
response = requests.post(url, data=data)
return response.json()
return None
def log_action(action):
print(action)
with open("action_log.txt", "a") as log_file:
log_file.write("{} - {}\n".format(datetime.now(), action))
def was_folder_processed(folder):
if not os.path.exists("songkong_log.txt"):
return False
with open("songkong_log.txt", "r") as log_file:
logs = log_file.read()
return folder in logs
def start_songkong_docker():
cmd = "docker start {}".format(DOCKER_CONTAINER_NAME)
subprocess.call(cmd.split())
def stop_songkong_docker():
cmd = "docker stop {}".format(DOCKER_CONTAINER_NAME)
subprocess.call(cmd.split())
def run_songkong(relative_path):
# Execute SongKong in Docker
cmd = "docker exec {} /opt/songkong/songkong.sh -m fixsongs {}".format(DOCKER_CONTAINER_NAME, os.path.join(DOCKER_FOLDER, relative_path))
log_action("Executing the command: {}".format(cmd))
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()
# Check if SongKong started the task successfully
if process.returncode == 0:
log_action("SongKong successfully processed folder: {}".format(relative_path))
else:
log_action("SongKong failed to process folder: {}. Error: {}".format(relative_path, error.decode("utf-8")))
send_pushover_notification("SongKong failed to process folder: {}. Check logs for more details.".format(relative_path))
def find_date_folders():
folders = [folder for folder in os.listdir(HOST_FOLDER) if os.path.isdir(os.path.join(HOST_FOLDER, folder))]
folders.sort(key=lambda date: datetime.strptime(date, '%m-%Y') if '-' in date else datetime.strptime('01-' + date, '%d-%m-%Y'))
return folders
if __name__ == "__main__":
target_folders = find_date_folders()
log_action("Target folders identified: {}".format(target_folders))
for target_folder in target_folders:
if not was_folder_processed(target_folder):
start_songkong_docker() # Start SongKong Docker
print("Attempting to run SongKong on folder: {}".format(os.path.join(DOCKER_FOLDER, target_folder)))
run_songkong(target_folder)
with open("songkong_log.txt", "a") as log_file:
log_file.write("Processed folder: {}\n".format(target_folder))
stop_songkong_docker() # Stop SongKong Docker
send_pushover_notification("Script has finished processing folders: {}".format(target_folders))
And here is what I can see in songkong logs :
14/08/2023 09.30.11:CEST:StartPage:setFolderInputField:SEVERE: -- GET:/music/Music_dump
14/08/2023 09.30.11:CEST:CmdRemote:lambda$start$180:SEVERE: >>>>>/foldertree
14/08/2023 09.30.11:CEST:CmdRemote:lambda$start$180:SEVERE: >>>>>/style/fontawesome/webfonts/fa-light-300.woff2
14/08/2023 09.30.11:CEST:CmdRemote:lambda$start$180:SEVERE: >>>>>/style/fontawesome/webfonts/custom-icons.woff2
14/08/2023 09.32.59:CEST:CmdRemote:lambda$start$180:SEVERE: >>>>>/start.task
14/08/2023 09.32.59:CEST:BaseFolderGuesser$FindFile:visitFile:WARNING: BaseFolderGuesser checking:01-Exhaust-A History Of Guerrilla Warfare.flac
14/08/2023 09.32.59:CEST:CmdRemote:lambda$start$180:SEVERE: >>>>>/fixsongs.select_profile
14/08/2023 09.32.59:CEST:CmdRemote:lambda$start$180:SEVERE: >>>>>/fixsongs.select_profile
14/08/2023 09.32.59:CEST:ServerProfile:selectProfile:SEVERE: selectProfile:/songkong/Prefs/songkong_fixsongs4.properties
14/08/2023 09.32.59:CEST:ServerProfile:selectProfile:SEVERE: selectProfileDone
But it gets stuck there it seems… it is running till 10 minutes+ and there is nothing more ingoing in the debug log file.
here is te output of the script:
Target folders identified: ['01-2015', '01-2016', '01-2017', '09-2019', '10-2019', '11-2019', '12-2019', '01-2020', '02-2020', '03-2020', '04-2020', '05-2020', '06-2020', '07-2020', '08-2020', '09-2020', '10-2020', '11-2020', '12-2020', '01-2021', '02-2021', '03-2021', '04-2021', '05-2021', '06-2021', '07-2021', '08-2021', '09-2021', '10-2021', '11-2021', '12-2021', '01-2022', '02-2022', '03-2022', '04-2022', '05-2022', '06-2022', '07-2022', '08-2022', '09-2022', '10-2022', '11-2022', '12-2022', '01-2023', '02-2023', '03-2023', '04-2023', '05-2023']
songkong
Attempting to run SongKong on folder: /music/Music_dump/01-2015
Executing the command: docker exec songkong /opt/songkong/songkong.sh -m fixsongs /music/Music_dump/01-2015
after quite some time, the sk logs will eventually state this
14/08/2023 10.34.21:CEST:WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@64ba3208 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
It is important to say that even running the following command directly from the docker console also seems to “hang” :
/opt/songkong # ./songkong.sh -m /music/Music_dump/03-2023
debuglogfile is:/songkong/Logs/songkong_debug%u-%g.log
userlogfile is:/songkong/Logs/songkong_user%u-%g.log
So there must b something wrong with the syntax or something like that.