* Added app
* README
This commit is contained in:
parent
ab98a30101
commit
06b9d383b7
13
README.md
13
README.md
@ -1,3 +1,14 @@
|
||||
# reaper-regionplaylist2csv
|
||||
|
||||
Exports all playlists in SWS's Region Playist to CSV files
|
||||
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
|
||||
```
|
69
app.py
Normal file
69
app.py
Normal file
@ -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'^.*<S&M_RGN_PLAYLIST(.*)$'
|
||||
if re.match(pattern, rpp_content_line):
|
||||
|
||||
playlist_name = re.findall(pattern, rpp_content_line)
|
||||
if playlist_name:
|
||||
playlist_name = playlist_name[0].strip()
|
||||
|
||||
pattern = r'^(.*) 1$'
|
||||
if re.match(pattern, playlist_name):
|
||||
playlist_name = re.findall(pattern, playlist_name)
|
||||
playlist_name = playlist_name[0]
|
||||
|
||||
playlist_name = playlist_name.replace('"', '')
|
||||
|
||||
result[playlist_name] = []
|
||||
|
||||
for playlist_name in result:
|
||||
|
||||
is_playlist = False
|
||||
|
||||
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()
|
Loading…
x
Reference in New Issue
Block a user