karaoke-lyrics-processor 0.1.0__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.
@@ -20,6 +20,14 @@ def main():
20
20
  package_version = pkg_resources.get_distribution("karaoke-lyrics-processor").version
21
21
  parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {package_version}")
22
22
  parser.add_argument("-d", "--debug", action="store_true", help="Enable debug mode, setting log level to DEBUG.")
23
+ parser.add_argument("-o", "--output", type=str, help="Optional: Specify the output filename for the processed lyrics.")
24
+ parser.add_argument(
25
+ "-l",
26
+ "--line_length",
27
+ type=int,
28
+ default=36,
29
+ help="Optional: Specify the maximum line length for the processed lyrics. Default is 36.",
30
+ )
23
31
  parser.add_argument("filename", type=str, help="The path to the file containing the song lyrics to process.")
24
32
 
25
33
  args = parser.parse_args()
@@ -37,10 +45,18 @@ def main():
37
45
  logger.info(f"Karaoke Lyrics processor beginning with input file: {args.filename}")
38
46
 
39
47
  filename_parts = args.filename.rsplit(".", 1)
40
- output_filename = f"{filename_parts[0]} (Lyrics Processed).{filename_parts[1]}"
48
+ if args.output:
49
+ output_filename = args.output
50
+ else:
51
+ base_name = filename_parts[0].replace(" (Lyrics)", "")
52
+ output_filename = f"{base_name} (Lyrics Processed).{filename_parts[1]}"
41
53
 
42
54
  processor = KaraokeLyricsProcessor(
43
- log_level=log_level, log_formatter=log_formatter, input_filename=args.filename, output_filename=output_filename
55
+ log_level=log_level,
56
+ log_formatter=log_formatter,
57
+ input_filename=args.filename,
58
+ output_filename=output_filename,
59
+ max_line_length=args.line_length,
44
60
  )
45
61
  processor.process()
46
62
  processor.write_to_output_file()
