Python Forum
Annoying BeautifulSoup user warning.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Annoying BeautifulSoup user warning.
#4
(May-10-2018, 07:00 PM)MegasXLR Wrote: Hello,

I have the following code:
GUI.py
from PySide import QtCore, QtGui

class Graphics(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1125, 865)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.playlist = QtGui.QListView(self.centralwidget)
        self.playlist.setGeometry(QtCore.QRect(10, 40, 301, 801))
        self.playlist.setObjectName("playlist")
        self.lyrics = QtGui.QTextBrowser(self.centralwidget)
        self.lyrics.setGeometry(QtCore.QRect(810, 40, 301, 801))
        self.lyrics.setObjectName("lyrics")
        self.albumArt = QtGui.QGraphicsView(self.centralwidget)
        self.albumArt.setGeometry(QtCore.QRect(325, 40, 471, 431))
        self.albumArt.setObjectName("albumArt")
        self.openFileButton = QtGui.QPushButton(self.centralwidget)
        self.openFileButton.setGeometry(QtCore.QRect(520, 10, 75, 23))
        self.openFileButton.setObjectName("openFileButton")
        self.songName = QtGui.QLabel(self.centralwidget)
        self.songName.setGeometry(QtCore.QRect(330, 640, 461, 21))
        self.songName.setObjectName("songName")
        self.artistName = QtGui.QLabel(self.centralwidget)
        self.artistName.setGeometry(QtCore.QRect(330, 670, 461, 21))
        self.artistName.setObjectName("artistName")
        self.albumName = QtGui.QLabel(self.centralwidget)
        self.albumName.setGeometry(QtCore.QRect(330, 700, 461, 21))
        self.albumName.setObjectName("albumName")
        self.songsCount = QtGui.QLabel(self.centralwidget)
        self.songsCount.setGeometry(QtCore.QRect(740, 670, 61, 21))
        self.songsCount.setObjectName("songsCount")
        self.seekSlider = QtGui.QSlider(self.centralwidget)
        self.seekSlider.setGeometry(QtCore.QRect(330, 500, 461, 22))
        self.seekSlider.setOrientation(QtCore.Qt.Horizontal)
        self.seekSlider.setObjectName("seekSlider")
        self.volumeSlider = QtGui.QSlider(self.centralwidget)
        self.volumeSlider.setGeometry(QtCore.QRect(330, 780, 461, 22))
        self.volumeSlider.setOrientation(QtCore.Qt.Horizontal)
        self.volumeSlider.setObjectName("volumeSlider")
        self.seekLabel = QtGui.QLabel(self.centralwidget)
        self.seekLabel.setGeometry(QtCore.QRect(330, 480, 461, 20))
        self.seekLabel.setObjectName("seekLabel")
        self.prevSongButton = QtGui.QPushButton(self.centralwidget)
        self.prevSongButton.setGeometry(QtCore.QRect(440, 550, 71, 71))
        self.prevSongButton.setText("")
        self.prevSongButton.setIconSize(QtCore.QSize(80, 80))
        self.prevSongButton.setObjectName("prevSongButton")
        self.playPauseButton = QtGui.QPushButton(self.centralwidget)
        self.playPauseButton.setGeometry(QtCore.QRect(520, 550, 81, 71))
        self.playPauseButton.setText("")
        self.playPauseButton.setIconSize(QtCore.QSize(80, 80))
        self.playPauseButton.setObjectName("playPauseButton")
        self.nextSongButton = QtGui.QPushButton(self.centralwidget)
        self.nextSongButton.setGeometry(QtCore.QRect(610, 550, 71, 71))
        self.nextSongButton.setText("")
        self.nextSongButton.setIconSize(QtCore.QSize(80, 80))
        self.nextSongButton.setObjectName("nextSongButton")
        self.volumeLabel = QtGui.QLabel(self.centralwidget)
        self.volumeLabel.setGeometry(QtCore.QRect(330, 760, 461, 20))
        self.volumeLabel.setObjectName("volumeLabel")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
        self.lyrics.setHtml(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.openFileButton.setText(QtGui.QApplication.translate("MainWindow", "Open File", None, QtGui.QApplication.UnicodeUTF8))
        self.songName.setText(QtGui.QApplication.translate("MainWindow", "Song:  ", None, QtGui.QApplication.UnicodeUTF8))
        self.artistName.setText(QtGui.QApplication.translate("MainWindow", "Artist:  ", None, QtGui.QApplication.UnicodeUTF8))
        self.albumName.setText(QtGui.QApplication.translate("MainWindow", "Album: ", None, QtGui.QApplication.UnicodeUTF8))
        self.songsCount.setText(QtGui.QApplication.translate("MainWindow", "0 / 0", None, QtGui.QApplication.UnicodeUTF8))
        self.seekLabel.setText(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p align=\"center\">Seek</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.volumeLabel.setText(QtGui.QApplication.translate("MainWindow", "<html><head/><body><p align=\"center\">Volume</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
MusicPlayer.py
import sys, tkinter, pygame, mutagen
from tkinter import filedialog
#from mutagen import File
from mutagen.easyid3 import EasyID3
from PyLyrics import *
from PySide.QtCore import *
from PySide.QtGui import *
from GUI import *
  
class MusicPlayer(QMainWindow, Graphics):
	def __init__(self, parent = None):
		super(MusicPlayer, self).__init__(parent)
		self.setupUi(self)
		pygame.init()
		pygame.mixer.init()
		self.openFileButton.clicked.connect(self.openFileSelectionDialog)
		self.prevIcon = QtGui.QIcon()
		self.prevIconImage = QtGui.QPixmap("icons/prevButton.png")
		self.prevIcon.addPixmap(self.prevIconImage)
		self.prevSongButton.setIcon(self.prevIcon)
		self.playIcon = QtGui.QIcon()
		self.playIconImage = QtGui.QPixmap("icons/playButton.png")
		self.playIcon.addPixmap(self.playIconImage)
		self.playPauseButton.setIcon(self.playIcon)
		self.pauseIcon = QtGui.QIcon()
		self.pauseIconImage = QtGui.QPixmap("icons/pauseButton.png")
		self.pauseIcon.addPixmap(self.pauseIconImage)
		self.nextIcon = QtGui.QIcon()
		self.nextIconImage = QtGui.QPixmap("icons/nextButton.png")
		self.nextIcon.addPixmap(self.nextIconImage)
		self.nextSongButton.setIcon(self.nextIcon)
		self.seekSlider.setValue(0)
		self.volumeSlider.setValue(0)
		self.prevSongButton.clicked.connect(self.previousSongAudioButton)
		self.nextSongButton.clicked.connect(self.nextSongAudioButton)
		self.previousButtonPressed = False
		self.isPlaying = False
		self.volumeSlider.setRange(0, 100)
	
	def openFileSelectionDialog(self):
		root = tkinter.Tk()
		root.withdraw()
		self.file_path = filedialog.askopenfilename()
		self.playAudioFromSelectedFile(self.file_path)
		
	def playAudioFromSelectedFile(self, path):
		pygame.mixer.music.load(path)
		pygame.mixer.music.play()
		self.showSongInfo(path)
		self.playPauseButton.setIcon(self.pauseIcon)
		self.playPauseButton.setEnabled(True)
		self.seekSlider.setEnabled(True)
		self.playPauseButton.clicked.connect(self.playPauseAudioButton)
		self.isPlaying = True
	
	def playPauseAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.pause()
			self.playPauseButton.setIcon(self.playIcon)
			self.isPlaying = False
		elif self.isPlaying == False:
			if self.previousButtonPressed == True:
				pygame.mixer.music.play()
			elif self.previousButtonPressed == False:
				pygame.mixer.music.unpause()
			self.playPauseButton.setIcon(self.pauseIcon)
			self.isPlaying = True
		
	def previousSongAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.stop()
			pygame.mixer.music.play()
		elif self.isPlaying == False:
			pygame.mixer.music.stop()
			pygame.mixer.music.load(self.file_path)
			self.previousButtonPressed = True
		
	def nextSongAudioButton(self):
		if self.isPlaying == True:
			pygame.mixer.music.stop()
		
	def showSongInfo(self, path):
		'''self.filePath = File(path)
		self.artwork = self.filePath.tags['APIC:'].data
		self.albumArtImage = QImage(self.artwork)
		self.pixmapItem = QGraphicsPixmapItem(QPixmap.fromImage(self.albumArtImage))
		self.scene = QGraphicsScene()
		scene.addItem(self.pixmapItem)
		self.albumArt.setScene(self.scene)'''
		#print(EasyID3.valid_keys.keys())
		self.audioFile = EasyID3(path)
		self.songName.setText("Song:  " + self.audioFile["title"][0])
		self.artistName.setText("Artist:  " + self.audioFile["artist"][0])
		self.albumName.setText("Album: " + self.audioFile["album"][0])
		self.lyrics.setText(PyLyrics.getLyrics(self.audioFile["artist"][0], self.audioFile["title"][0]))
	
if __name__ == "__main__":
	app = QApplication(sys.argv)
	window = MusicPlayer()
	window.show()
	sys.exit(app.exec_())
But never in my code have I used "BeautifulSoup" at all! So I can't change it as suggested by the message...
How can I remove or fix this annoying warning? The program works fine, I just don't like errors in the console.
PyLyrics is the module that uses BeatifulSoup in some way, but I don't know how to get rid of the warning. Help :(

PS: It says that it's caused on line 101, but it's not if you look at that line.

actually you are using BeautifulSoup (indirectly). In your GUI file you are calling the setHtml function of the QTextBrowser item "lyrics". At least that is the only part where it might be called.
The interesting part is, that my system does not show any warning at all.
Since creating the MusicPlayer object does not throw any warning I do not think the problem is in your PyLyrics file. So the setHtml function could be the reason.
Reply


Messages In This Thread
Annoying BeautifulSoup user warning. - by MegasXLR - May-10-2018, 07:00 PM
RE: Annoying BeautifulSoup user warning. - by ThiefOfTime - May-11-2018, 07:48 AM
RE: Annoying BeautifulSoup user warning. - by buran - May-15-2018, 07:05 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020