The pyrealpro module provides classes that can be used to build a representation of a song, and render it in the import URL format used by the iRealPro app. It assumes that you have a passing familiarity with the iRealPro import format, but hopefully makes it easier to programmatically construct an iRealPro song than resorting to brute-force string concatenation.
The Song
class is used to define a song that you wish to import into iRealPro. In addition to basic information like
title, composer, key, and style, a song's measures
property may contain a list of Measure
objects.
A Measure
object's chords
property will have one or more chord names, as well as additional properties that describe
time signature (as a TimeSignature
object), barlines, endings, rehearsal marks, and text to be displayed underneath.
The TimeSignature
class provides simple objects used by the Measure
class to properly format the output ultimately
used by the Song
class to generate an iRealPro URL.
from pyrealpro import Song, Measure, TimeSignature
s = Song(title="Automation Blues", composer="pyrealpro", key='G', style='New Orleans Swing',
composer_name_first="Otto",
composer_name_last="Matonne")
s.measures.append(Measure(chords='G7', barline_open='{', staff_text='Generated by pyrealpro'))
s.measures.append(Measure(chords='G7'))
s.measures.append(Measure(chords='G7'))
s.measures.append(Measure(chords='G7', barline_close=']'))
s.measures.append(Measure(chords='C7', barline_open='['))
s.measures.append(Measure(chords='C7'))
s.measures.append(Measure(chords='G7'))
s.measures.append(Measure(chords='G7', barline_close=']'))
s.measures.append(Measure(chords='D7', barline_open='['))
s.measures.append(Measure(chords='C7'))
s.measures.append(Measure(chords='G7', ending='N1'))
s.measures.append(Measure(chords='D7', barline_close='}'))
s.measures.append(Measure(chords='G7', ending='N2'))
s.measures.append(Measure(chords='G7', barline_close='Z'))
print(s.url())
The above program will output the following URL, which can be imported into iRealPro:
irealbook://Automation%20Blues=Matonne%20Otto=New%20Orleans%20Swing=G=n=%7BT44%3CGenerated%20by%20pyrealpro%3EG7%20%20%20%7CG7%20%20%20%7CG7%20%20%20%7CG7%20%20%20%5D%5BC7%20%20%20%7CC7%20%20%20%7CG7%20%20%20%7CG7%20%20%20%5D%5BD7%20%20%20%7CC7%20%20%20%7CN1G7%20%20%20%7CD7%20%20%20%7DN2G7%20%20%20%7CG7%20%20%20Z