From 06b9d383b75b085e94edb126934a5b121d6c7df9 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Wed, 12 Mar 2025 12:42:17 +0100 Subject: [PATCH] * Added app * README --- README.md | 13 ++++++++++- app.py | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 app.py diff --git a/README.md b/README.md index b98aa0f..f98018f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # reaper-regionplaylist2csv -Exports all playlists in SWS's Region Playist to CSV files \ No newline at end of file +Exports all playlists in SWS's Region Playist to CSV files + +## Usage + +* Clone Repositiory in your Reaper project +* Rename project file to 'project.rpp' or change the filename in the script +* Run + +``` Batch +cd reaper-regionplaylist2csv +python ./app.py +``` \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..05b370a --- /dev/null +++ b/app.py @@ -0,0 +1,69 @@ +import os +import re + +def extract(): + result = {} + + working_dir = os.path.dirname(os.path.realpath(__file__)) + rpp_filename = os.path.join(working_dir, '..', r'project.rpp') + + with open(rpp_filename, mode='r', encoding='utf-8') as rpp_file: + rpp_content = rpp_file.readlines() + + for rpp_content_line in rpp_content: + pattern = r'^.*.*$' + if re.match(pattern, rpp_content_line): + is_playlist = False + + if is_playlist: + playlist_item = rpp_content_line.strip() + playlist_item = playlist_item[:-2] + playlist_item = playlist_item[8:] + playlist_item = int(playlist_item) - 24 + + for rpp_content_line2 in rpp_content: + pattern = r'^.*MARKER ' + str(playlist_item) + ' .*".+".*{.*}.*$' # Ouch + if re.match(pattern, rpp_content_line2): + item = rpp_content_line2.strip() + item = item.split('"')[1] + result[playlist_name].append(item) + + pattern = r'^.*' + playlist_name + '.*$' + if re.match(pattern, rpp_content_line): + is_playlist = True + + save2csv(result) + +def save2csv(result): + for playlist in result: + + working_dir = os.path.dirname(os.path.realpath(__file__)) + playlist_file_name = os.path.join(working_dir, playlist + '.csv') + + with open(playlist_file_name, mode='w', encoding="iso-8859-1") as playlist_file: + for item in result[playlist]: + playlist_file.write(item + '\n') + +if __name__ == '__main__': + extract()