Function for idv3 and bugfix

This commit is contained in:
2025-01-08 11:34:40 +01:00
parent 0f596cbdba
commit 85d276f2d4
2 changed files with 43 additions and 0 deletions
+36
View File
@@ -2,6 +2,42 @@
"""This module contains utility scripts used by musi radiostation Conjurer""" """This module contains utility scripts used by musi radiostation Conjurer"""
import time import time
import re import re
import os
from mutagen.easyid3 import EasyID3
from mutagen.mp3 import MP3
def update_metadata(base_folder):
for root, _, files in os.walk(base_folder):
for file in files:
if file.endswith('.mp3'):
full_path = os.path.join(root, file)
try:
print(f"Processing {full_path}")
# Parse metadata from the filename or path
# For example, assume filenames are in the format "Artist - Title.mp3"
filename = os.path.splitext(file)[0]
parts = filename.split(' - ')
if len(parts) == 2:
artist, title = parts
else:
artist = 'Unknown Artist'
title = filename
# Load the MP3 file
audio = MP3(full_path, ID3=EasyID3)
# Update metadata
audio['title'] = title
audio['artist'] = artist
# Save changes
audio.save()
print(f"Updated metadata: Artist = {artist}, Title = {title}")
except Exception as e:
print(f"Error processing {file}: {e}")
base_folder = 'path/to/your/folder' # Update with the path to your folder
#update_metadata(base_folder)
NAME = "/home/pi/Conjurer/persistence.log" NAME = "/home/pi/Conjurer/persistence.log"
+7
View File
@@ -1,4 +1,7 @@
import logging
# define an asynchronous generator # define an asynchronous generator
LOGGER = logging.getLogger("discord")
async def async_iterator_generator(range_of_iterable): async def async_iterator_generator(range_of_iterable):
""" """
Generate asynchronouse iterator. Generate asynchronouse iterator.
@@ -87,8 +90,10 @@ async def get_stats(client, ctx, history_limit):
async def discord_friendly_reply(ctx, message_content, file=None): async def discord_friendly_reply(ctx, message_content, file=None):
if len(message_content) < 999: if len(message_content) < 999:
LOGGER.info("Wiadomosci ponizej 999 znakow")
await ctx.reply(message_content) await ctx.reply(message_content)
else: else:
LOGGER.info("Wiadomosci powyzej 999 znakow")
while len(message_content) > 999: while len(message_content) > 999:
await ctx.reply(message_content[:999]) await ctx.reply(message_content[:999])
message_content = message_content[999:] message_content = message_content[999:]
@@ -97,8 +102,10 @@ async def discord_friendly_reply(ctx, message_content, file=None):
async def discord_friendly_send(ctx, message_content, file=None): async def discord_friendly_send(ctx, message_content, file=None):
if len(message_content) < 999: if len(message_content) < 999:
LOGGER.info("Wiadomosci ponizej 999 znakow")
await ctx.send(message_content) await ctx.send(message_content)
else: else:
LOGGER.info("Wiadomosci powyzej 999 znakow")
while len(message_content) > 999: while len(message_content) > 999:
await ctx.send(message_content[:999]) await ctx.send(message_content[:999])
message_content = message_content[999:] message_content = message_content[999:]