Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port pulseaudio_dlna to python3.8 and fix issues #404

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emembrives
Copy link

This change ports pulseaudio_dlna to python3.8, for compatibility with Ubuntu 20.04. Tested with Chromecast.

This change ports pulseaudio_dlna to python3.8, for compatibility with
Ubuntu 20.04. Tested with Chromecast.
@polyzen
Copy link

polyzen commented May 29, 2020

There's already been work on porting to Python 3:
https://github.com/masmu/pulseaudio-dlna/tree/python3
#389
#398

Perhaps you should rebase on the python3 branch or something?

@avodonosov
Copy link

README is not updated, for example, the installation instructions still refer python2

@avodonosov
Copy link

avodonosov commented May 31, 2020

Makefile is also not updated ...

Update:
Nevermind, I cloned your repo but was using the master branch instead of the 2to3 branch.

@avodonosov
Copy link

avodonosov commented May 31, 2020

I switched to the correct branch now.

After running make and ./bin/pulseaudio-dlna I have this error:

...
05-31 04:46:10 pulseaudio_dlna.pulseaudio                     INFO     Connecting to pulseaudio on "unix:path=/run/user/1000/pulse/dbus-socket" ...
05-31 04:46:11 zeroconf                                       WARNING  packets() made no progress adding records; returning
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/__init__.py", line 55, in launch_discover
    discover.search(ssdp_ttl=ttl)
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/ssdp/discover.py", line 68, in search
    self._search(self.host or '', ssdp_ttl, ssdp_mx, ssdp_amount)
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/ssdp/discover.py", line 113, in _search
    self.cb_on_device_response(header, address)
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/__init__.py", line 40, in wrapper
    self.holder.add_device(device)
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/holder.py", line 111, in add_device
    device.activate(config)
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/renderer.py", line 72, in activate
    mime_types = self.get_mime_types()
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/renderer.py", line 205, in get_mime_types
    d = self.upnp_device.get_protocol_info()
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/pyupnpv2/__init__.py", line 596, in get_protocol_info
    response = self.connection_manager.get_protocol_info(*args, **kwargs)
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/pyupnpv2/__init__.py", line 475, in get_protocol_info
    return self._execute_action('GetProtocolInfo', {})
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/pyupnpv2/__init__.py", line 355, in _execute_action
    response = self._do_post_request(self.control_url, headers, data)
  File "/home/anton/my/unpacked/pulseaudio-dlna-py3/pulseaudio_dlna/plugins/dlna/pyupnpv2/__init__.py", line 339, in _do_post_request
    url, data=data.encode(self.ENCODING), headers=headers,
AttributeError: 'bytes' object has no attribute 'encode'
05-31 04:46:13 zeroconf                                       WARNING  packets() made no progress adding records; returning
05-31 04:46:17 zeroconf                                       WARNING  packets() made no progress adding records; returning
05-31 04:46:25 zeroconf                                       WARNING  packets() made no progress adding records; returning
...

@av8r
Copy link

av8r commented Aug 30, 2020

Work fine using @emembrives branch and applying the 2 lines following patch.
Test with Freebox player and a Denon DRA-800H amplifier (not yet listed in the README.md)

diff --git a/pulseaudio_dlna/images.py b/pulseaudio_dlna/images.py
index 375997e..c27e281 100644
--- a/pulseaudio_dlna/images.py
+++ b/pulseaudio_dlna/images.py
@@ -99,7 +99,7 @@ class BaseImage(object):

 def _read_data(self):
     try:
  •        with open(self.path) as h:
    
  •        with open(self.path, 'rb') as h:
               self._data = h.read()
       except EnvironmentError:
           raise ImageNotAccessible(self.path)
    

diff --git a/pulseaudio_dlna/plugins/dlna/pyupnpv2/init.py b/pulseaudio_dlna/plugins/dlna/pyupnpv2/init.py
index 4dffb43..f772ebd 100644
--- a/pulseaudio_dlna/plugins/dlna/pyupnpv2/init.py
+++ b/pulseaudio_dlna/plugins/dlna/pyupnpv2/init.py
@@ -336,7 +336,7 @@ class UpnpService(object):
try:
response = None
response = self._request.post(

  •            url, data=data.encode(self.ENCODING), headers=headers,
    
  •            url, data=data, headers=headers,
               timeout=self.TIMEOUT)
           return response
       finally:
    

@Lapeth
Copy link

Lapeth commented Apr 23, 2021

On top of av8r's diff, I had to apply:

diff --git a/pulseaudio_dlna/plugins/dlna/renderer.py b/pulseaudio_dlna/plugins/dlna/renderer.py
index a674ef3..cba655f 100644
--- a/pulseaudio_dlna/plugins/dlna/renderer.py
+++ b/pulseaudio_dlna/plugins/dlna/renderer.py
@@ -204,6 +204,8 @@ class DLNAMediaRenderer(pulseaudio_dlna.plugins.renderer.BaseRenderer):
         try:
             d = self.upnp_device.get_protocol_info()
             sinks = d['GetProtocolInfoResponse']['Sink']
+            if type(sinks) == dict:
+                sinks = sinks['#text']
             for sink in sinks.split(','):
                 attributes = sink.strip().split(':')
                 if len(attributes) >= 4:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants