# Path: src/controllers/utils.py
# def registerContext(func):
#     @functools.wraps(func)
#     def wrapper(*args, **kwargs):
#         self = args[0]
#         if hasattr(self, '__contextName__'):
#             contexts.update({self.__contextName__: self})
#         func(*args, **kwargs)
# 
#     return wrapper
# 
# Path: src/controllers/signalmanager.py
# class SignalManager(QObject):
#     def __init__(self, parent=None):


import os
import re
import requests
from PyQt5.QtCore import (QObject, pyqtSignal, pyqtSlot, pyqtProperty, QUrl)
from PyQt5.QtGui import QCursor, QDesktopServices
from .utils import registerContext
from config.constants import LRCPath
from log import logger
from dwidgets.coverlrc.lrc_download import TTPlayer, DUOMI, SOSO, TTPod
from dwidgets.coverlrc.cover_query import poster
from dwidgets.coverlrc.lrc_parser import LrcParser
from dwidgets.dthreadutil import dthread
from .signalmanager import signalManager
        lrcParser = LrcParser()
        if title:
            lrc_path = self.getLrcPath(artist, title)
            if lrc_path and os.path.exists(lrc_path):
                lrcParser.set_filename(lrc_path)
            else:
                artist = artist.encode('utf-8')
                title = title.encode('utf-8')
                lrc_path = self.multiple_engine(lrc_path, artist, title)
                if lrc_path:
                    lrcParser.set_filename(lrc_path)
        if hasattr(lrcParser, 'scroll_lyrics'):
            return lrcParser.scroll_lyrics
        else:
            return []

    @dthread
    def getLrc(self, artist, title):
        try:
            if title:
                lrc_path = self.getLrcPath(artist, title)
                if lrc_path and os.path.exists(lrc_path):
                    self.lrcFileExisted.emit(lrc_path)
                else:
                    artist = artist.encode('utf-8')
                    title = title.encode('utf-8')
                    lrc_path = self.multiple_engine(lrc_path, artist, title)
                    if lrc_path:
                        self.lrcFileExisted.emit(lrc_path)
                    else:

# Path: src/controllers/utils.py
# def registerContext(func):
#     @functools.wraps(func)
#     def wrapper(*args, **kwargs):
#         self = args[0]
#         if hasattr(self, '__contextName__'):
#             contexts.update({self.__contextName__: self})
#         func(*args, **kwargs)
# 
#     return wrapper
# 
# Path: src/controllers/signalmanager.py
# class SignalManager(QObject):
#     def __init__(self, parent=None):


# Path: src/controllers/lrcworker.py
import os
import re
import requests
from PyQt5.QtCore import (QObject, pyqtSignal, pyqtSlot, pyqtProperty, QUrl)
from PyQt5.QtGui import QCursor, QDesktopServices
from .utils import registerContext
from config.constants import LRCPath
from log import logger
from dwidgets.coverlrc.lrc_download import TTPlayer, DUOMI, SOSO, TTPod
from dwidgets.coverlrc.cover_query import poster
from dwidgets.coverlrc.lrc_parser import LrcParser
from dwidgets.dthreadutil import dthread
from .signalmanager import signalManager

        lrcParser = LrcParser()
        if title:
            lrc_path = self.getLrcPath(artist, title)
            if lrc_path and os.path.exists(lrc_path):
                lrcParser.set_filename(lrc_path)
            else:
                artist = artist.encode('utf-8')
                title = title.encode('utf-8')
                lrc_path = self.multiple_engine(lrc_path, artist, title)
                if lrc_path:
                    lrcParser.set_filename(lrc_path)
        if hasattr(lrcParser, 'scroll_lyrics'):
            return lrcParser.scroll_lyrics
        else:
            return []

    @dthread
    def getLrc(self, artist, title):
        try:
            if title:
                lrc_path = self.getLrcPath(artist, title)
                if lrc_path and os.path.exists(lrc_path):
                    self.lrcFileExisted.emit(lrc_path)
                else:
                    artist = artist.encode('utf-8')
                    title = title.encode('utf-8')
                    lrc_path = self.multiple_engine(lrc_path, artist, title)
                    if lrc_path:
                        self.lrcFileExisted.emit(lrc_path)
                    else:

                        signalManager.noLrcFound.emit()