@@ -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
 
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.1
2
+ Name: karaoke-lyrics-processor
3
+ Version: 0.2.0
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
+ License: MIT
7
+ Author: Andrew Beveridge
8
+ Author-email: andrew@beveridge.uk
9
+ Requires-Python: >=3.9,<3.13
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Dist: pyperclip (>=1.8)
17
+ Project-URL: Documentation, https://github.com/karaokenerds/karaoke-lyrics-processor/blob/main/README.md
18
+ Project-URL: Repository, https://github.com/karaokenerds/karaoke-lyrics-processor
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Karaoke Lyrics Processor 🎶 ✍️
22
+
23
+ ![PyPI - Version](https://img.shields.io/pypi/v/karaoke-lyrics-processor)
24
+
25
+ Karaoke Lyrics Processor is a tool to prepare song lyrics for karaoke video production.
26
+
27
+ It processes lyrics by splitting long lines, handling parentheses, and ensuring that each line fits within a specified maximum length.
28
+ This tool is especially useful for creating karaoke tracks where timing and line length are crucial for readability.
29
+
30
+ ## Features
31
+
32
+ - **Line Splitting**: Automatically splits long lines of lyrics to ensure they fit within a specified maximum length, making them more readable and suitable for karaoke display.
33
+ - **Intelligent Splitting**: Finds the best split points in lines, considering punctuation and logical breaks in the lyrics.
34
+ - **Parentheses Handling**: Processes lines containing parentheses appropriately, ensuring that the lyrical flow is maintained.
35
+ - **Clipboard Support**: Copies the processed lyrics to the clipboard for easy pasting into video production software or other applications.
36
+ - **Debug Mode**: Offers a debug mode for detailed logging, helping with troubleshooting and fine-tuning the processing.
37
+
38
+ ## Installation
39
+
40
+ To install the Karaoke Lyrics Processor, ensure you have Python 3.9 or newer in your environment.
41
+
42
+ This package is available on PyPI and can be installed using pip. Run the following command in your terminal:
43
+
44
+ ```bash
45
+ pip install karaoke-lyrics-processor
46
+ ```
47
+
48
+ ## Usage (CLI)
49
+
50
+ To process a file containing song lyrics, use the following command:
51
+
52
+ ```bash
53
+ karaoke-lyrics-processor <path_to_lyrics_file>
54
+ ```
55
+
56
+ By default, this will create a new file in your current directory with `(Lyrics Processed)` in the filename containing the processed lyrics.
57
+
58
+ ### Command line options
59
+
60
+ ```bash
61
+ usage: karaoke-lyrics-processor [-h] [-v] [-d] [-o OUTPUT] [-l LINE_LENGTH] filename
62
+
63
+ Process song lyrics to prepare them for karaoke video production, e.g. by splitting long lines
64
+
65
+ positional arguments:
66
+ filename The path to the file containing the song lyrics to process.
67
+
68
+ options:
69
+ -h, --help show this help message and exit
70
+ -v, --version show program's version number and exit
71
+ -d, --debug Enable debug mode, setting log level to DEBUG.
72
+ -o OUTPUT, --output OUTPUT Optional: Specify the output filename for the processed lyrics.
73
+ -l LINE_LENGTH, --line_length LINE_LENGTH Optional: Specify the maximum line length for the processed lyrics. Default is 36.
74
+ ```
75
+
76
+ ## Contributing 🤝
77
+
78
+ Contributions are very much welcome! Please fork the repository and submit a pull request with your changes, and I'll try to review, merge and publish promptly!
79
+
80
+ - This project is 100% open-source and free for anyone to use and modify as they wish.
81
+ - If the maintenance workload for this repo somehow becomes too much for me I'll ask for volunteers to share maintainership of the repo, though I don't think that is very likely
82
+
83
+ ## License 📄
84
+
85
+ This project is licensed under the MIT [License](LICENSE).
86
+
87
+ ## Contact 💌
88
+
89
+ For questions or feedback, please raise an issue or reach out to @beveradb ([Andrew Beveridge](mailto:andrew@beveridge.uk)) directly.
90
+
@@ -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,23 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: karaoke-lyrics-processor
3
- Version: 0.1.0
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
- License: MIT
7
- Author: Andrew Beveridge
8
- Author-email: andrew@beveridge.uk
9
- Requires-Python: >=3.9,<3.13
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.9
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Programming Language :: Python :: 3.12
16
- Requires-Dist: pyperclip (>=1.8)
17
- Project-URL: Documentation, https://github.com/karaokenerds/karaoke-lyrics-processor/blob/main/README.md
18
- Project-URL: Repository, https://github.com/karaokenerds/karaoke-lyrics-processor
19
- Description-Content-Type: text/markdown
20
-
21
- # karaoke-lyrics-processor
22
- Process song lyrics to prepare them for karaoke video production, e.g. by splitting long lines
23
-
@@ -1,8 +0,0 @@
1
- karaoke_lyrics_processor/__init__.py,sha256=rLRkJQi61qkRiNXdlTleE3ahJ1oBKcghYVkz64x7IIg,62
2
- karaoke_lyrics_processor/cli.py,sha256=ZBIZsZoxjofJJljIzLn0vtQpTt3nQ0x2CMe5QLDIEtY,1957
3
- karaoke_lyrics_processor/karaoke_lyrics_processor.py,sha256=M8CE5l_aIyzjWwiu1lOqFkOkBB7R38JV8oqHFS-wklQ,6615
4
- karaoke_lyrics_processor-0.1.0.dist-info/LICENSE,sha256=BiPihPDxhxIPEx6yAxVfAljD5Bhm_XG2teCbPEj_m0Y,1069
5
- karaoke_lyrics_processor-0.1.0.dist-info/METADATA,sha256=UJ5w1ZoOOt1-2MdDN1gOGRtfQwRqOtyr19t6_oeuJIc,1027
6
- karaoke_lyrics_processor-0.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
- karaoke_lyrics_processor-0.1.0.dist-info/entry_points.txt,sha256=hjFp6CUxl1p-1WJYfB6TbNcI_DHEnVzX3BXAs4y_0O8,78
8
- karaoke_lyrics_processor-0.1.0.dist-info/RECORD,,