Exemplo n.º 1
0
 def apply(self):
     if  self.check_validity() and (self.artist, self.musicName, self.album) != (self.artistEdit.text(), self.musicEdit.text(), self.albumEdit.text()):
         self.artist, self.musicName, self.album = self.artistEdit.text(), self.musicEdit.text(), self.albumEdit.text()
         self.title = connect_as_title(self.artist, self.musicName)
         write_tags(self.path, self.title, self.album)
         modifiedTime = get_time_of_now()
         self.modifyTimeLabel.setText('修改时间: %s'%format_time_str_with_weekday(modifiedTime))
         self.tag_values_changed_signal.emit(self.row, self.title, self.album, modifiedTime)
Exemplo n.º 2
0
 def set_media_source_at_row(self, row, clickPlayFlag=False):
     if not self.playlist.length() or row < 0:
         return
     self.stop_music()
     self.clickPlayFlag = clickPlayFlag
     self.playlist.set_current_row(row)
     sourcePath = self.playlist.get_music_path_at(row)
     self.title = self.playlist.get_music_title_at(row)
     self.sourceTrace = "local" if self.playlist.get_music_id_at(row) == Configures.LocalMusicId else "online"
     self.artistName, self.musicName = get_artist_and_musicname_from_title(self.title)
     self.playlistName = self.playlist.get_name()
     self.totalTime = self.playlist.get_music_time_at(row)
     self.album = self.playlist.get_music_album_at(row)
     self.errorType = Configures.NoError
     isAnUrl = False
     if not os.path.exists(sourcePath):
         if self.playlist.get_name() == Configures.PlaylistOnline:
             if sourcePath == Configures.NoLink:
                 musicId = self.playlist.get_music_id_at(row)
                 sourcePath = SearchOnline.get_song_link(musicId)
                 if sourcePath:
                     self.playlist.set_music_path_at(row, sourcePath)
                 else:
                     self.errorType = Configures.UrlError
             isAnUrl = True
         else:
             self.errorType = Configures.PathError
             sourcePath = "/usr/share/sounds/error_happened.ogg"
     if self.errorType == Configures.NoError:
         self.sourcePath = sourcePath
         self.musicFileName = get_base_name_from_path(sourcePath)
         self.playedDate = get_time_of_now()
         self.songinfosManager.update_datas_of_item(
             self.musicFileName,
             self.playedDate,
             self.musicName,
             self.artistName,
             self.totalTime,
             self.album,
             self.playlistName,
         )
         if not self.timerFlag:
             self.timerFlag = True
             self.timeSpan = 0
         if isAnUrl:
             url = QUrl(sourcePath)
         else:
             url = QUrl.fromLocalFile(sourcePath)
         self.play_from_url(url)
     else:
         self.timerFlag = False
         self.dont_hide_main_window_signal.emit()
         if self.errorType == Configures.DisnetError:
             QMessageBox.critical(
                 self, "错误", "联网出错!\n无法联网播放歌曲'%s'!\n您最好在网络畅通时下载该曲目!" % self.playlist.get_music_title_at(row)
             )
         elif self.errorType == Configures.PathError:
             QMessageBox.information(self, "提示", "路径'%s'无效,请尝试重新下载并添加对应歌曲!" % self.playlist.get_music_path_at(row))
