diff --git a/cue_to_meta.py b/cue_to_meta.py index 30317e8..9ed276a 100644 --- a/cue_to_meta.py +++ b/cue_to_meta.py @@ -23,16 +23,17 @@ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +import io import re import click -def cue_to_meta(cuefile, metafile): +def cue_to_meta(cuefile: io.StringIO, metafile: io.StringIO) -> None: """Convert CUE to META.""" - title = None - performer = None - timestamp = None + title = "" + performer = "" + timestamp = "" for line in cuefile.readlines(): title_re = re.search(r'^ TITLE "(.*)"$', line) @@ -44,17 +45,18 @@ def cue_to_meta(cuefile, metafile): performer = performer_re[1] if index_re: time_re = re.search(r"^(..):(..):..$", index_re[1]) - timestamp = f"00{time_re[1]}{time_re[2]}" - if title and performer and timestamp: + if time_re: + timestamp = f"00{time_re[1]}{time_re[2]}" + if title != "" and performer != "" and timestamp != "": metafile.write(f"{timestamp}:{performer} - {title}\n") - title = None - performer = None - timestamp = None + title = "" + performer = "" + timestamp = "" @click.command() @click.argument("cuefile", type=click.File("r")) @click.argument("metafile", type=click.File("w")) -def cli(cuefile, metafile): +def cli(cuefile: io.StringIO, metafile: io.StringIO) -> None: """Convert CUEFILE to meta format as METAFILE.""" cue_to_meta(cuefile, metafile) diff --git a/test_cue_to_meta.py b/test_cue_to_meta.py index aa94a48..f4df077 100644 --- a/test_cue_to_meta.py +++ b/test_cue_to_meta.py @@ -26,7 +26,7 @@ import io import cue_to_meta -def test_cue_to_meta(): +def test_cue_to_meta() -> None: """Test CUE to META conversion.""" cue_text = """PERFORMER "mcornick" TITLE "Luv'n Time International"