Compare commits
No commits in common. "1da0668807808055282f75d9604c6f5a1d0c9d63" and "d670f397fc28f83618dc19440f17c50484323883" have entirely different histories.
1da0668807
...
d670f397fc
@ -6,7 +6,6 @@ import tempfile
|
|||||||
from mutagen.flac import FLAC # type: ignore
|
from mutagen.flac import FLAC # type: ignore
|
||||||
from mutagen.mp3 import MP3 # type: ignore
|
from mutagen.mp3 import MP3 # type: ignore
|
||||||
from pydub import effects
|
from pydub import effects
|
||||||
from pydub.utils import mediainfo
|
|
||||||
|
|
||||||
from config import Config
|
from config import Config
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -203,7 +202,6 @@ def normalise_track(path):
|
|||||||
f"File type {ftype} not implemented"
|
f"File type {ftype} not implemented"
|
||||||
)
|
)
|
||||||
|
|
||||||
bitrate = mediainfo(path)['bit_rate']
|
|
||||||
audio = get_audio_segment(path)
|
audio = get_audio_segment(path)
|
||||||
if not audio:
|
if not audio:
|
||||||
return
|
return
|
||||||
@ -223,8 +221,7 @@ def normalise_track(path):
|
|||||||
# Overwrite original file with normalised output
|
# Overwrite original file with normalised output
|
||||||
normalised = effects.normalize(audio)
|
normalised = effects.normalize(audio)
|
||||||
try:
|
try:
|
||||||
normalised.export(path, format=os.path.splitext(path)[1][1:],
|
normalised.export(path, format=os.path.splitext(path)[1][1:])
|
||||||
bitrate=bitrate)
|
|
||||||
# Fix up permssions and ownership
|
# Fix up permssions and ownership
|
||||||
os.chown(path, stats.st_uid, stats.st_gid)
|
os.chown(path, stats.st_uid, stats.st_gid)
|
||||||
os.chmod(path, stats.st_mode)
|
os.chmod(path, stats.st_mode)
|
||||||
|
|||||||
@ -1051,19 +1051,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
track = None
|
track = None
|
||||||
if track_id:
|
if track_id:
|
||||||
track = session.get(Tracks, track_id)
|
track = session.get(Tracks, track_id)
|
||||||
if not track:
|
|
||||||
# We have a track_id but we can't find the track.
|
|
||||||
# Update playlist_row accordingly
|
|
||||||
missing_track = playlist_row.track_id
|
|
||||||
playlist_row.track_id = None
|
|
||||||
if note_text:
|
|
||||||
note_text += f"track_id {missing_track} not found"
|
|
||||||
else:
|
|
||||||
note_text = f"track_id {missing_track} not found"
|
|
||||||
playlist_row.note = note_text
|
|
||||||
session.commit()
|
|
||||||
note_item = QTableWidgetItem(note_text)
|
|
||||||
self.setItem(row, HEADER_NOTES_COLUMN, note_item)
|
|
||||||
|
|
||||||
if track:
|
if track:
|
||||||
# Reset colour in case it was current/next/unplayable
|
# Reset colour in case it was current/next/unplayable
|
||||||
@ -1086,10 +1073,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
# Highlight low bitrates
|
# Highlight low bitrates
|
||||||
if track.bitrate:
|
if track.bitrate:
|
||||||
bitrate_str = str(track.bitrate)
|
|
||||||
bitrate_item = self.item(row, BITRATE)
|
|
||||||
if bitrate_item.text() != bitrate_str:
|
|
||||||
bitrate_item.setText(bitrate_str)
|
|
||||||
if track.bitrate < Config.BITRATE_LOW_THRESHOLD:
|
if track.bitrate < Config.BITRATE_LOW_THRESHOLD:
|
||||||
cell_colour = Config.COLOUR_BITRATE_LOW
|
cell_colour = Config.COLOUR_BITRATE_LOW
|
||||||
elif track.bitrate < Config.BITRATE_OK_THRESHOLD:
|
elif track.bitrate < Config.BITRATE_OK_THRESHOLD:
|
||||||
@ -1178,11 +1161,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
# Does it delimit a section?
|
# Does it delimit a section?
|
||||||
if section_start_plr is not None:
|
if section_start_plr is not None:
|
||||||
if note_text.endswith("-"):
|
if note_text.endswith("-"):
|
||||||
log.debug(
|
|
||||||
"line 1165: "
|
|
||||||
f"self._update_note_text({section_start_plr=},"
|
|
||||||
f"self._get_section_timing_string({section_time=})"
|
|
||||||
)
|
|
||||||
self._update_note_text(
|
self._update_note_text(
|
||||||
section_start_plr,
|
section_start_plr,
|
||||||
self._get_section_timing_string(section_time)
|
self._get_section_timing_string(section_time)
|
||||||
@ -1204,16 +1182,12 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
# Have we had a section start but not end?
|
# Have we had a section start but not end?
|
||||||
if section_start_plr is not None:
|
if section_start_plr is not None:
|
||||||
log.debug(
|
|
||||||
"line 1191: "
|
|
||||||
f"self._update_note_text({section_start_plr=},"
|
|
||||||
f"self._get_section_timing_string({section_time=})"
|
|
||||||
)
|
|
||||||
self._update_note_text(
|
self._update_note_text(
|
||||||
section_start_plr,
|
section_start_plr,
|
||||||
self._get_section_timing_string(section_time, no_end=True)
|
self._get_section_timing_string(section_time, no_end=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#
|
||||||
# # ########## Internally called functions ##########
|
# # ########## Internally called functions ##########
|
||||||
|
|
||||||
def _add_track(self, row: int) -> None:
|
def _add_track(self, row: int) -> None:
|
||||||
@ -1229,11 +1203,14 @@ class PlaylistTab(QTableWidget):
|
|||||||
plr.track_id = track.id
|
plr.track_id = track.id
|
||||||
session.commit()
|
session.commit()
|
||||||
# Update attributes of row
|
# Update attributes of row
|
||||||
self.item(row, USERDATA).setData(self.ROW_TRACK_ID, track.id)
|
self.item(row, columns["userdata"].idx).setData(
|
||||||
self.item(row, START_GAP).setText(str(track.start_gap))
|
self.ROW_TRACK_ID, track.id)
|
||||||
self.item(row, TITLE).setText(str(track.title))
|
self.item(row, columns["start_gap"].idx).setText(
|
||||||
self.item(row, ARTIST).setText(str(track.artist))
|
str(track.start_gap))
|
||||||
self.item(row, DURATION).setText(ms_to_mmss(track.duration))
|
self.item(row, columns["title"].idx).setText(str(track.title))
|
||||||
|
self.item(row, columns["artist"].idx).setText(str(track.artist))
|
||||||
|
self.item(row, columns["duration"].idx).setText(
|
||||||
|
ms_to_mmss(track.duration))
|
||||||
last_playtime = Playdates.last_played(session, track.id)
|
last_playtime = Playdates.last_played(session, track.id)
|
||||||
last_played_str = get_relative_date(last_playtime)
|
last_played_str = get_relative_date(last_playtime)
|
||||||
self.item(row, LASTPLAYED).setText(last_played_str)
|
self.item(row, LASTPLAYED).setText(last_played_str)
|
||||||
@ -1415,10 +1392,7 @@ class PlaylistTab(QTableWidget):
|
|||||||
def _get_note_text_time(text: str) -> Optional[datetime]:
|
def _get_note_text_time(text: str) -> Optional[datetime]:
|
||||||
"""Return time specified as @hh:mm:ss in text"""
|
"""Return time specified as @hh:mm:ss in text"""
|
||||||
|
|
||||||
try:
|
|
||||||
match = start_time_re.search(text)
|
match = start_time_re.search(text)
|
||||||
except TypeError:
|
|
||||||
return None
|
|
||||||
if not match:
|
if not match:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user