karaoke-lyrics-processor 0.4.1__py3-none-any.whl → 0.4.2__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.
@@ -60,11 +60,8 @@ class KaraokeLyricsProcessor:
60
60
  def read_txt_file(self):
61
61
  with codecs.open(self.input_filename, "r", encoding="utf-8") as infile:
62
62
  content = infile.read()
63
- self.logger.debug(f"Raw content read from file: {repr(content)}")
64
63
  lines = content.splitlines()
65
- self.logger.debug(f"Number of lines read: {len(lines)}")
66
- for i, line in enumerate(lines):
67
- self.logger.debug(f"Line {i}: {repr(line)}")
64
+ self.logger.debug(f"Read {len(lines)} lines from {self.input_filename}")
68
65
  return self.clean_text(content).splitlines()
69
66
 
70
67
  def read_doc_file(self):
@@ -78,16 +75,29 @@ class KaraokeLyricsProcessor:
78
75
  return self.clean_text(plain_text).splitlines()
79
76
 
80
77
  def clean_text(self, text):
81
- self.logger.debug(f"Cleaning text: {repr(text)}")
82
- # Remove any non-printable characters except newlines and U+2005 (four-per-em space)
78
+ # Remove any non-printable characters except newlines and U+2005
79
+ original_len = len(text)
83
80
  cleaned = "".join(char for char in text if char.isprintable() or char in ["\n", "\u2005"])
84
- self.logger.debug(f"Text after removing non-printable characters: {repr(cleaned)}")
81
+ if len(cleaned) != original_len:
82
+ self.logger.debug(f"Removed {original_len - len(cleaned)} non-printable characters")
83
+
85
84
  # Replace multiple newlines with a single newline
85
+ newlines_before = cleaned.count("\n")
86
86
  cleaned = re.sub(r"\n{2,}", "\n", cleaned)
87
- self.logger.debug(f"Text after replacing multiple newlines: {repr(cleaned)}")
87
+ newlines_after = cleaned.count("\n")
88
+ if newlines_before != newlines_after:
89
+ self.logger.debug(f"Consolidated {newlines_before - newlines_after} extra newlines")
90
+
88
91
  # Remove leading/trailing whitespace from each line
89
- cleaned = "\n".join(line.strip() for line in cleaned.splitlines())
90
- self.logger.debug(f"Final cleaned text: {repr(cleaned)}")
92
+ lines_before = cleaned.splitlines()
93
+ cleaned = "\n".join(line.strip() for line in lines_before)
94
+ lines_after = cleaned.splitlines()
95
+
96
+ # Count lines that changed due to stripping
97
+ changed_lines = sum(1 for before, after in zip(lines_before, lines_after) if before != after)
98
+ if changed_lines > 0:
99
+ self.logger.debug(f"Stripped whitespace from {changed_lines} lines")
100
+
91
101
  return cleaned
92
102
 
93
103
  def find_best_split_point(self, line):
@@ -147,8 +157,6 @@ class KaraokeLyricsProcessor:
147
157
  Replace non-printable space-like characters, tabs, and other whitespace with regular spaces,
148
158
  excluding newline characters.
149
159
  """
150
- self.logger.debug(f"Replacing non-printable spaces in: {repr(text)}")
151
-
152
160
  # Log each character and its Unicode code point
153
161
  # for i, char in enumerate(text):
154
162
  # self.logger.debug(f"Character at position {i}: {repr(char)} (Unicode: U+{ord(char):04X})")
@@ -159,35 +167,29 @@ class KaraokeLyricsProcessor:
159
167
  # Replace matched characters with a regular space
160
168
  cleaned_text = re.sub(space_pattern, " ", text)
161
169
 
162
- # Log the result of the replacement
163
- self.logger.debug(f"Text after replacing non-printable spaces: {repr(cleaned_text)}")
164
-
165
170
  # Remove leading/trailing spaces and collapse multiple spaces into one, preserving newlines
166
171
  final_text = re.sub(r" +", " ", cleaned_text).strip()
167
172
 
168
- # Log the final result
169
- self.logger.debug(f"Final text after cleaning: {repr(final_text)}")
170
-
171
173
  return final_text
172
174
 
173
175
  def clean_punctuation_spacing(self, text):
174
176
  """
175
177
  Remove unnecessary spaces before punctuation marks.
176
178
  """
177
- self.logger.debug(f"Cleaning punctuation spacing in: {text}")
179
+ self.logger.debug(f"Cleaning punctuation spacing")
178
180
  # Remove space before comma, period, exclamation mark, question mark, colon, and semicolon
179
181
  cleaned_text = re.sub(r"\s+([,\.!?:;])", r"\1", text)
180
- self.logger.debug(f"Text after cleaning punctuation spacing: {cleaned_text}")
182
+
181
183
  return cleaned_text
182
184
 
183
185
  def fix_commas_inside_quotes(self, text):
184
186
  """
185
187
  Move commas inside quotes to after the closing quote.
186
188
  """
187
- self.logger.debug(f"Fixing commas inside quotes in: {text}")
189
+ self.logger.debug(f"Fixing commas inside quotes")
188
190
  # Use regex to find patterns where a comma is inside quotes and move it outside
189
191
  fixed_text = re.sub(r'(".*?)(,)(\s*")', r"\1\3\2", text)
190
- self.logger.debug(f"Text after fixing commas inside quotes: {fixed_text}")
192
+
191
193
  return fixed_text
192
194
 
193
195
  def process_line(self, line):
@@ -307,7 +309,7 @@ class KaraokeLyricsProcessor:
307
309
  processed_lyrics_text = self.clean_punctuation_spacing(processed_lyrics_text)
308
310
 
309
311
  self.processed_lyrics_text = processed_lyrics_text
310
-
312
+
311
313
  # Try to copy to clipboard, but don't fail if it's not available
312
314
  try:
313
315
  pyperclip.copy(processed_lyrics_text)
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: karaoke-lyrics-processor
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Process song lyrics to prepare them for karaoke video production, e.g. by splitting long lines
5
- Home-page: https://github.com/karaokenerds/karaoke-lyrics-processor
6
5
  License: MIT
7
6
  Author: Andrew Beveridge
8
7
  Author-email: andrew@beveridge.uk
@@ -18,6 +17,7 @@ Requires-Dist: pyperclip (>=1.8)
18
17
  Requires-Dist: python-docx (>=1)
19
18
  Requires-Dist: striprtf (>=0.0.27)
20
19
  Project-URL: Documentation, https://github.com/karaokenerds/karaoke-lyrics-processor/blob/main/README.md
20
+ Project-URL: Homepage, https://github.com/karaokenerds/karaoke-lyrics-processor
21
21
  Project-URL: Repository, https://github.com/karaokenerds/karaoke-lyrics-processor
22
22
  Description-Content-Type: text/markdown
23
23
 
@@ -0,0 +1,8 @@
1
+ karaoke_lyrics_processor/__init__.py,sha256=rLRkJQi61qkRiNXdlTleE3ahJ1oBKcghYVkz64x7IIg,62
2
+ karaoke_lyrics_processor/cli.py,sha256=bdtseRI2jcChb1bMr92pc5mpSWpHXh4TSzA2tknbyjU,2522
3
+ karaoke_lyrics_processor/karaoke_lyrics_processor.py,sha256=Yyj9OSwwUPyqYPcMRcaVu-i0-f89Em-LnUqfAbFskOE,13468
4
+ karaoke_lyrics_processor-0.4.2.dist-info/LICENSE,sha256=BiPihPDxhxIPEx6yAxVfAljD5Bhm_XG2teCbPEj_m0Y,1069
5
+ karaoke_lyrics_processor-0.4.2.dist-info/METADATA,sha256=T0DNBQ3lzcZh_kpYsos3Z631ShgXq5apSlJYJ3esBcc,4276
6
+ karaoke_lyrics_processor-0.4.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
7
+ karaoke_lyrics_processor-0.4.2.dist-info/entry_points.txt,sha256=hjFp6CUxl1p-1WJYfB6TbNcI_DHEnVzX3BXAs4y_0O8,78
8
+ karaoke_lyrics_processor-0.4.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.0.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,8 +0,0 @@
1
- karaoke_lyrics_processor/__init__.py,sha256=rLRkJQi61qkRiNXdlTleE3ahJ1oBKcghYVkz64x7IIg,62
2
- karaoke_lyrics_processor/cli.py,sha256=bdtseRI2jcChb1bMr92pc5mpSWpHXh4TSzA2tknbyjU,2522
3
- karaoke_lyrics_processor/karaoke_lyrics_processor.py,sha256=Ew91yh7f0kbBy_nnWGntBClRQ1uxE9brhtWExcRl7t0,13716
4
- karaoke_lyrics_processor-0.4.1.dist-info/LICENSE,sha256=BiPihPDxhxIPEx6yAxVfAljD5Bhm_XG2teCbPEj_m0Y,1069
5
- karaoke_lyrics_processor-0.4.1.dist-info/METADATA,sha256=4Ut0L964ec92IuLlQiZilngjnjMr4dUm2FAIFk5uCLg,4264
6
- karaoke_lyrics_processor-0.4.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
7
- karaoke_lyrics_processor-0.4.1.dist-info/entry_points.txt,sha256=hjFp6CUxl1p-1WJYfB6TbNcI_DHEnVzX3BXAs4y_0O8,78
8
- karaoke_lyrics_processor-0.4.1.dist-info/RECORD,,