Init
This commit is contained in:
parent
99a2392147
commit
aa22ab989a
32
README.md
32
README.md
|
@ -1,3 +1,33 @@
|
||||||
# cue2txt
|
# cue2txt
|
||||||
|
|
||||||
Python script to convert a cue sheet file (.cue tracklist) in a text file more comfortably readable by humans.
|
Python script to convert a cue sheet file (.cue tracklist) in a text file more comfortably readable by humans.
|
||||||
|
## Installation
|
||||||
|
```bash
|
||||||
|
git clone https://forge.chalec.org/Marmous/cue2txt.git
|
||||||
|
```
|
||||||
|
## Usage
|
||||||
|
```
|
||||||
|
usage: cue2txt.py \[-h\] \[-s\] \[-o OUTPUT\] file
|
||||||
|
|
||||||
|
Let's convert a cue sheet file (.cue tracklist) in a text file more comfortably readable by humans.
|
||||||
|
|
||||||
|
positional arguments:
|
||||||
|
file path to cue file
|
||||||
|
|
||||||
|
options:
|
||||||
|
-h, --help show this help message and exit
|
||||||
|
-s, --show show results
|
||||||
|
-o OUTPUT, --output OUTPUT
|
||||||
|
path to output txt file
|
||||||
|
```
|
||||||
|
### Linux
|
||||||
|
```bash
|
||||||
|
python3 cue2txt.py FILEPATH
|
||||||
|
```
|
||||||
|
### Windows
|
||||||
|
```bash
|
||||||
|
python cue2txt.py FILEPATH
|
||||||
|
```
|
||||||
|
|
||||||
|
## References
|
||||||
|
- _example.cue_ comes from [the Cue sheet Wikipedia article](https://en.wikipedia.org/wiki/Cue_sheet_(computing)?oldformat=true#Examples)
|
|
@ -0,0 +1,34 @@
|
||||||
|
import argparse
|
||||||
|
import re
|
||||||
|
|
||||||
|
# Command arguments
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Let's convert a cue sheet file (.cue tracklist) in a text file more comfortably readable by humans.",
|
||||||
|
)
|
||||||
|
parser.add_argument("file", type=str, help="path to cue file")
|
||||||
|
parser.add_argument("-s", "--show", action="store_true", help="show results")
|
||||||
|
parser.add_argument("-o", "--output", type=str, help="path to output txt file")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
filepath = args.file
|
||||||
|
show_state = args.show
|
||||||
|
if args.output != None: # output filepath is optional
|
||||||
|
new_filepath = args.output
|
||||||
|
else:
|
||||||
|
new_filepath = re.findall(r"(.*)(?:\.cue)", filepath)[0]+".txt"
|
||||||
|
|
||||||
|
# Parsing
|
||||||
|
with open(filepath,"r") as content, open(new_filepath,"w") as tracklist :
|
||||||
|
line = content.readline()
|
||||||
|
track_tab = {}
|
||||||
|
|
||||||
|
while line != "":
|
||||||
|
line = content.readline()
|
||||||
|
if "TRACK" in line:
|
||||||
|
title = re.findall(r"(?:TITLE\s\")(.*)(?:\")", content.readline())[0]
|
||||||
|
performer = re.findall(r"(?:PERFORMER\s\")(.*)(?:\")", content.readline())[0]
|
||||||
|
time = re.findall(r"(?:INDEX\s\d+\s)(.*)(?:\:\d+)", content.readline())[0]
|
||||||
|
track_string = time+" - "+performer+" - "+title+"\n" # makes a text line for any track
|
||||||
|
if show_state: # prints result if requested
|
||||||
|
print(track_string)
|
||||||
|
tracklist.write(track_string) # writes the line in the .txt file
|
|
@ -0,0 +1,37 @@
|
||||||
|
REM GENRE Electronica
|
||||||
|
REM DATE 1998
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
TITLE "Live in Berlin"
|
||||||
|
FILE "Faithless - Live in Berlin.mp3" MP3
|
||||||
|
TRACK 01 AUDIO
|
||||||
|
TITLE "Reverence"
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
INDEX 01 00:00:00
|
||||||
|
TRACK 02 AUDIO
|
||||||
|
TITLE "She's My Baby"
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
INDEX 01 06:42:00
|
||||||
|
TRACK 03 AUDIO
|
||||||
|
TITLE "Take the Long Way Home"
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
INDEX 01 10:54:00
|
||||||
|
TRACK 04 AUDIO
|
||||||
|
TITLE "Insomnia"
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
INDEX 01 17:04:00
|
||||||
|
TRACK 05 AUDIO
|
||||||
|
TITLE "Bring the Family Back"
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
INDEX 01 25:44:00
|
||||||
|
TRACK 06 AUDIO
|
||||||
|
TITLE "Salva Mea"
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
INDEX 01 30:50:00
|
||||||
|
TRACK 07 AUDIO
|
||||||
|
TITLE "Dirty Old Man"
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
INDEX 01 38:24:00
|
||||||
|
TRACK 08 AUDIO
|
||||||
|
TITLE "God Is a DJ"
|
||||||
|
PERFORMER "Faithless"
|
||||||
|
INDEX 01 42:35:00
|
Loading…
Reference in New Issue