More > JRiver Media Center 27 for Linux

Quick Start Guide for Installing LCD Matrix on rPi, reading track info

<< < (4/5) > >>

bob:
I'm sure there are way more efficient ways of doing this, I'm not a python coder but on my device I can use charset 'A00' and it does the best job handling extra characters if they are lower case so I translate the UC ones to LC thusly:

   
--- Code: ---        global Artist
Artist = " "
Artist = readattrval(root,"./Item[@Name='Artist']")
Artist=Artist.replace(chr(196),chr(228))
Artist=Artist.replace(chr(209),chr(241))
Artist=Artist.replace(chr(214),chr(246))
Artist=Artist.replace(chr(220),chr(252))
global Album
Album = " "
Album = readattrval(root,"./Item[@Name='Album']")
Album=Album.replace(chr(196),chr(228))
Album=Album.replace(chr(209),chr(241))
Album=Album.replace(chr(214),chr(246))
Album=Album.replace(chr(220),chr(252))
global Name
Name = " "
Name = readattrval(root,"./Item[@Name='Name']")
Name=Name.replace(chr(196),chr(228))
Name=Name.replace(chr(209),chr(241))
Name=Name.replace(chr(214),chr(246))
Name=Name.replace(chr(220),chr(252))
--- End code ---

Picture of my pi0w running this querying one of my Id's  :)

Wheaten:
glad it's working.

To make it a bit more maintainable, you can declare a function, which will save a lot of double code lines, like:

--- Code: ---def replacechar(sourcestr):
sourcestr = sourcestr.replace(chr(196),chr(228))
sourcestr = sourcestr.replace(chr(209),chr(241))
sourcestr = sourcestr.replace(chr(214),chr(246))
sourcestr = sourcestr.replace(chr(220),chr(252))
return sourcestr

--- End code ---

so then you need to only call it like:

--- Code: ---Album = replacechar(Album)
Name = replacechar(Name)

--- End code ---

haven't been able to test it yet, as All Pi's are in use for other purposes.

bob:

--- Quote from: Wheaten on April 01, 2021, 12:59:47 pm ---glad it's working.

To make it a bit more maintainable, you can declare a function, which will save a lot of double code lines, like:

--- Code: ---def replacechar(sourcestr):
sourcestr = sourcestr.replace(chr(196),chr(228))
sourcestr = sourcestr.replace(chr(209),chr(241))
sourcestr = sourcestr.replace(chr(214),chr(246))
sourcestr = sourcestr.replace(chr(220),chr(252))
return sourcestr

--- End code ---

so then you need to only call it like:

--- Code: ---Album = replacechar(Album)
Name = replacechar(Name)

--- End code ---

haven't been able to test it yet, as All Pi's are in use for other purposes.

--- End quote ---
I found that if one of the fields are empty it errors out so like this works:

--- Code: ---if bool(Album):
    replacechar(Album)

--- End code ---
fixes that.
I also compiled daemontools-encore on TinyCoreLinux for this app and use that to restart it when it dies (MC is offline or the network connection drops).
I can provide that if anyone is interested.

Wheaten:
Since you're the admin, you can add it to my starting topic. So we everything in one place

bmunroe:

--- Quote from: Wheaten on March 11, 2021, 10:09:31 am ---OLED version is WIP (Work In Progress)

--- End quote ---

looking forward to seeing your code for the OLED.  I managed to smash together your code with a CPU stats display code for my OLED to get it to work.  Took me a bit to figure it all out (n00b to linux and python) but it is working well now, although just putting out text info.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version