Compare commits

...

5 Commits

4 changed files with 22 additions and 7 deletions

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## 1.3
* New property for songs: has_subtitles
* Upgrade dependencies
* Add songs without ass file as pending
* Song folders must have a metadata.json file
## 1.2 ## 1.2
* Get karaoke ass generator from negromate.web * Get karaoke ass generator from negromate.web
@ -9,6 +16,7 @@
* Use configuration file for commands defaults * Use configuration file for commands defaults
## 1.1 ## 1.1
* Start with generic negromate command with entry points for other modules * Start with generic negromate command with entry points for other modules
* Move image generating code to utils * Move image generating code to utils
* Migrate setup to pep517 * Migrate setup to pep517

View File

@ -1,6 +1,6 @@
import logging import logging
VERSION = "1.2" VERSION = "1.3"
logger = logging.getLogger("negromate.songs") logger = logging.getLogger("negromate.songs")

View File

@ -109,11 +109,18 @@ class Song:
self.karaoke_ass = karaoke_ass self.karaoke_ass = karaoke_ass
generate_karaoke_ass(str(karaoke_template_file), str(self.ass), str(karaoke_ass)) generate_karaoke_ass(str(karaoke_template_file), str(self.ass), str(karaoke_ass))
@property
def has_subtitles(self):
return self.ass or self.srt or self.vtt
@property @property
def publish(self): def publish(self):
has_subtitles = self.ass or self.srt or self.vtt return self.video and self.has_subtitles
has_video = self.video
return has_video and has_subtitles @property
def pending(self):
finished = self.ass and self.video
return not finished
def load_songs(root_folder, generate=True, regenerate=False, karaoke_template_file=None): def load_songs(root_folder, generate=True, regenerate=False, karaoke_template_file=None):
@ -122,7 +129,7 @@ def load_songs(root_folder, generate=True, regenerate=False, karaoke_template_fi
for entry in root_folder.iterdir(): for entry in root_folder.iterdir():
if entry.name in ['static', 'playlist', 'home', 'todo']: if entry.name in ['static', 'playlist', 'home', 'todo']:
continue continue
if entry.is_dir(): if entry.is_dir() and (entry / 'metadata.json').exists():
logger.info("building {}".format(entry.name)) logger.info("building {}".format(entry.name))
try: try:
song = Song(entry, root_folder) song = Song(entry, root_folder)
@ -133,7 +140,7 @@ def load_songs(root_folder, generate=True, regenerate=False, karaoke_template_fi
continue continue
if song.publish: if song.publish:
songs.append(song) songs.append(song)
else: if song.pending:
pending_songs.append(song) pending_songs.append(song)
songs.sort(key=lambda a: a.name) songs.sort(key=lambda a: a.name)

View File

@ -25,7 +25,7 @@ install_requires =
importlib_metadata importlib_metadata
webvtt-py webvtt-py
asstosrt ==0.1.6 asstosrt ==0.1.6
srt ==1.6.0 srt ==3.5.2
[options.entry_points] [options.entry_points]
console_scripts = console_scripts =