Image bug
Fixed bug where images using "jpeg" (vice "jpg") were being ignored. Mostly affects some stations that use that format for album art.
This commit is contained in:
parent
23a232c7e7
commit
33e6e9b7be
31
nrsc5-dui.py
31
nrsc5-dui.py
@ -58,6 +58,7 @@ class NRSC5_DUI(object):
|
|||||||
self.getControls() # get controls and windows
|
self.getControls() # get controls and windows
|
||||||
self.initStreamInfo() # initilize stream info and clear status widgets
|
self.initStreamInfo() # initilize stream info and clear status widgets
|
||||||
self.http = urllib3.PoolManager()
|
self.http = urllib3.PoolManager()
|
||||||
|
# self.headers = urllib3.util.make_headers(keep_alive=True, accept_encoding=True, user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0")
|
||||||
|
|
||||||
self.debugLog("Local path determined as " + runtimeDir)
|
self.debugLog("Local path determined as " + runtimeDir)
|
||||||
|
|
||||||
@ -247,7 +248,7 @@ class NRSC5_DUI(object):
|
|||||||
re.compile("^[0-9\:]{8,8} Title: (.*)$"), # 4 match title
|
re.compile("^[0-9\:]{8,8} Title: (.*)$"), # 4 match title
|
||||||
re.compile("^[0-9\:]{8,8} Artist: (.*)$"), # 5 match artist
|
re.compile("^[0-9\:]{8,8} Artist: (.*)$"), # 5 match artist
|
||||||
re.compile("^[0-9\:]{8,8} Album: (.*)$"), # 6 match album
|
re.compile("^[0-9\:]{8,8} Album: (.*)$"), # 6 match album
|
||||||
re.compile("^[0-9\:]{8,8} LOT file: port=([\d]+) lot=([\d]+) name=(.*\.(?:jpg|png|txt)) size=([\d]+) mime=([\w]+)$"), # 7 match file (album art, maps, weather info)
|
re.compile("^[0-9\:]{8,8} LOT file: port=([\d]+) lot=([\d]+) name=(.*\.(?:jpg|jpeg|png|txt)) size=([\d]+) mime=([\w]+)$"), # 7 match file (album art, maps, weather info)
|
||||||
re.compile("^[0-9\:]{8,8} MER: (-?[\d]+\.[\d]+) dB \(lower\), (-?[\d]+\.[\d]+) dB \(upper\)$"), # 8 match MER
|
re.compile("^[0-9\:]{8,8} MER: (-?[\d]+\.[\d]+) dB \(lower\), (-?[\d]+\.[\d]+) dB \(upper\)$"), # 8 match MER
|
||||||
re.compile("^[0-9\:]{8,8} BER: (0\.[\d]+), avg: (0\.[\d]+), min: (0\.[\d]+), max: (0\.[\d]+)$"), # 9 match BER
|
re.compile("^[0-9\:]{8,8} BER: (0\.[\d]+), avg: (0\.[\d]+), min: (0\.[\d]+), max: (0\.[\d]+)$"), # 9 match BER
|
||||||
re.compile("^[0-9\:]{8,8} Best gain: (.*) dB,.*$"), # 10 match gain
|
re.compile("^[0-9\:]{8,8} Best gain: (.*) dB,.*$"), # 10 match gain
|
||||||
@ -319,10 +320,10 @@ class NRSC5_DUI(object):
|
|||||||
self.imgMap.set_from_icon_name("MISSING_IMAGE", Gtk.IconSize.DIALOG)
|
self.imgMap.set_from_icon_name("MISSING_IMAGE", Gtk.IconSize.DIALOG)
|
||||||
|
|
||||||
def id3_did_change(self):
|
def id3_did_change(self):
|
||||||
oldTitle = self.txtTitle.get_label()
|
oldTitle = self.txtTitle.get_label().strip()
|
||||||
oldArtist = self.txtArtist.get_label()
|
oldArtist = self.txtArtist.get_label().strip()
|
||||||
newTitle = self.streamInfo["Title"]
|
newTitle = self.streamInfo["Title"].strip()
|
||||||
newArtist = self.streamInfo["Artist"]
|
newArtist = self.streamInfo["Artist"].strip()
|
||||||
return ((newArtist != oldArtist) and (newTitle != oldTitle))
|
return ((newArtist != oldArtist) and (newTitle != oldTitle))
|
||||||
|
|
||||||
def get_cover_data(self, response):
|
def get_cover_data(self, response):
|
||||||
@ -378,7 +379,8 @@ class NRSC5_DUI(object):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
searchStr = "https://www.discogs.com/search/?q="+searchStr+"&type=all"
|
searchStr = "https://www.discogs.com/search/?q="+searchStr+"&type=all"
|
||||||
r = self.http.request('GET',searchStr)
|
#r = self.http.request('GET', searchStr, self.headers)
|
||||||
|
r = self.http.request('GET', searchStr)
|
||||||
if (r.status == 200):
|
if (r.status == 200):
|
||||||
response = r.data.decode('utf-8')
|
response = r.data.decode('utf-8')
|
||||||
|
|
||||||
@ -513,7 +515,8 @@ class NRSC5_DUI(object):
|
|||||||
self.playing = True
|
self.playing = True
|
||||||
#self.lastXHDR = ["", -1]
|
#self.lastXHDR = ["", -1]
|
||||||
self.lastXHDR = ""
|
self.lastXHDR = ""
|
||||||
|
#print("lastXHDR reset")
|
||||||
|
|
||||||
# start the player thread
|
# start the player thread
|
||||||
self.playerThread = Thread(target=self.play)
|
self.playerThread = Thread(target=self.play)
|
||||||
self.playerThread.start()
|
self.playerThread.start()
|
||||||
@ -699,6 +702,7 @@ class NRSC5_DUI(object):
|
|||||||
self.streamInfo["Logo"] = ""
|
self.streamInfo["Logo"] = ""
|
||||||
self.streamInfo["Bitrate"] = 0
|
self.streamInfo["Bitrate"] = 0
|
||||||
self.set_program_btns()
|
self.set_program_btns()
|
||||||
|
#print("lastXHDR, cover, and logo reset")
|
||||||
if self.playing:
|
if self.playing:
|
||||||
self.nrsc5msg = str(self.streamNum)
|
self.nrsc5msg = str(self.streamNum)
|
||||||
self.displayLogo()
|
self.displayLogo()
|
||||||
@ -932,17 +936,20 @@ class NRSC5_DUI(object):
|
|||||||
if self.lastXHDR == "0":
|
if self.lastXHDR == "0":
|
||||||
imagePath = os.path.join(aasDir, self.streamInfo["Cover"])
|
imagePath = os.path.join(aasDir, self.streamInfo["Cover"])
|
||||||
image = self.streamInfo["Cover"]
|
image = self.streamInfo["Cover"]
|
||||||
|
#print("lastXHDR is 0, set image to Cover:"+imagePath)
|
||||||
#elif (int(self.lastXHDR[1]) < 0 or self.streamInfo["Cover"] == None):
|
#elif (int(self.lastXHDR[1]) < 0 or self.streamInfo["Cover"] == None):
|
||||||
elif self.lastXHDR == "1":
|
elif self.lastXHDR == "1":
|
||||||
imagePath = os.path.join(aasDir, self.streamInfo["Logo"])
|
imagePath = os.path.join(aasDir, self.streamInfo["Logo"])
|
||||||
image = self.streamInfo["Logo"]
|
image = self.streamInfo["Logo"]
|
||||||
|
#print("lastXHDR is 1, set image to Logo:"+imagePath)
|
||||||
if (not os.path.isfile(imagePath)):
|
if (not os.path.isfile(imagePath)):
|
||||||
self.imgCover.clear()
|
self.imgCover.clear()
|
||||||
self.coverImage = ""
|
self.coverImage = ""
|
||||||
|
|
||||||
# resize and display image if it changed and exists
|
# resize and display image if it changed and exists
|
||||||
#if (self.xhdrChanged and self.lastImage != image and os.path.isfile(imagePath)):
|
if (self.xhdrChanged and (self.lastImage != image) and os.path.isfile(imagePath)):
|
||||||
if (self.lastImage != image) and os.path.isfile(imagePath):
|
#if ((self.lastImage != image) and os.path.isfile(imagePath)):
|
||||||
|
#print("xhdrChanged, image changed, and file exists:"+imagePath)
|
||||||
self.xhdrChanged = False
|
self.xhdrChanged = False
|
||||||
self.lastImage = image
|
self.lastImage = image
|
||||||
#img_size = min(self.alignmentCover.get_allocated_height(), self.alignmentCover.get_allocated_width()) - 12
|
#img_size = min(self.alignmentCover.get_allocated_height(), self.alignmentCover.get_allocated_width()) - 12
|
||||||
@ -952,6 +959,7 @@ class NRSC5_DUI(object):
|
|||||||
#self.pixbuf = self.pixbuf.scale_simple(img_size, img_size, GdkPixbuf.InterpType.BILINEAR)
|
#self.pixbuf = self.pixbuf.scale_simple(img_size, img_size, GdkPixbuf.InterpType.BILINEAR)
|
||||||
#self.imgCover.set_from_pixbuf(self.pixbuf)
|
#self.imgCover.set_from_pixbuf(self.pixbuf)
|
||||||
self.showArtwork(imagePath)
|
self.showArtwork(imagePath)
|
||||||
|
#print("displaying image:"+imagePath)
|
||||||
#self.handle_window_resize()
|
#self.handle_window_resize()
|
||||||
self.debugLog("Image Changed")
|
self.debugLog("Image Changed")
|
||||||
|
|
||||||
@ -1264,6 +1272,7 @@ class NRSC5_DUI(object):
|
|||||||
xhdr = m.group(1)
|
xhdr = m.group(1)
|
||||||
mime = m.group(2)
|
mime = m.group(2)
|
||||||
lot = m.group(3)
|
lot = m.group(3)
|
||||||
|
#print("got XHDR msg xhdr:"+xhdr+" for lot:"+lot)
|
||||||
if (xhdr != self.lastXHDR):
|
if (xhdr != self.lastXHDR):
|
||||||
self.lastXHDR = xhdr
|
self.lastXHDR = xhdr
|
||||||
self.xhdrChanged = True
|
self.xhdrChanged = True
|
||||||
@ -1279,6 +1288,7 @@ class NRSC5_DUI(object):
|
|||||||
|
|
||||||
p = int(m.group(1),16)
|
p = int(m.group(1),16)
|
||||||
|
|
||||||
|
#print("got LOT msg, port:"+str(p)+" lot_name:"+fileName+" size:"+str(fileSize))
|
||||||
# check file existance and size .. right now we just debug log
|
# check file existance and size .. right now we just debug log
|
||||||
if (not os.path.isfile(os.path.join(aasDir,fileName))):
|
if (not os.path.isfile(os.path.join(aasDir,fileName))):
|
||||||
self.debugLog("Missing file: " + fileName)
|
self.debugLog("Missing file: " + fileName)
|
||||||
@ -1294,11 +1304,13 @@ class NRSC5_DUI(object):
|
|||||||
if (p == self.streams[int(self.streamNum)][0]):
|
if (p == self.streams[int(self.streamNum)][0]):
|
||||||
self.streamInfo["Cover"] = fileName
|
self.streamInfo["Cover"] = fileName
|
||||||
self.debugLog("Got Album Cover: " + fileName)
|
self.debugLog("Got Album Cover: " + fileName)
|
||||||
|
#print("got Cover:"+fileName)
|
||||||
#elif (p == self.streams[int(self.spinStream.get_value()-1)][1]):
|
#elif (p == self.streams[int(self.spinStream.get_value()-1)][1]):
|
||||||
elif (p == self.streams[int(self.streamNum)][1]):
|
elif (p == self.streams[int(self.streamNum)][1]):
|
||||||
self.streamInfo["Logo"] = fileName
|
self.streamInfo["Logo"] = fileName
|
||||||
self.stationLogos[self.stationStr][self.streamNum] = fileName # add station logo to database
|
self.stationLogos[self.stationStr][self.streamNum] = fileName # add station logo to database
|
||||||
self.debugLog("Got Station Logo: " + fileName)
|
self.debugLog("Got Station Logo: " + fileName)
|
||||||
|
#print("got Logo:"+fileName)
|
||||||
|
|
||||||
elif(fileName[headerOffset:(5+headerOffset)] == "DWRO_" and mapDir is not None):
|
elif(fileName[headerOffset:(5+headerOffset)] == "DWRO_" and mapDir is not None):
|
||||||
self.processWeatherOverlay(fileName)
|
self.processWeatherOverlay(fileName)
|
||||||
@ -1495,6 +1507,7 @@ class NRSC5_DUI(object):
|
|||||||
"BER": [0,0,0,0], # bit error rate: current, average, min, max
|
"BER": [0,0,0,0], # bit error rate: current, average, min, max
|
||||||
"Gain": 0 # automatic gain
|
"Gain": 0 # automatic gain
|
||||||
}
|
}
|
||||||
|
#print("reset cover and logo")
|
||||||
|
|
||||||
self.streams = [[],[],[],[]]
|
self.streams = [[],[],[],[]]
|
||||||
self.numStreams = 0
|
self.numStreams = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user