#!/usr/bin/env python #-*- coding: UTF-8 -*- # Filename: lrcShow-II.py # Develop CodeName: Shiningirl # Version:0.9.2 # Author: Xu Jia (sanfanling) and OutLikeAShoe # Lisence: GPL-2.0 # Bug report: xujia19@gmail.com #lrcShow-II: lrc script for Amarok #Copyright (C) 2008 Xu Jia #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation; either version 2 of the License, or #(at your option) any later version. #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os,sys,gettext,pickle,ConfigParser def initConfigFile(x): c='''[option] lrcpath = %s, savelrcpath = %s download = no linenumber = 3 backroundcolor = 59,86,115 fontcolor = 255,255,255 highlightcolor = 180,200,255 fonttype = serif fontsize = 9 fontweight = 50 fontitalic = no proxy = no encoder = utf8 searchengine = ttPlayer nolrc = normal includecancel = no autoinsert = no titlebarinfo = no completetag = yes filterlyrics = no nullline = no filterrule = http|lyrics|qq filtercap = no astrackname = no minwidth = 360 horizontal = no savetomediapath = no searchmediapath = no useuslt = no lastposition = 0,0 lrctagtype = lyrics3v2 lastshowmode = normal lastistop = no remembershowmode = no [shortcuts] fullscreen = F osd = O normal = Esc insert = F5 cancel = F6 editor = E save = S delay = - advance = + fastbar = I [version] pyqt = %s''' %(os.getenv('HOME'),os.getenv('HOME'),x) return c def mainQt4(args): app=QApplication(args) win=mainBox() thread=myThread(win,app) thread.start() win.show() sys.exit(app.exec_()) def mainQt3(args): app=QApplication(args) win=mainBox() thread=myThread(win,app) thread.start() win.show() app.connect(app, SIGNAL("lastWindowClosed()"),app, SLOT("quit()")) app.exec_loop() if(__name__=="__main__"): try: gettext.translation('lrcShow-II','../scripts/lrcShow-II/locale').install(unicode=True) except IOError: gettext.translation('lrcShow-II','../scripts/lrcShow-II/locale',languages=['en_US']).install(unicode=True) if(os.path.exists('lrcShow-II.db')): pass else: mydb=open('lrcShow-II.db','w') pickler=pickle.Pickler(mydb,True) pickler.dump({}) mydb.close() if(os.path.exists('lrcShow-II.conf')): pass else: try: from qt import * except ImportError: try: from PyQt4.QtCore import * from PyQt4.QtGui import * except ImportError: os.system('dcop amarok playlist popupMessage "lrcShow-II: you should install pyqt3 or pyqt4 in your system first"') sys.exit() else: config=initConfigFile('4') file=open('lrcShow-II.conf','w') file.write(config) file.close() os.system('dcop amarok playlist popupMessage "lrcShow-II: pyqt4 version is working, if you want to switch to pyqt3 version, please install pyqt3 first then use Amarok script manager\'s configure button"') else: config=initConfigFile('3') file=open('lrcShow-II.conf','w') file.write(config) file.close() os.system('dcop amarok playlist popupMessage "lrcShow-II: pyqt3 version is working, if you want to switch to pyqt4 version, please use Amarok script manager\'s configure button"') p=ConfigParser.ConfigParser() p.read('lrcShow-II.conf') try: a=p.get('version','pyqt') except: os.system('dcop amarok playlist popupMessage "lrcShow-II: config file error, please check or delete it"') else: if(a=='3'): from qt import * from mainGuiQt3 import * mainQt3(sys.argv) elif(a=='4'): from PyQt4.QtCore import * from PyQt4.QtGui import * from mainGuiQt4 import * mainQt4(sys.argv) else: os.system('dcop amarok playlist popupMessage "lrcShow-II: config file error, please check or delete it"')