Code Monkey home page Code Monkey logo

nano-dlna's Issues

HTTP Error 500

I have the same issue #11, and the solution of changing branch to feature/debug-log also works for me.
Thanks for the useful tool.

help - code inside script

can you show me how I use its functions within a python script to use in another project?
I need you to discover the devices and put them on a list so that I can select and then send the url to the TV, I already have the proxy server to serve the content

HTTP Error

Hi, thanks for sharing this tool, it appears to be exactly what i was looking for.

Although I am unable to get any media to play. I am trying to stream from arch linux + python 3.9 to a sony bdp-s390 bluray play. The device is found using nanodlna list, but when trying: nanodlna play movie.mp4 it returns the following error.

Traceback (most recent call last):
  File "/home/clu/.local/bin/nanodlna", line 8, in <module>
    sys.exit(run())
  File "/home/clu/.local/lib/python3.9/site-packages/nanodlna/cli.py", line 96, in run
    args.func(args)
  File "/home/clu/.local/lib/python3.9/site-packages/nanodlna/cli.py", line 73, in play
    dlna.play(files_urls, device)
  File "/home/clu/.local/lib/python3.9/site-packages/nanodlna/dlna.py", line 54, in play
    send_dlna_action(device, video_data, "SetAVTransportURI")
  File "/home/clu/.local/lib/python3.9/site-packages/nanodlna/dlna.py", line 29, in send_dlna_action
    urllibreq.urlopen(request)
  File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error

Any thoughts you may have would be very appreciated!

Streaming doesn't stop even when the video ended

It would be great to have a function or a command to get the transport status of the device, either for checking if it's available for consuming another video or to check if the last consumed video ended, since nano-dlna does not do this.

Is there a way to close o exit the program?

I love this program but I'm having a problem while trying to close it... It seems that the only way for me to close is by killin the process with killall nanodlna. Not even "ctrl + c" works! Anyway thanks for this piece of code

traceback when devices does not support expected UPNP_DEFAULT_SERVICE_TYPE

While attempting to test version 0.1.6, I encountered the following traceback:

$ nanodlna list
Traceback (most recent call last):
  File "/bin/nanodlna", line 11, in <module>
    load_entry_point('nanodlna==0.1.6', 'console_scripts', 'nanodlna')()
  File "/usr/lib/python3.6/site-packages/nanodlna/cli.py", line 96, in run
    args.func(args)
  File "/usr/lib/python3.6/site-packages/nanodlna/cli.py", line 26, in list_devices
    my_devices = devices.get_devices(args.timeout)
  File "/usr/lib/python3.6/site-packages/nanodlna/devices.py", line 87, in get_devices
    devices = [register_device(location_url) for location_url in devices_urls]
  File "/usr/lib/python3.6/site-packages/nanodlna/devices.py", line 87, in <listcomp>
    devices = [register_device(location_url) for location_url in devices_urls]
  File "/usr/lib/python3.6/site-packages/nanodlna/devices.py", line 42, in register_device
    UPNP_DEFAULT_SERVICE_TYPE
AttributeError: 'NoneType' object has no attribute 'text'

Digging into this a bit it appears nanodlna is expecting DLNA devices to advertise one specific service type: urn:schemas-upnp-org:service:AVTransport:1

However, the device in question here (Sonos CONNECT:AMP) does not advertise this service.

After applying the following patch, I found that a second DLNA device on the network also does not advertise this service, Rygel under Linux.

$ git diff
diff --git a/nanodlna/devices.py b/nanodlna/devices.py
index 2e95e96..106bc64 100644
--- a/nanodlna/devices.py
+++ b/nanodlna/devices.py
@@ -37,12 +37,15 @@ def register_device(location_url):
 
     friendly_name = info.find("./device/friendlyName").text
 
-    path = info.find(
-        "./device/serviceList/service/[serviceType='{0}']/controlURL".format(
-            UPNP_DEFAULT_SERVICE_TYPE
-        )
-    ).text
-    action_url = urllibparse.urljoin(location_url, path)
+    try:
+        path = info.find(
+            "./device/serviceList/service/[serviceType='{0}']/controlURL".format(
+                UPNP_DEFAULT_SERVICE_TYPE
+            )
+        ).text
+        action_url = urllibparse.urljoin(location_url, path)
+    except AttributeError:
+        action_url = None
 
     device = {
         "location": location_url,

I'll fork the project and submit a pull request with the above fix.

Crash on OpenBSD

$ ~/.local/bin/nanodlna list
nano-dlna log will be saved here: /tmp/tmp02_tdvqe/nanodlna-2021-10-08_11-36-16.log
Traceback (most recent call last):
  File "/home/edd/.local/bin/nanodlna", line 8, in <module>
    sys.exit(run())
  File "/home/edd/.local/lib/python3.8/site-packages/nanodlna/cli.py", line 150, in run
    args.func(args)
  File "/home/edd/.local/lib/python3.8/site-packages/nanodlna/cli.py", line 55, in list_devices
    my_devices = devices.get_devices(args.timeout)
  File "/home/edd/.local/lib/python3.8/site-packages/nanodlna/devices.py", line 77, in get_devices
    s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 4)
OSError: [Errno 22] Invalid argument

Any ideas?

Compatibility with Python 2.7

The setup.py specifies that this package is compatible with Python 2.7. When executing nanodlna list i get the error No module named request. Devices.py imports urllib.request which is, as far as i understand a Python 3 package. Is there a possibility to run nanodlna with Python 2.7?

Errors on python 3.10

nanodlna list
nano-dlna log will be saved here: /tmp/tmplrlgcziw/nanodlna-2022-02-05_14-24-40.log
Traceback (most recent call last):
File "/usr/bin/nanodlna", line 8, in
sys.exit(run())
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 150, in run
args.func(args)
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 55, in list_devices
my_devices = devices.get_devices(args.timeout)
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 114, in get_devices
devices = [register_device(location_url) for location_url in devices_urls]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 114, in
devices = [register_device(location_url) for location_url in devices_urls]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 40, in register_device
friendly_name = info.find("./device/friendlyName").text
AttributeError: 'NoneType' object has no attribute 'text'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.