(.*)<\/PRE>", re.DOTALL).search(textl) if a: ftext = a.groups() else: return 0 doc = '''dcop amarok contextbrowser showLyrics \"%s \"''' % (myurl, artist, title, ftext) doc = re.sub("
|
", "\n", re.sub(r"\\r|\\n", "" ,re.sub('\("
|
",\)|
",\)|",\)|\(\'|\',\)', '', doc))) os.system(doc.encode('ascii', 'xmlcharrefreplace')) return 1 def lyricwiki_scrape(self, myurl, artist, title): br.open(myurl) print br.title() textl = br.response().read() a = re.compile("(.*)", re.DOTALL).search(textl) if a: ftext = a.groups() else: return 0 doc = '''dcop amarok contextbrowser showLyrics \"%s \"''' % (myurl, artist, title, ftext) doc = re.sub("
|
|
", "\n", re.sub(r"\\r|\\n", "" ,re.sub('\("
|
",\)|
",\)|",\)', '', doc))) os.system(doc.encode('ascii', 'xmlcharrefreplace')) return 1 def terra_scrape(self, myurl, artist, title): br.open(myurl) print br.title() textl = br.response().read() a = re.compile("(.*)
", re.DOTALL).search(textl) if a: ftext = a.groups() else: return 0 doc = '''dcop amarok contextbrowser showLyrics \"%s \"''' % (myurl, artist, title, ftext) doc = re.sub("
|
|
", "\n", re.sub(r"\\r|\\n", "" ,re.sub('\("
|
",\)|
",\)|",\)|\(\'|\',\)', '', doc))) os.system(doc.encode('ascii', 'xmlcharrefreplace')) return 1 #------------------------------------ #parser = OptionParser() #options, args = parser.parse_args() #artist = args[0] #title = args[1] plugin = PyLyrics() while True: signal=sys.stdin.readline() if re.search('(fetchLyrics|configure)',signal): if re.search('configure', signal): os.system("dcop amarok playlist popupMessage \"This script does not require any configuration.\"") else: artist=string.rstrip(os.popen("dcop amarok player artist").read()) title=string.rstrip(os.popen("dcop amarok player title").read()) if not plugin.fetchLyrics(artist, title): atitle = re.sub(r"\W*\(.*\)\W*","",title) aartist = re.sub(r"\W*\(.*\)\W*","",artist) if ( atitle == title ) & ( aartist == artist ): acc = os.popen("dcop amarok contextbrowser showLyrics").read() if len(acc) <= 60: os.system('''dcop amarok contextbrowser showLyrics \"No Lyrics found. \"''') elif not plugin.fetchLyrics(aartist, atitle): acc = os.popen("dcop amarok contextbrowser showLyrics").read() if len(acc) <= 60: os.system('''dcop amarok contextbrowser showLyrics \"No Lyrics found. \"''')