示例#1
0
    def __start(self):
        music_helper = MusicHelper()

        while self._file_name_list:
            file_path = self._file_name_list.pop()
            music_tag = music_helper.get_music_tag(file_path)
            music_info = Music()
            music_info.file_path = file_path
            if music_tag == {}:
                logger.info("Music tag can't be got: " + music_info.file_path)
            else:
                music_info.music_tag = music_tag
                self._music_tag_queue.put(music_info)
示例#2
0
    def __start(self):
        cover_downloader = CoverDownloader()
        try_time = 3
        while not self._is_stop:
            try:
                # print("CoverDownloaderThread itunes queue size: " + str(self._itunes_info_queue.qsize()))
                music_info = self._itunes_info_queue.get(timeout=15)
                print("Downloading...:" + music_info.file_path)
                # logger.info("Downloading...:" + music.file_path)
                music_cover = cover_downloader.download_cover(music_info.music_itunes_info)

                if music_cover == {}:
                    logger.info("Failed to Download: " + music_info.file_path)
                else:
                    music_info.music_cover = music_cover
                    self._cover_queue.put(music_info, timeout=15)
                    self._itunes_info_queue.task_done()

                try_time = 3
            except queue.Empty:
                try_time -= 1
            if try_time == 0:
                print('Thread CoverDownloader ' + self.getName() + 'end')
                return
示例#3
0
    def __start(self):
        itunes_search = ITunesSearch()
        itunes_search.set_search_country(self._conf.COUNTRY)
        itunes_search.set_trust_prob(self._conf.TRUST_P)
        itunes_search.set_cover_min_size(self._conf.COVER_MIN_SIZE)
        try_time = 3
        while not self._is_stop:
            try:
                # print("ITunesSearchThread tag queue size: " + str(self._music_tag_queue.qsize()))
                music_info = self._music_tag_queue.get(timeout=15)
                # 用户配置了替换cover
                if self._conf.REPLACE_COVER == 1:
                    itunes_info = itunes_search.get_itunes_info(music_info.music_tag)
                    if itunes_info == {}:
                        logger.info("Music can't be found at iTunes:" + music_info.file_path + '\n' +
                                        "ALBUM: " + music_info.music_tag.get(music.ALBUM, '') + '\n' +
                                        "ALBUM_ARTIST: " + music_info.music_tag.get(music.ALBUM_ARTIST, '') + '\n' +
                                        "ARTIST: " + music_info.music_tag.get(music.ARTIST, ''))
                    else:
                        music_info.music_itunes_info = itunes_info
                        self._itunes_info_queue.put(music_info, timeout=15)
                        self._music_tag_queue.task_done()

                # 用户配置不替换cover
                elif self._conf.REPLACE_COVER == 0:
                    if music_info.music_tag[music.HAS_COVER]:
                        print("Cover file exit:" + music_info.file_path)
                        logger.info("Cover file exit:" + music_info.file_path)
                    else:
                        itunes_info = itunes_search.get_itunes_info(music_info.music_tag)
                        if itunes_info == {}:
                            logger.info("Music can't be found at iTunes:" + music_info.file_path + '\n' +
                                        "ALBUM: " + music_info.music_tag.get(music.ALBUM, '') + '\n' +
                                        "ALBUM_ARTIST: " + music_info.music_tag.get(music.ALBUM_ARTIST, '') + '\n' +
                                        "ARTIST: " + music_info.music_tag.get(music.ARTIST, ''))
                        else:
                            music_info.music_itunes_info = itunes_info
                            self._itunes_info_queue.put(music_info, timeout=15)
                            self._music_tag_queue.task_done()

                try_time = 3
            except queue.Empty:
                try_time -= 1
            if try_time == 0:
                print('Thread ITunesSearch ' + self.getName() + 'end')
                return