Lyricue --> Songbeamer Converter

Alles über SongBeamer, das sonst nirgendwo hineinpaßt
Antworten
corbin
Beiträge: 14
Registriert: Mi Jul 16, 2008 12:14 am

Lyricue --> Songbeamer Converter

Beitrag von corbin »

Hallo,

wir sind vor ca. 2 Jahren von Lyricue auf Songbeamer umgestiegen. Da beide Programme mit offenen Formaten arbeiten, war es recht einfach, die Daten von Lyricue zu Songbeamer zu konvertieren. Ich hab das Script gerade wieder gefunden und poste es einmal hier - vielleicht kann es ja jemand brauchen.
Damit es funktioniert, muss Ruby installiert sein. Bei Fragen postet einfach.

Viel Spaß damit!

LG
Corbin

Code: Alles auswählen

#!/usr/local/bin/ruby -w

require "mysql"
require "iconv"

dbname = "lyricDb"
encode_from = "iso-8859-1"
encode_to = "utf-8"
path = "./"
host = "localhost"
user = "XXX"
password = "YYY"

db = Mysql.new(host, user, password)
db.select_db("lyricDb")
result = db.query("SELECT title, id, artist, copyright FROM lyricMain ORDER BY title")
result.each do |array|
    title = array[0].gsub(/[\t\r\n]/, "")
    title = title.gsub("?", "")
    title = title.gsub("\n", "")
    title = title.gsub("/", " -- ")
    title = Iconv.new(encode_to, encode_from).iconv(title)
    if title != ""
        id = array[1]
        artist = array[2]
        artist = Iconv.new(encode_to, encode_from).iconv(artist)
        copyright = array[3]
        copyright = Iconv.new(encode_to, encode_from).iconv(copyright)
        if File.exists?(path + title)
            puts "Error! File " + title + ".sng already exists."
        else
            file = File.open(path + title + ".sng", "w+")
    
            # write Header Info
            file.puts "#LangCount=1"
            file.puts "#Title=" + title
            file.puts "#Author=" + artist
            file.puts "#(c)=Lyricue Import"
            file.puts "#Rights=" + copyright
            file.puts "#Editor=SongBeamer 2.24j"
            file.puts "#Version=3"
            file.puts "#Format=F/K//"
            file.puts "#TitleFormat=U"
    
            # write Verses
            text = db.query("select lyrics from page where songid = " + id + "  order by pagenum")
            text.each do |array_text|
                vers = array_text[0]
                vers = Iconv.new(encode_to, encode_from).iconv(vers)
                file.puts "---"
                file.puts vers
            end
            file.close
        end
    end
end
db.close
Antworten