Coder Social home page Coder Social logo

Comments (6)

masmu avatar masmu commented on July 19, 2024

I really like the idea.
But getting the local ip address is no simple task if you have multiple interfaces as i do.

What do you think of:

import commands
import re

def default_ipv4():
    status_code, result = commands.getstatusoutput('ip route get 255.255.255.255')
    if status_code == 0:
        match = re.findall(r"(?<=src )(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})", result)
        if match:
            return match[0]
    return None

from pulseaudio-dlna.

Takkat-Nebuk avatar Takkat-Nebuk commented on July 19, 2024

yeah ip route get sure is an alternative to hostname -I.
However if people had multiple interfaces they may prefer your still working --host option anyway.

Just a note aside: commands is deprecated in Python3 so I'd recommend subprocess.Popen instead.

from pulseaudio-dlna.

masmu avatar masmu commented on July 19, 2024

Sorry for the late reply.

A friend of mine recommended socket.gethostbyname(socket.getfqdn()), but since this is all about the important default value host i will first test it.

I will implement it this evening (hopefully).

from pulseaudio-dlna.

masmu avatar masmu commented on July 19, 2024
  • 0.2.1 - (2015-01-11)
    • TTL changed to 10 and timeout to 5 for UDP broadcasting
    • Added the --renderer-urls option to manually add UPNP devices via their control url
    • Added the --debug flag
    • The host ip address is now discovered automatically, no need to specifiy --host anymore

from pulseaudio-dlna.

Takkat-Nebuk avatar Takkat-Nebuk commented on July 19, 2024

Cool! Works great now. Thank you!

from pulseaudio-dlna.

masmu avatar masmu commented on July 19, 2024

Your welcome :)

from pulseaudio-dlna.

Related Issues (20)

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.