{"action":"created","comment":{"url":"https://api.github.com/repos/balloob/netdisco/pulls/comments/42324612","id":42324612,"diff_hunk":"@@ -0,0 +1,98 @@\n+\"\"\"\n+Adds support for discovery using GDM (Good Day Mate),\n+an in-house developped multicast protocol by Plex.\n+\n+Inspired by\n+  hippojay's plexGDM:\n+  https://github.com/hippojay/script.plexbmc.helper/resources/lib/plexgdm.py\n+  iBaa's PlexConnect: https://github.com/iBaa/PlexConnect/PlexAPI.py\n+\"\"\"\n+import threading\n+import socket\n+\n+\n+class GDM(object):\n+    \"\"\" Base class to discover GDM services. \"\"\"\n+\n+    def __init__(self):\n+        self.entries = []\n+        self.last_scan = None\n+        self._lock = threading.RLock()\n+\n+    def scan(self):\n+        ''' Scan the network. '''\n+        with self._lock:\n+            self.update()\n+\n+    def all(self):\n+        \"\"\"\n+        Returns all found entries.\n+        Will scan for entries if not scanned recently.\n+        \"\"\"\n+        self.scan()\n+        return list(self.entries)\n+\n+    def find_by_content_type(self, value):\n+        '''\n+        Return a list of entries that match the content_type\n+        '''\n+        self.scan()\n+        return [entry for entry in self.entries\n+                if value in entry['data']['Content_Type']]\n+\n+    def find_by_data(self, values):\n+        '''\n+        Return a list of entries that match the search parameters\n+        '''\n+        self.scan()\n+        return [entry for entry in self.entries\n+                if (item in values.items() for item in entry['data'].items())]","path":"netdisco/gdm.py","position":49,"original_position":49,"commit_id":"a8347a8d3ce9d7337ffa74c021d219e1d3c42bef","original_commit_id":"a8347a8d3ce9d7337ffa74c021d219e1d3c42bef","user":{"login":"tomduijf","id":8886397,"avatar_url":"https://avatars.githubusercontent.com/u/8886397?v=3","gravatar_id":"","url":"https://api.github.com/users/tomduijf","html_url":"https://github.com/tomduijf","followers_url":"https://api.github.com/users/tomduijf/followers","following_url":"https://api.github.com/users/tomduijf/following{/other_user}","gists_url":"https://api.github.com/users/tomduijf/gists{/gist_id}","starred_url":"https://api.github.com/users/tomduijf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomduijf/subscriptions","organizations_url":"https://api.github.com/users/tomduijf/orgs","repos_url":"https://api.github.com/users/tomduijf/repos","events_url":"https://api.github.com/users/tomduijf/events{/privacy}","received_events_url":"https://api.github.com/users/tomduijf/received_events","type":"User","site_admin":false},"body":"I was wondering how to do that (missed it in ssdp, which i did use mostly as example).\r\nLike this?\r\n```\r\n       return [entry for entry in self.entries\r\n                if all(item in values.items() for item in entry['data'].items())]\r\n```\r\nI want to return the whole dict, not just contents of entry['data']. entry['from'] contains the source IP.\r\n\r\nI've thought of adding that to the 'data' dict so result list is much simpler, but i wanted to keep the 'data' dict true to the original response.","created_at":"2015-10-18T18:49:53Z","updated_at":"2015-10-18T18:49:53Z","html_url":"https://github.com/balloob/netdisco/pull/5#discussion_r42324612","pull_request_url":"https://api.github.com/repos/balloob/netdisco/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/comments/42324612"},"html":{"href":"https://github.com/balloob/netdisco/pull/5#discussion_r42324612"},"pull_request":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/balloob/netdisco/pulls/5","id":48005443,"html_url":"https://github.com/balloob/netdisco/pull/5","diff_url":"https://github.com/balloob/netdisco/pull/5.diff","patch_url":"https://github.com/balloob/netdisco/pull/5.patch","issue_url":"https://api.github.com/repos/balloob/netdisco/issues/5","number":5,"state":"open","locked":false,"title":"Initial commit of GDM discovery support","user":{"login":"tomduijf","id":8886397,"avatar_url":"https://avatars.githubusercontent.com/u/8886397?v=3","gravatar_id":"","url":"https://api.github.com/users/tomduijf","html_url":"https://github.com/tomduijf","followers_url":"https://api.github.com/users/tomduijf/followers","following_url":"https://api.github.com/users/tomduijf/following{/other_user}","gists_url":"https://api.github.com/users/tomduijf/gists{/gist_id}","starred_url":"https://api.github.com/users/tomduijf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomduijf/subscriptions","organizations_url":"https://api.github.com/users/tomduijf/orgs","repos_url":"https://api.github.com/users/tomduijf/repos","events_url":"https://api.github.com/users/tomduijf/events{/privacy}","received_events_url":"https://api.github.com/users/tomduijf/received_events","type":"User","site_admin":false},"body":"Hi Balloob,\r\n\r\nThis PR introduces 'GDM' support.\r\nIt's an auto-discovery method like SSDP, made by Plex.\r\n\r\nI'd like to use this to autodiscover plex media servers in HA, similar as Hue discovery is done now.\r\n\r\nHope you like","created_at":"2015-10-18T10:06:04Z","updated_at":"2015-10-18T18:49:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e9904e9e90758692057ae8059e1d41c56dad4bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/balloob/netdisco/pulls/5/commits","review_comments_url":"https://api.github.com/repos/balloob/netdisco/pulls/5/comments","review_comment_url":"https://api.github.com/repos/balloob/netdisco/pulls/comments{/number}","comments_url":"https://api.github.com/repos/balloob/netdisco/issues/5/comments","statuses_url":"https://api.github.com/repos/balloob/netdisco/statuses/a8347a8d3ce9d7337ffa74c021d219e1d3c42bef","head":{"label":"tomduijf:gdm","ref":"gdm","sha":"a8347a8d3ce9d7337ffa74c021d219e1d3c42bef","user":{"login":"tomduijf","id":8886397,"avatar_url":"https://avatars.githubusercontent.com/u/8886397?v=3","gravatar_id":"","url":"https://api.github.com/users/tomduijf","html_url":"https://github.com/tomduijf","followers_url":"https://api.github.com/users/tomduijf/followers","following_url":"https://api.github.com/users/tomduijf/following{/other_user}","gists_url":"https://api.github.com/users/tomduijf/gists{/gist_id}","starred_url":"https://api.github.com/users/tomduijf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomduijf/subscriptions","organizations_url":"https://api.github.com/users/tomduijf/orgs","repos_url":"https://api.github.com/users/tomduijf/repos","events_url":"https://api.github.com/users/tomduijf/events{/privacy}","received_events_url":"https://api.github.com/users/tomduijf/received_events","type":"User","site_admin":false},"repo":{"id":41105118,"name":"netdisco","full_name":"tomduijf/netdisco","owner":{"login":"tomduijf","id":8886397,"avatar_url":"https://avatars.githubusercontent.com/u/8886397?v=3","gravatar_id":"","url":"https://api.github.com/users/tomduijf","html_url":"https://github.com/tomduijf","followers_url":"https://api.github.com/users/tomduijf/followers","following_url":"https://api.github.com/users/tomduijf/following{/other_user}","gists_url":"https://api.github.com/users/tomduijf/gists{/gist_id}","starred_url":"https://api.github.com/users/tomduijf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomduijf/subscriptions","organizations_url":"https://api.github.com/users/tomduijf/orgs","repos_url":"https://api.github.com/users/tomduijf/repos","events_url":"https://api.github.com/users/tomduijf/events{/privacy}","received_events_url":"https://api.github.com/users/tomduijf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tomduijf/netdisco","description":"Python library to scan local network for mDNS and uPnP services and devices.","fork":true,"url":"https://api.github.com/repos/tomduijf/netdisco","forks_url":"https://api.github.com/repos/tomduijf/netdisco/forks","keys_url":"https://api.github.com/repos/tomduijf/netdisco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tomduijf/netdisco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tomduijf/netdisco/teams","hooks_url":"https://api.github.com/repos/tomduijf/netdisco/hooks","issue_events_url":"https://api.github.com/repos/tomduijf/netdisco/issues/events{/number}","events_url":"https://api.github.com/repos/tomduijf/netdisco/events","assignees_url":"https://api.github.com/repos/tomduijf/netdisco/assignees{/user}","branches_url":"https://api.github.com/repos/tomduijf/netdisco/branches{/branch}","tags_url":"https://api.github.com/repos/tomduijf/netdisco/tags","blobs_url":"https://api.github.com/repos/tomduijf/netdisco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tomduijf/netdisco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tomduijf/netdisco/git/refs{/sha}","trees_url":"https://api.github.com/repos/tomduijf/netdisco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tomduijf/netdisco/statuses/{sha}","languages_url":"https://api.github.com/repos/tomduijf/netdisco/languages","stargazers_url":"https://api.github.com/repos/tomduijf/netdisco/stargazers","contributors_url":"https://api.github.com/repos/tomduijf/netdisco/contributors","subscribers_url":"https://api.github.com/repos/tomduijf/netdisco/subscribers","subscription_url":"https://api.github.com/repos/tomduijf/netdisco/subscription","commits_url":"https://api.github.com/repos/tomduijf/netdisco/commits{/sha}","git_commits_url":"https://api.github.com/repos/tomduijf/netdisco/git/commits{/sha}","comments_url":"https://api.github.com/repos/tomduijf/netdisco/comments{/number}","issue_comment_url":"https://api.github.com/repos/tomduijf/netdisco/issues/comments{/number}","contents_url":"https://api.github.com/repos/tomduijf/netdisco/contents/{+path}","compare_url":"https://api.github.com/repos/tomduijf/netdisco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tomduijf/netdisco/merges","archive_url":"https://api.github.com/repos/tomduijf/netdisco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tomduijf/netdisco/downloads","issues_url":"https://api.github.com/repos/tomduijf/netdisco/issues{/number}","pulls_url":"https://api.github.com/repos/tomduijf/netdisco/pulls{/number}","milestones_url":"https://api.github.com/repos/tomduijf/netdisco/milestones{/number}","notifications_url":"https://api.github.com/repos/tomduijf/netdisco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tomduijf/netdisco/labels{/name}","releases_url":"https://api.github.com/repos/tomduijf/netdisco/releases{/id}","created_at":"2015-08-20T15:57:42Z","updated_at":"2015-08-20T15:57:42Z","pushed_at":"2015-10-18T10:15:38Z","git_url":"git://github.com/tomduijf/netdisco.git","ssh_url":"git@github.com:tomduijf/netdisco.git","clone_url":"https://github.com/tomduijf/netdisco.git","svn_url":"https://github.com/tomduijf/netdisco","homepage":"","size":110,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"balloob:master","ref":"master","sha":"a3b71e16f2ced748af950114d503fa7962d79685","user":{"login":"balloob","id":1444314,"avatar_url":"https://avatars.githubusercontent.com/u/1444314?v=3","gravatar_id":"","url":"https://api.github.com/users/balloob","html_url":"https://github.com/balloob","followers_url":"https://api.github.com/users/balloob/followers","following_url":"https://api.github.com/users/balloob/following{/other_user}","gists_url":"https://api.github.com/users/balloob/gists{/gist_id}","starred_url":"https://api.github.com/users/balloob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balloob/subscriptions","organizations_url":"https://api.github.com/users/balloob/orgs","repos_url":"https://api.github.com/users/balloob/repos","events_url":"https://api.github.com/users/balloob/events{/privacy}","received_events_url":"https://api.github.com/users/balloob/received_events","type":"User","site_admin":false},"repo":{"id":28765925,"name":"netdisco","full_name":"balloob/netdisco","owner":{"login":"balloob","id":1444314,"avatar_url":"https://avatars.githubusercontent.com/u/1444314?v=3","gravatar_id":"","url":"https://api.github.com/users/balloob","html_url":"https://github.com/balloob","followers_url":"https://api.github.com/users/balloob/followers","following_url":"https://api.github.com/users/balloob/following{/other_user}","gists_url":"https://api.github.com/users/balloob/gists{/gist_id}","starred_url":"https://api.github.com/users/balloob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balloob/subscriptions","organizations_url":"https://api.github.com/users/balloob/orgs","repos_url":"https://api.github.com/users/balloob/repos","events_url":"https://api.github.com/users/balloob/events{/privacy}","received_events_url":"https://api.github.com/users/balloob/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/balloob/netdisco","description":"Python library to scan local network for mDNS and uPnP services and devices.","fork":false,"url":"https://api.github.com/repos/balloob/netdisco","forks_url":"https://api.github.com/repos/balloob/netdisco/forks","keys_url":"https://api.github.com/repos/balloob/netdisco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/balloob/netdisco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/balloob/netdisco/teams","hooks_url":"https://api.github.com/repos/balloob/netdisco/hooks","issue_events_url":"https://api.github.com/repos/balloob/netdisco/issues/events{/number}","events_url":"https://api.github.com/repos/balloob/netdisco/events","assignees_url":"https://api.github.com/repos/balloob/netdisco/assignees{/user}","branches_url":"https://api.github.com/repos/balloob/netdisco/branches{/branch}","tags_url":"https://api.github.com/repos/balloob/netdisco/tags","blobs_url":"https://api.github.com/repos/balloob/netdisco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/balloob/netdisco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/balloob/netdisco/git/refs{/sha}","trees_url":"https://api.github.com/repos/balloob/netdisco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/balloob/netdisco/statuses/{sha}","languages_url":"https://api.github.com/repos/balloob/netdisco/languages","stargazers_url":"https://api.github.com/repos/balloob/netdisco/stargazers","contributors_url":"https://api.github.com/repos/balloob/netdisco/contributors","subscribers_url":"https://api.github.com/repos/balloob/netdisco/subscribers","subscription_url":"https://api.github.com/repos/balloob/netdisco/subscription","commits_url":"https://api.github.com/repos/balloob/netdisco/commits{/sha}","git_commits_url":"https://api.github.com/repos/balloob/netdisco/git/commits{/sha}","comments_url":"https://api.github.com/repos/balloob/netdisco/comments{/number}","issue_comment_url":"https://api.github.com/repos/balloob/netdisco/issues/comments{/number}","contents_url":"https://api.github.com/repos/balloob/netdisco/contents/{+path}","compare_url":"https://api.github.com/repos/balloob/netdisco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/balloob/netdisco/merges","archive_url":"https://api.github.com/repos/balloob/netdisco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/balloob/netdisco/downloads","issues_url":"https://api.github.com/repos/balloob/netdisco/issues{/number}","pulls_url":"https://api.github.com/repos/balloob/netdisco/pulls{/number}","milestones_url":"https://api.github.com/repos/balloob/netdisco/milestones{/number}","notifications_url":"https://api.github.com/repos/balloob/netdisco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/balloob/netdisco/labels{/name}","releases_url":"https://api.github.com/repos/balloob/netdisco/releases{/id}","created_at":"2015-01-04T06:07:06Z","updated_at":"2015-09-28T05:59:37Z","pushed_at":"2015-10-18T10:06:05Z","git_url":"git://github.com/balloob/netdisco.git","ssh_url":"git@github.com:balloob/netdisco.git","clone_url":"https://github.com/balloob/netdisco.git","svn_url":"https://github.com/balloob/netdisco","homepage":"","size":255,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/5"},"html":{"href":"https://github.com/balloob/netdisco/pull/5"},"issue":{"href":"https://api.github.com/repos/balloob/netdisco/issues/5"},"comments":{"href":"https://api.github.com/repos/balloob/netdisco/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/balloob/netdisco/statuses/a8347a8d3ce9d7337ffa74c021d219e1d3c42bef"}}}}