Exemplo n.º 3
0
 def set_media_source_at_row(self, row, clickPlayFlag=False):
     if not self.playlist.length() or row < 0:
         return
     self.stop_music()
     self.clickPlayFlag = clickPlayFlag
     self.playlist.set_current_row(row)
     sourcePath = self.playlist.get_music_path_at(row)
     self.title = self.playlist.get_music_title_at(row)
     self.sourceTrace = 'local' if self.playlist.get_music_id_at(
         row) == Configures.LocalMusicId else 'online'
     self.artistName, self.musicName = get_artist_and_musicname_from_title(
         self.title)
     self.playlistName = self.playlist.get_name()
     self.totalTime = self.playlist.get_music_time_at(row)
     self.album = self.playlist.get_music_album_at(row)
     self.errorType = Configures.NoError
     isAnUrl = False
     if not os.path.exists(sourcePath):
         if self.playlist.get_name() == Configures.PlaylistOnline:
             if sourcePath == Configures.NoLink:
                 musicId = self.playlist.get_music_id_at(row)
                 sourcePath = SearchOnline.get_song_link(musicId)
                 if sourcePath:
                     self.playlist.set_music_path_at(row, sourcePath)
                 else:
                     self.errorType = Configures.UrlError
             isAnUrl = True
         else:
             self.errorType = Configures.PathError
             sourcePath = "/usr/share/sounds/error_happened.ogg"
     if self.errorType == Configures.NoError:
         self.sourcePath = sourcePath
         self.musicFileName = get_base_name_from_path(sourcePath)
         self.playedDate = get_time_of_now()
         self.songinfosManager.update_datas_of_item(
             self.musicFileName, self.playedDate, self.musicName,
             self.artistName, self.totalTime, self.album, self.playlistName)
         if not self.timerFlag:
             self.timerFlag = True
             self.timeSpan = 0
         if isAnUrl:
             url = QUrl(sourcePath)
         else:
             url = QUrl.fromLocalFile(sourcePath)
         self.play_from_url(url)
     else:
         self.timerFlag = False
         self.dont_hide_main_window_signal.emit()
         if self.errorType == Configures.DisnetError:
             QMessageBox.critical(
                 self, "错误", "联网出错!\n无法联网播放歌曲'%s'!\n您最好在网络畅通时下载该曲目!" %
                 self.playlist.get_music_title_at(row))
         elif self.errorType == Configures.PathError:
             QMessageBox.information(
                 self, "提示", "路径'%s'无效,请尝试重新下载并添加对应歌曲!" %
                 self.playlist.get_music_path_at(row))
Exemplo n.º 4
0
 def get_record_at(self, index):
     record = PlaylistBasic.get_infos_at(self, index)
     infoChanged = False
     if record[6] == 0:
         infoChanged = True
         record[6] = get_time_of_now()
     if record[7] == 0:
         infoChanged = True
         record[7] = record[6]
     if infoChanged:
         self.commit_records()
     return record
Exemplo n.º 5
0
 def get_record_at(self, index):
     record = PlaylistBasic.get_infos_at(self, index)
     infoChanged = False
     if record[6] == 0:
         infoChanged = True
         record[6] = get_time_of_now()
     if record[7] == 0:
         infoChanged = True
         record[7] = record[6]
     if infoChanged:
         self.commit_records()
     return record
Exemplo n.º 6
0
 def add_record(self,
                id,
                title,
                totalTime,
                album,
                path,
                size,
                musicId=Configures.LocalMusicId):
     timeNow = get_time_of_now()
     self.add_item(id, [
         title, totalTime, album, path, size, musicId, timeNow, timeNow, 0,
         0, 0, 0
     ])
Exemplo n.º 7
0
 def apply(self):
     if self.check_validity() and (self.artist, self.musicName,
                                   self.album) != (self.artistEdit.text(),
                                                   self.musicEdit.text(),
                                                   self.albumEdit.text()):
         self.artist, self.musicName, self.album = self.artistEdit.text(
         ), self.musicEdit.text(), self.albumEdit.text()
         self.title = connect_as_title(self.artist, self.musicName)
         write_tags(self.path, self.title, self.album)
         modifiedTime = get_time_of_now()
         self.modifyTimeLabel.setText(
             '修改时间: %s' % format_time_str_with_weekday(modifiedTime))
         self.tag_values_changed_signal.emit(self.row, self.title,
                                             self.album, modifiedTime)
Exemplo n.º 8
0
 def add_record(self, id, title, totalTime, album, path, size, musicId=Configures.LocalMusicId):
     timeNow = get_time_of_now()
     self.add_item(id, [title, totalTime, album, path, size, musicId, timeNow, timeNow, 0, 0, 0, 0])