Source

VPlayer / albumresolver.py

Full commit
from time import sleep
from collections import deque

from PyQt4 import QtCore

from vplayer.logger import log

class AlbumResolver(QtCore.QThread):
    def __init__(self):
        QtCore.QThread.__init__(self)
        self.queue = deque()
        self.active = True

    def add(self, track):
        #was = False
        #for item in self.queue:
        #    if item.url == track.url:
        #        was = True
        #        break
        #if not was:
        self.queue.append(track)

    def remove(self, track):
        if track in self.queue:
            try:
                self.queue.remove(track)
            except:
                pass

    def run(self):
        while self.active:
            if self.queue:
                track = self.queue[0]
                if track.got_album:
                    self.queue.popleft()
                    continue
                log.debug("Resolvind album for " + unicode(track))
                track.get_album()
                try: self.queue.popleft()
                except: pass
                log.debug('Resolved')
                #if track._album is None:
                #    track.got_album = False
                #    self.add(track)
                sleep(0.01)
                continue
            sleep(0.1)