File: plex_mediaserver.py

package info (click to toggle)
python-netdisco 2.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 508 kB
  • sloc: python: 1,532; xml: 247; sh: 10; makefile: 8
file content (21 lines) | stat: -rw-r--r-- 751 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Discover PlexMediaServer."""
from . import GDMDiscoverable
from ..const import ATTR_NAME, ATTR_HOST, ATTR_PORT, ATTR_URLBASE


class Discoverable(GDMDiscoverable):
    """Add support for discovering Plex Media Server."""

    def info_from_entry(self, entry):
        """Return most important info from a GDM entry."""
        return {
            ATTR_NAME: entry['data']['Name'],
            ATTR_HOST: entry['from'][0],
            ATTR_PORT: entry['data']['Port'],
            ATTR_URLBASE: 'https://%s:%s' % (entry['from'][0],
                                             entry['data']['Port'])
        }

    def get_entries(self):
        """Return all PMS entries."""
        return self.find_by_data({'Content-Type': 'plex/media-server'})