-
Notifications
You must be signed in to change notification settings - Fork 1
/
qlyric.py
45 lines (35 loc) · 1.09 KB
/
qlyric.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/env python2
# QLyric: a lyric downloader and displayer for Quod Libet
# version 0.1
# (C) 2011 by Johnny Huang <[email protected]>
# Licenses under GPLv2. See Quod Libet's COPYING for more information
import thread
import time
from notilyric import NotiLyric
from quodlibet.plugins.events import EventPlugin
from quodlibet.player import playlist as player
class QLyric(EventPlugin):
PLUGIN_ID = "QLyric"
PLUGIN_NAME = "Quod Libet Lyric"
PLUGIN_DESC = "A lyric downloader and displayer for Quod Libet"
PLUGIN_VERSION = "0.1"
def __init__(self):
self.live = False
self.notilyric = NotiLyric('QLyric')
self.interval = 1
def display(self):
while self.live:
time.sleep(self.interval)
if player.paused:
self.notilyric.close()
continue
progress = int(player.get_position() // 1000)
self.notilyric.display(progress)
def enabled(self):
self.live = True
thread.start_new_thread(self.display, ())
def disabled(self):
self.live = False
self.notilyric.close()
def plugin_on_song_started(self, song):
self.notilyric.setinfo(song.get('artist'), song.get('title'))