VLC NowPlaying

Non-OBS Script VLC NowPlaying 1.7.0

AbyssHunted

New Member
Had an issue with this tool. It would crash whenever I was playing any file in VLC that had Unicode characters in its meta-data.

Fortunately, was able to fix the problem by modifying 5 lines of python code.

If you could publish a fixed version of the tool, I'm sure other folks might appreciate it.

Details on the code fixes below.

1)Change
import os, time, datetime, requests
to
import os, time, datetime, requests, codecs

2)Change
root = ET.fromstring(r.text)
to
root = ET.fromstring(r.content)

3)Change
print(currentSongInfo)
to
print(currentSongInfo.encode('utf-8', 'ignore'))

4)Change
textFile = open('NowPlaying.txt', 'w')
to
textFile = codecs.open('NowPlaying.txt', 'w', encoding='utf-8', errors='ignore')

5)Change
textFile = open('NowPlaying_History.txt', 'a')
to
textFile = codecs.open('NowPlaying_History.txt', 'a', encoding='utf-8', errors='ignore')
 
Last edited:

Tipher88

New Member
Had an issue with this tool. It would crash whenever I was playing any file in VLC that had Unicode characters in its meta-data.

Fortunately, was able to fix the problem by modifying 5 lines of python code.

If you could publish a fixed version of the tool, I'm sure other folks might appreciate it.

Details on the code fixes below.

1)Change
import os, time, datetime, requests
to
import os, time, datetime, requests, codecs

2)Change
root = ET.fromstring(r.text)
to
root = ET.fromstring(r.content)

3)Change
print(currentSongInfo)
to
print(currentSongInfo.encode('utf-8', 'ignore'))

4)Change
textFile = open('NowPlaying.txt', 'w')
to
textFile = codecs.open('NowPlaying.txt', 'w', encoding='utf-8', errors='ignore')

5)Change
textFile = open('NowPlaying_History.txt', 'a')
to
textFile = codecs.open('NowPlaying_History.txt', 'a', encoding='utf-8', errors='ignore')

Hey AbyssHunted! Thanks for pointing out the bug and also for submitting the fix for it! Update is incoming shortly.
 

Mitsunee

New Member
I went and got Python 3.4.3 64-bit to try this, but I get an error message saying that it can't find the module request? (I guessed it's some kind of include, so I tried commenting it out, but it is indeed needed).
 

mathwizi2005

New Member
I'm getting Invalid Syntax errors running the requests command.
Note I have NEVER run python myself, its always been a self-contained script or a script that grabbed dependencies on its own if they didn't exist already.
(I only muck about with Lua, Python is beyond me)
cec395a40d.jpg
 

Tipher88

New Member
I'm getting Invalid Syntax errors running the requests command.
Note I have NEVER run python myself, its always been a self-contained script or a script that grabbed dependencies on its own if they didn't exist already.
(I only muck about with Lua, Python is beyond me)
cec395a40d.jpg

Hi mathwizi2005,

The pip command should not be run inside python's interpreter, but only at the command prompt/terminal level (the same level that you issue normal commands). If you don't have pip installed already then you can follow the guide linked on this site.
 

mathwizi2005

New Member
Installed, ended up ignoring any syntax symbols and had cmd do its thing. (again I know Lua, Python is a whole different ball game to me)
Script is working now.
 

Andrew Fabri

New Member
Thanks for these updates! I was having a problem as the program was closing when certain italian symbols were being used in the meta data (as the station I listen to is italian). With update 1.5.0 this does not happen anymore. But what is happening now is that for some reason, the station (when a specific jingle goes on air) outputs a weird meta data text and is causing the program to crash again. I managed to take a screen shot of the error and also found out what the weird text is as seen below. Would you be able to fix this in another release? Thanks!
 

Attachments

  • metadata1.PNG
    122.7 KB · Views: 280

Tipher88

New Member
Thanks for these updates! I was having a problem as the program was closing when certain italian symbols were being used in the meta data (as the station I listen to is italian). With update 1.5.0 this does not happen anymore. But what is happening now is that for some reason, the station (when a specific jingle goes on air) outputs a weird meta data text and is causing the program to crash again. I managed to take a screen shot of the error and also found out what the weird text is as seen below. Would you be able to fix this in another release? Thanks!

I did my best to handle the crash you are encountering, if 1.6.0 doesn't fix your issue then please let me know and include a copy of the xml that is causing it.
 

Ostensible

New Member
Hi Tipher, I used python 3.5.0 to run the .py and apparently my charmap codec wasn't able to encode Japanese characters. This happened for both 2.7 and 3.5. Do you have an idea of what might have happened?

Traceback (most recent call last):
File "E:\Files\Music\NowPlaying.py", line 144, in <module>
getInfo()
File "E:\Files\Music\NowPlaying.py", line 104, in getInfo
writeSongInfoToFile(titleAndArtist, separator)
File "E:\Files\Music\NowPlaying.py", line 127, in writeSongInfoToFile
print(htmlParser.unescape(currentSongInfo))
File "C:\Users\Aya\AppData\Local\Programs\Python\Python35\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-7: character maps to <undefined>
 

Tipher88

New Member
Hi Tipher, I used python 3.5.0 to run the .py and apparently my charmap codec wasn't able to encode Japanese characters. This happened for both 2.7 and 3.5. Do you have an idea of what might have happened?

Traceback (most recent call last):
File "E:\Files\Music\NowPlaying.py", line 144, in <module>
getInfo()
File "E:\Files\Music\NowPlaying.py", line 104, in getInfo
writeSongInfoToFile(titleAndArtist, separator)
File "E:\Files\Music\NowPlaying.py", line 127, in writeSongInfoToFile
print(htmlParser.unescape(currentSongInfo))
File "C:\Users\Aya\AppData\Local\Programs\Python\Python35\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-7: character maps to <undefined>

Hi Ostensible! I can try to do some testing on my side to replicate/fix the error, however it would be much easier if you could upload a copy of the raw xml document that is causing the issue (http://localhost:8080/requests/status.xml).

Thanks for using my script!
 

Ostensible

New Member
Hi Ostensible! I can try to do some testing on my side to replicate/fix the error, however it would be much easier if you could upload a copy of the raw xml document that is causing the issue (http://localhost:8080/requests/status.xml).

Thanks for using my script!

Sure thing! Please see attached the .xml - The result is the same for any song with unicode metadata, or name. I had to change it to a .txt to upload it here
 

Attachments

  • status.txt
    2.7 KB · Views: 49

Tipher88

New Member
Any news about a fix for the above problem? Let me know if you need to see anything else

Hopefully v1.7.0 fixes your issue. It worked for me with your sample file using both python versions I tested with (v2.7.10 and v3.4.3). Let me know if you are still having issues after this update.
 

Ostensible

New Member
Everything is functioning as expected. The console log is still gibberish on cmd/mintty but the output text file is perfectly fine now, which is what I need. Thank you for your help!
 
Top