# 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
            if self.validLrcContent(ttpod_result):
                with open(lrc_path, 'wb') as fp:
                    fp.write(ttpod_result.encode('utf-8'))
                    return lrc_path
            else:
                return None

    def duomiEngine(self, lrc_path, artist, title):
        duomi_result = DUOMI().request(artist, title)
        if duomi_result:
            urls = [item[2] for item in duomi_result]
            for url in urls:
                ret = self.downloadLRC(url, lrc_path)
                if ret:
                    return lrc_path
                else:
                    return None
        else:
            return None

    def sosoEngine(self, lrc_path, artist, title):
        soso_result = SOSO().request(artist, title)
        if soso_result:
            urls = [item[2] for item in soso_result]
            for url in urls:
                ret = self.downloadLRC(url, lrc_path)
                if ret:
                    return lrc_path
                else:
                    return None

# 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

            if self.validLrcContent(ttpod_result):
                with open(lrc_path, 'wb') as fp:
                    fp.write(ttpod_result.encode('utf-8'))
                    return lrc_path
            else:
                return None

    def duomiEngine(self, lrc_path, artist, title):
        duomi_result = DUOMI().request(artist, title)
        if duomi_result:
            urls = [item[2] for item in duomi_result]
            for url in urls:
                ret = self.downloadLRC(url, lrc_path)
                if ret:
                    return lrc_path
                else:
                    return None
        else:
            return None

    def sosoEngine(self, lrc_path, artist, title):
        soso_result = SOSO().request(artist, title)
        if soso_result:
            urls = [item[2] for item in soso_result]
            for url in urls:
                ret = self.downloadLRC(url, lrc_path)
                if ret:
                    return lrc_path
                else:
                    return None

        else: