Station logo
Fixed a timing bug where the track info trigger wasn't properly displaying the station logo when it changes to an info/slogan.
This commit is contained in:
parent
d46533a96c
commit
23a232c7e7
74
nrsc5-dui.py
74
nrsc5-dui.py
@ -362,48 +362,48 @@ class NRSC5_DUI(object):
|
|||||||
got_cover = False
|
got_cover = False
|
||||||
|
|
||||||
# only change when there's a new ID3
|
# only change when there's a new ID3
|
||||||
if (self.id3Changed):
|
#if (self.id3Changed):
|
||||||
# only care about the first artist listed if separated by slashes
|
|
||||||
newArtist = self.fix_artist()
|
|
||||||
baseStr = str(newArtist +" - "+self.streamInfo["Title"]).replace("/","_").replace(":","_")
|
|
||||||
#saveStr = "aas/"+ baseStr.replace(" ","_")+".jpg"
|
|
||||||
saveStr = os.path.join(aasDir, baseStr.replace(" ","_")+".jpg")
|
|
||||||
searchStr = baseStr.replace(" ","+")
|
|
||||||
|
|
||||||
# does it already exist?
|
# only care about the first artist listed if separated by slashes
|
||||||
if (os.path.isfile(saveStr)):
|
newArtist = self.fix_artist()
|
||||||
self.coverImage = saveStr
|
baseStr = str(newArtist +" - "+self.streamInfo["Title"]).replace("/","_").replace(":","_")
|
||||||
|
saveStr = os.path.join(aasDir, baseStr.replace(" ","_")+".jpg")
|
||||||
|
searchStr = baseStr.replace(" ","+")
|
||||||
|
|
||||||
# if not, get it from Discogs
|
# does it already exist?
|
||||||
else:
|
if (os.path.isfile(saveStr)):
|
||||||
try:
|
self.coverImage = saveStr
|
||||||
searchStr = "https://www.discogs.com/search/?q="+searchStr+"&type=all"
|
|
||||||
r = self.http.request('GET',searchStr)
|
|
||||||
if (r.status == 200):
|
|
||||||
response = r.data.decode('utf-8')
|
|
||||||
|
|
||||||
# loop through the page until you either get an artist match or you run out of page (check)
|
# if not, get it from Discogs
|
||||||
while (not got_cover):
|
else:
|
||||||
resultUrl = ""
|
try:
|
||||||
resultArtist = ""
|
searchStr = "https://www.discogs.com/search/?q="+searchStr+"&type=all"
|
||||||
check, response, resultUrl, resultArtist = self.get_cover_data(response)
|
r = self.http.request('GET',searchStr)
|
||||||
got_cover = (newArtist.lower() in resultArtist.lower()) and (check == 0)
|
if (r.status == 200):
|
||||||
|
response = r.data.decode('utf-8')
|
||||||
# if you got a match, save it
|
|
||||||
if (resultUrl != ""):
|
|
||||||
with self.http.request('GET', resultUrl, preload_content=False) as r, open(saveStr, 'wb') as out_file:
|
|
||||||
if (r.status == 200):
|
|
||||||
shutil.copyfileobj(r, out_file)
|
|
||||||
self.coverImage = saveStr
|
|
||||||
|
|
||||||
# If no match use the station logo if there is one
|
# loop through the page until you either get an artist match or you run out of page (check)
|
||||||
else:
|
while (not got_cover):
|
||||||
self.coverImage = os.path.join(aasDir, self.stationLogos[self.stationStr][self.streamNum])
|
resultUrl = ""
|
||||||
except:
|
resultArtist = ""
|
||||||
pass
|
check, response, resultUrl, resultArtist = self.get_cover_data(response)
|
||||||
|
got_cover = (newArtist.lower() in resultArtist.lower()) and (check == 0)
|
||||||
|
|
||||||
|
# if you got a match, save it
|
||||||
|
if (resultUrl != ""):
|
||||||
|
with self.http.request('GET', resultUrl, preload_content=False) as r, open(saveStr, 'wb') as out_file:
|
||||||
|
if (r.status == 200):
|
||||||
|
shutil.copyfileobj(r, out_file)
|
||||||
|
self.coverImage = saveStr
|
||||||
|
|
||||||
# now display it by simulating a window resize
|
# If no match use the station logo if there is one
|
||||||
self.on_cover_resize(self.mainWindow)
|
else:
|
||||||
|
self.coverImage = os.path.join(aasDir, self.stationLogos[self.stationStr][self.streamNum])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# now display it by simulating a window resize
|
||||||
|
self.on_cover_resize(self.mainWindow)
|
||||||
|
|
||||||
def showArtwork(self, art):
|
def showArtwork(self, art):
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user