auto
This commit is contained in:
parent
5c27645666
commit
d579a60917
@ -51,7 +51,6 @@ config.ini db/
|
||||
- ~~editable lyrics window~~
|
||||
- ~~batch metadata changer (red highlight fields that have differing info)~~
|
||||
- ~~playlists~~
|
||||
- playlist m3u files
|
||||
- playlist autoexporting
|
||||
- fix table headers being resized and going out window bounds
|
||||
- delete songs from library (del key || right-click delete)
|
||||
|
||||
14
main.py
14
main.py
@ -188,7 +188,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
||||
lambda: self.player.setPosition(self.playbackSlider.value())
|
||||
) # sliderReleased works better than sliderMoved
|
||||
self.volumeSlider.sliderMoved[int].connect(lambda: self.volume_changed())
|
||||
self.speedSlider.sliderReleased.connect(
|
||||
self.speedSlider.sliderMoved.connect(
|
||||
lambda: self.speed_changed(self.speedSlider.value())
|
||||
)
|
||||
self.playButton.clicked.connect(self.on_play_clicked) # Click to play/pause
|
||||
@ -448,7 +448,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
||||
self.playButton.setText("⏸️")
|
||||
else:
|
||||
self.play_audio_file()
|
||||
self.playButton.setText("⏸️")
|
||||
self.playButton.setText("👽")
|
||||
|
||||
def on_previous_clicked(self) -> None:
|
||||
""""""
|
||||
@ -562,17 +562,17 @@ if __name__ == "__main__":
|
||||
Path(user_config_dir(appname="musicpom", appauthor="billypom")) / "config.ini"
|
||||
)
|
||||
cfg_path = str(Path(user_config_dir(appname="musicpom", appauthor="billypom")))
|
||||
debug(f'config file: {cfg_file}')
|
||||
debug(f'config path: {cfg_path}')
|
||||
debug(f"config file: {cfg_file}")
|
||||
debug(f"config path: {cfg_path}")
|
||||
|
||||
# If config path doesn't exist, create it
|
||||
if not os.path.exists(cfg_path):
|
||||
os.makedirs(cfg_path)
|
||||
# If the config file doesn't exist, create it from the sample config
|
||||
if not os.path.exists(cfg_file):
|
||||
debug('copying sample config')
|
||||
debug("copying sample config")
|
||||
# Create config file from sample
|
||||
run(["cp", "sample_config.ini", cfg_file])
|
||||
run(["cp", "./sample_config.ini", cfg_file])
|
||||
config = ConfigParser()
|
||||
config.read(cfg_file)
|
||||
db_filepath: str = config.get("db", "database")
|
||||
@ -580,7 +580,7 @@ if __name__ == "__main__":
|
||||
# If the database location isnt set at the config location, move it
|
||||
if not db_filepath.startswith(cfg_path):
|
||||
new_path = f"{cfg_path}/{db_filepath}"
|
||||
debug(f'setting new db-database path: {new_path}')
|
||||
debug(f"setting new db-database path: {new_path}")
|
||||
config["db"]["database"] = new_path
|
||||
# Save the config
|
||||
with open(cfg_file, "w") as configfile:
|
||||
|
||||
@ -1,38 +1,46 @@
|
||||
import DBA
|
||||
import logging
|
||||
import os
|
||||
from logging import debug
|
||||
from utils import get_id3_tags, id3_timestamp_to_datetime
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from configparser import ConfigParser
|
||||
from pathlib import Path
|
||||
from appdirs import user_config_dir
|
||||
import platform
|
||||
|
||||
|
||||
def add_files_to_library(files, progress_callback=None):
|
||||
"""
|
||||
Adds audio file(s) to the sqllite db
|
||||
Args:
|
||||
files: list() of fully qualified paths to audio file(s)
|
||||
progress_callback: emit data for user feedback
|
||||
Returns:
|
||||
True on success, else False
|
||||
"""
|
||||
config = ConfigParser()
|
||||
cfg_file = (
|
||||
Path(user_config_dir(appname="musicpom", appauthor="billypom")) / "config.ini"
|
||||
)
|
||||
config.read(cfg_file)
|
||||
|
||||
|
||||
def add_files_to_library(files, progress_callback=None):
|
||||
"""Adds audio file(s) to the sqllite db
|
||||
files = list() of fully qualified paths to audio file(s)
|
||||
Returns a list of dictionaries of metadata
|
||||
"""
|
||||
logging.info("started function")
|
||||
if not files:
|
||||
return []
|
||||
return False
|
||||
extensions = config.get("settings", "extensions").split(",")
|
||||
insert_data = [] # To store data for batch insert
|
||||
for filepath in files:
|
||||
if any(filepath.lower().endswith(ext) for ext in extensions):
|
||||
if progress_callback:
|
||||
progress_callback.emit(filepath)
|
||||
# if "microsoft-standard" in platform.uname().release:
|
||||
# filename = filepath.split(r"\\")[-1]
|
||||
# filepath = os.path.join(filepath)
|
||||
# else:
|
||||
filename = filepath.split("/")[-1]
|
||||
audio = get_id3_tags(filepath)
|
||||
|
||||
try:
|
||||
title = audio["TIT2"].text[0]
|
||||
except KeyError as e:
|
||||
except KeyError:
|
||||
title = filename
|
||||
try:
|
||||
artist = audio["TPE1"].text[0]
|
||||
@ -75,7 +83,7 @@ def add_files_to_library(files, progress_callback=None):
|
||||
)
|
||||
# Check if batch size is reached
|
||||
if len(insert_data) >= 1000:
|
||||
logging.info(f"inserting a LOT of songs: {len(insert_data)}")
|
||||
debug(f"inserting a LOT of songs: {len(insert_data)}")
|
||||
with DBA.DBAccess() as db:
|
||||
db.executemany(
|
||||
"INSERT OR IGNORE INTO song (filepath, title, album, artist, track_number, genre, codec, album_date, bitrate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
@ -86,9 +94,9 @@ def add_files_to_library(files, progress_callback=None):
|
||||
# continue adding files if we havent reached big length
|
||||
continue
|
||||
# Insert any remaining data
|
||||
logging.info("i check for insert data")
|
||||
debug("i check for insert data")
|
||||
if insert_data:
|
||||
logging.info(f"inserting some songs: {len(insert_data)}")
|
||||
debug(f"inserting some songs: {len(insert_data)}")
|
||||
with DBA.DBAccess() as db:
|
||||
db.executemany(
|
||||
"INSERT OR IGNORE INTO song (filepath, title, album, artist, track_number, genre, codec, album_date, bitrate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
|
||||
@ -2,12 +2,11 @@
|
||||
# https://github.com/ravenkls/MilkPlayer/blob/master/audio/fft_analyser.py
|
||||
|
||||
import time
|
||||
import os
|
||||
from PyQt5 import QtCore
|
||||
from pydub import AudioSegment
|
||||
import numpy as np
|
||||
from scipy.ndimage.filters import gaussian_filter1d
|
||||
from logging import info
|
||||
from logging import debug
|
||||
|
||||
|
||||
class FFTAnalyser(QtCore.QThread):
|
||||
@ -66,9 +65,9 @@ class FFTAnalyser(QtCore.QThread):
|
||||
if not data.size:
|
||||
return
|
||||
|
||||
for n, f in enumerate(np.arange(0, 1, point_range), start=1):
|
||||
for i, freq in enumerate(np.arange(0, 1, point_range), start=1):
|
||||
# get the amps which are in between the frequency range
|
||||
amps = data[(f - point_range < data[:, 0]) & (data[:, 0] < f)]
|
||||
amps = data[(freq - point_range < data[:, 0]) & (data[:, 0] < freq)]
|
||||
if not amps.size:
|
||||
point_samples.append(0)
|
||||
else:
|
||||
@ -76,7 +75,7 @@ class FFTAnalyser(QtCore.QThread):
|
||||
amps.max()
|
||||
* (
|
||||
(1 + self.sensitivity / 10 + (self.sensitivity - 1) / 10)
|
||||
** (n / 50)
|
||||
** (i / 50)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user