karaoke-lyrics-processor 0.1.1__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,8 @@ def main():
48
48
  if args.output:
49
49
  output_filename = args.output
50
50
  else:
51
- output_filename = f"{filename_parts[0]} (Lyrics Processed).{filename_parts[1]}"
51
+ base_name = filename_parts[0].replace(" (Lyrics)", "")
52
+ output_filename = f"{base_name} (Lyrics Processed).{filename_parts[1]}"
52
53
 
53
54
  processor = KaraokeLyricsProcessor(
54
55
  log_level=log_level,
@@ -1,6 +1,7 @@
1
1
  import re
2
2
  import logging
3
3
  import pyperclip
4
+ import unicodedata
4
5
 
5
6
 
6
7
  class KaraokeLyricsProcessor:
@@ -87,11 +88,29 @@ class KaraokeLyricsProcessor:
87
88
  self.logger.debug(f"Line is still too long, forcibly splitting at position {forced_split_point}")
88
89
  return forced_split_point
89
90
 
91
+ def replace_non_printable_spaces(self, text):
92
+ """
93
+ Replace non-printable space-like characters, tabs, and other whitespace with regular spaces,
94
+ excluding newline characters.
95
+ """
96
+ self.logger.debug(f"Replacing non-printable spaces in: {text}")
97
+ # Define a pattern for space-like characters, including tabs and other whitespace, but excluding newlines
98
+ space_pattern = r"[^\S\n\r]|\u00A0|\u1680|\u2000-\u200A|\u202F|\u205F|\u3000"
99
+ # Replace matched characters with a regular space
100
+ cleaned_text = re.sub(space_pattern, " ", text)
101
+ # Remove leading/trailing spaces and collapse multiple spaces into one, preserving newlines
102
+ cleaned_text = re.sub(r" +", " ", cleaned_text).strip()
103
+ self.logger.debug(f"Text after replacing non-printable spaces: {cleaned_text}")
104
+ return cleaned_text
105
+
90
106
  def process_line(self, line):
91
107
  """
92
108
  Process a single line to ensure it's within the maximum length,
93
- and handle parentheses.
109
+ handle parentheses, and replace non-printable spaces.
94
110
  """
111
+ # Replace non-printable spaces at the beginning
112
+ line = self.replace_non_printable_spaces(line)
113
+
95
114
  processed_lines = []
96
115
  iteration_count = 0
97
116
  max_iterations = 100 # Failsafe limit
@@ -153,6 +172,9 @@ class KaraokeLyricsProcessor:
153
172
 
154
173
  processed_lyrics_text = "\n".join(lyrics_lines)
155
174
 
175
+ # Final pass to replace any remaining non-printable spaces
176
+ processed_lyrics_text = self.replace_non_printable_spaces(processed_lyrics_text)
177
+
156
178
  self.processed_lyrics_text = processed_lyrics_text
157
179
  pyperclip.copy(processed_lyrics_text)
158
180
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: karaoke-lyrics-processor
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: Process song lyrics to prepare them for karaoke video production, e.g. by splitting long lines
5
5
  Home-page: https://github.com/karaokenerds/karaoke-lyrics-processor
6
6
  License: MIT
@@ -20,6 +20,8 @@ Description-Content-Type: text/markdown
20
20
 
21
21
  # Karaoke Lyrics Processor 🎶 ✍️
22
22
 
23
+ ![PyPI - Version](https://img.shields.io/pypi/v/karaoke-lyrics-processor)
24
+
23
25
  Karaoke Lyrics Processor is a tool to prepare song lyrics for karaoke video production.
24
26
 
25
27
  It processes lyrics by splitting long lines, handling parentheses, and ensuring that each line fits within a specified maximum length.
@@ -0,0 +1,8 @@
1
+ karaoke_lyrics_processor/__init__.py,sha256=rLRkJQi61qkRiNXdlTleE3ahJ1oBKcghYVkz64x7IIg,62
2
+ karaoke_lyrics_processor/cli.py,sha256=84utSfU-AZZU3okHS8tBFSucJ9-59hXJugfMn48oAKQ,2482
3
+ karaoke_lyrics_processor/karaoke_lyrics_processor.py,sha256=3UOEHFU61aZveDMbPDYcIhAwGc6qKeHRLhwHdY9akLM,7813
4
+ karaoke_lyrics_processor-0.2.0.dist-info/LICENSE,sha256=BiPihPDxhxIPEx6yAxVfAljD5Bhm_XG2teCbPEj_m0Y,1069
5
+ karaoke_lyrics_processor-0.2.0.dist-info/METADATA,sha256=6axf30tfSxbLylh6YF_kfVF2B6CytMoVPKYq2qhB8Tc,4164
6
+ karaoke_lyrics_processor-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
+ karaoke_lyrics_processor-0.2.0.dist-info/entry_points.txt,sha256=hjFp6CUxl1p-1WJYfB6TbNcI_DHEnVzX3BXAs4y_0O8,78
8
+ karaoke_lyrics_processor-0.2.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- karaoke_lyrics_processor/__init__.py,sha256=rLRkJQi61qkRiNXdlTleE3ahJ1oBKcghYVkz64x7IIg,62
2
- karaoke_lyrics_processor/cli.py,sha256=yCbmQBTRHvSV0tjRf2WmWmYHXjYzlsPXd_EfZIRYm_c,2427
3
- karaoke_lyrics_processor/karaoke_lyrics_processor.py,sha256=M8CE5l_aIyzjWwiu1lOqFkOkBB7R38JV8oqHFS-wklQ,6615
4
- karaoke_lyrics_processor-0.1.1.dist-info/LICENSE,sha256=BiPihPDxhxIPEx6yAxVfAljD5Bhm_XG2teCbPEj_m0Y,1069
5
- karaoke_lyrics_processor-0.1.1.dist-info/METADATA,sha256=Yi8rovwQ9alrNvFYQeOxvGD5z7v6Lde85hk5sJ_Q1Wc,4089
6
- karaoke_lyrics_processor-0.1.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
- karaoke_lyrics_processor-0.1.1.dist-info/entry_points.txt,sha256=hjFp6CUxl1p-1WJYfB6TbNcI_DHEnVzX3BXAs4y_0O8,78
8
- karaoke_lyrics_processor-0.1.1.dist-info/RECORD,,