From bb01952895a59bf871d7685c64f00fd7fe7a67b6 Mon Sep 17 00:00:00 2001 From: Mark Cornick Date: Wed, 17 Aug 2022 03:07:32 -0400 Subject: [PATCH] Initial commit --- README.md | 18 +++++++++++++++++ cue_to_meta.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 README.md create mode 100755 cue_to_meta.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..38d5e98 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# cue_to_meta + +Takes the CUE format written by e.g. Mixxx's recording feature, and +converts it to the metadata format expected by aNONradio's "podcast" +system. + +## Usage + +`./cue_to_meta filename.cue` will parse `filename.cue` and write +`filename.meta` in meta format. + +## Bugs + +Assumes the show is one hour or less in length. + +## Author/License + +Mark Cornick under the MIT license. diff --git a/cue_to_meta.py b/cue_to_meta.py new file mode 100755 index 0000000..835c7f0 --- /dev/null +++ b/cue_to_meta.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 + +"""Converts a CUE file to the meta format expected by aNONradio.""" + +# Copyright (c) 2022 Mark Cornick +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import re +import sys + +cue_file = sys.argv[1] +meta_file = re.sub(r"cue$", "meta", cue_file) + +with open(cue_file) as f: + cue = f.readlines() + +title = None +performer = None +timestamp = None + +with open(meta_file, "w") as f: + for line in cue: + title_re = re.search(r'^ TITLE "(.*)"$', line) + performer_re = re.search(r'^ PERFORMER "(.*)"$', line) + index_re = re.search(r"^ INDEX 01 (.*)$", line) + if title_re: + title = title_re[1] + if performer_re: + performer = performer_re[1] + if index_re: + time_re = re.search(r"^(..):(..):..$", index_re[1]) + timestamp = "00{}{}".format(time_re[1], time_re[2]) + if title and performer and timestamp: + f.write("{}:{} - {}\n".format(timestamp, performer, title)) + title = None + performer = None + timestamp = None