while listening to IPTV Radios this plugin displays Artist amd Title, we have this already in infobar showing now/next, this works only with gstreamer, this plugin works with exteplayer too or you may start it from plugin if you put it on a hotkey
[Plugin] ICY Stream Titles
- mrvica
- Thread is marked as Resolved.
-
-
Some "how to install and use" would be helpful.
-
if someone can make the .ipk file quickly and put it here! from the channel selection start an iptv radio service and afterwards the plugin, that is all, on the screen you will see artist an title, with ok you can hide and show the screen and with ch+/ch- you can switch to another service,, the titles are updated every 15 secs unless you do it with ok key, there are plugins that have stream titles like HDF Radio and others, this one is just simple
-
i modded for dreamos
online on LinuxSat Panel ;)
-
this line is missing, gives error, global name meta_byte not defined, maybe just forgotten
meta_byte = stream.read(1)
-
this line is missing, gives error, global name meta_byte not defined, maybe just forgotten
meta_byte = stream.read(1)
Code
Display Moreresponse = requests.get(stream_url, headers={'Icy-MetaData': '1'}, stream=True, timeout=10, verify=False) response.raise_for_status() headers = response.headers stream = response.raw meta_byte = stream.read(1) meta_int = headers.get('icy-metaint') if meta_int is not None: audio_length = int(meta_int) audio_data = stream.read(audio_length) # print('audio_data:', audio_data) if meta_byte: meta_length = ord(meta_byte) * 16 meta_data = stream.read(meta_length) if "StreamTitle='" in meta_data: meta_data = meta_data.split("StreamTitle='")[1].split("';")[0] else: meta_data = "N/A" # print("service_name %s" % service_name) # print("ICY title -> %s" % str(meta_data)) self["icy_title"].setText(str(service_name) + "\n\n" + str(meta_data)) else: # print("service_name %s" % service_name) # print("ICY title -> Metadata not available") self["icy_title"].setText(str(service_name) + "\n\nMetadata not available")
it?
-
not there in ipk (deb) you uploaded, just have a look
-
- look code my last reply
-
ok!
-
it doesn´t work on OpenATV py3, the code needs some changes
error a bytes-like object is required not 'str'
#meta_data = meta_data.split("StreamTitle='")[1].split("';")[0]
meta_data = meta_data.split(b"StreamTitle='")[1].split(b"';")[0]
and to get rid of prefix b'
#self["icy_title"].setText(str(service_name) + "\n\n" + str(meta_data))
self["icy_title"].setText(str(service_name) + "\n\n" + str(meta_data)[2:-1])
-
it doesn´t work on OpenATV py3, the code needs some changes
error a bytes-like object is required not 'str'
#meta_data = meta_data.split("StreamTitle='")[1].split("';")[0]
meta_data = meta_data.split(b"StreamTitle='")[1].split(b"';")[0]
and to get rid of prefix b'
#self["icy_title"].setText(str(service_name) + "\n\n" + str(meta_data))
self["icy_title"].setText(str(service_name) + "\n\n" + str(meta_data)[2:-1])
IF REQUIRED OBJECT AND NO T STR.. WHY YOU STR TYPE DATA?
-
are we talking about the same thing? did you update your code once more? I tried it on ATV 7.3 and I got error, did someone else try it on ATV? about the code snippet, I don´t know the better solution how to fix it, not the right way but works
-
no no,
I was wondering why the error occurred because str on tuple and str on txt are different..
Ok try this
-
no, Error: a bytes-like object is required not 'str', my old code with the snippet ok, seems Python 3.9 (PLi) and 3.12 (ATV) is not the same
unpleasant side effect, the non-printable chars are displayed as hex string \x... and I don´t know how to fix it, on python 2.7 (PLI 8.3) everything is fine
-
I had already warned you about this before but you obviously meant something else.
In Python 2, strings are treated as bytes by default, while in Python 3 you need to explicitly convert between bytes and strings.
-
no, Error: a bytes-like object is required not 'str', my old code with the snippet ok, seems Python 3.9 (PLi) and 3.12 (ATV) is not the same
unpleasant side effect, the non-printable chars are displayed as hex string \x... and I don´t know how to fix it, on python 2.7 (PLI 8.3) everything is fine
this is last code.. i don't have time my friend for joke.. :)
-
Code
Display Moredef icy_monitor(self): service_name = self.session.nav.getCurrentService().info().getName() ref = self.session.nav.getCurrentlyPlayingServiceReference().toString() try: stream_url = ref.split(':')[10] stream_url = stream_url.replace('%3a', ':') except IndexError: self["icy_title"].setText("Invalid reference format: " + ref) return if not stream_url.startswith(('http://', 'https://')): stream_url = 'http://' + stream_url # or 'https://' if not stream_url: self["icy_title"].setText("No valid URL supplied for streaming.") return try: response = requests.get(stream_url, headers={'Icy-MetaData': '1'}, stream=True, timeout=10, verify=False) response.raise_for_status() headers = response.headers stream = response.raw meta_byte = stream.read(1) if not isinstance(meta_byte, int): meta_byte = ord(meta_byte) meta_int = headers.get('icy-metaint') if meta_int is not None: audio_length = int(meta_int) audio_data = stream.read(audio_length) if meta_byte: meta_length = meta_byte * 16 meta_data = stream.read(meta_length) if isinstance(meta_data, bytes): meta_data = meta_data.decode('utf-8', errors='ignore') if "StreamTitle='" in meta_data: meta_data = meta_data.split("StreamTitle='")[1].split("';")[0] else: meta_data = "N/A" self["icy_title"].setText(str(service_name) + "\n\n" + meta_data) else: self["icy_title"].setText(str(service_name) + "\n\nMetadata not available") except Exception as e: self["icy_title"].setText("Error: " + str(e))
-
no bad feelings!, yeh, your latest code works on ATV 7.3, on PLi 8.3 (py2) I get error, see atached picture, PLi 9 I can´t test at the moment.
-
this version works both on py2/py3, I could fix that with non printable chars
-
mrvica
Changed the title of the thread from “ICY Stream Titles” to “[Plugin] ICY Stream Titles”.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!