{"action":"created","comment":{"url":"https://api.github.com/repos/balloob/netdisco/pulls/comments/56489288","id":56489288,"diff_hunk":"@@ -0,0 +1,65 @@\n+\"\"\"\n+Squeezebox/Logitech Media server discovery.\n+\"\"\"\n+import socket\n+import threading\n+\n+DISCOVERY_PORT = 3483\n+DEFAULT_DISCOVERY_TIMEOUT = 1\n+\n+\n+class LMS(object):\n+    \"\"\"Base class to discover Logitech Media servers.\"\"\"\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+        \"\"\"Scan and return all found entries.\"\"\"\n+        self.scan()\n+        return list(self.entries)\n+\n+    def update(self):\n+        \"\"\"Scan network for Logitech Media Servers.\"\"\"\n+        lms_ip = '<broadcast>'\n+        lms_port = DISCOVERY_PORT\n+        lms_msg = b\"d.................\"\n+        lms_timeout = DEFAULT_DISCOVERY_TIMEOUT\n+\n+        entries = []\n+\n+        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n+        sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)\n+        sock.settimeout(lms_timeout)\n+        sock.bind(('', 0))\n+\n+        try:\n+            sock.sendto(lms_msg, (lms_ip, lms_port))\n+\n+            while True:\n+                try:\n+                    data, server = sock.recvfrom(1024)\n+                    entries.append({'data': data,","path":"netdisco/lms.py","position":null,"original_position":49,"commit_id":"dcac2452ed9dc9a88227486162acbc2db08c27ef","original_commit_id":"602b11bafbd3cb59d0b7bed15fe110795d39e25f","user":{"login":"jaharkes","id":394722,"avatar_url":"https://avatars.githubusercontent.com/u/394722?v=3","gravatar_id":"","url":"https://api.github.com/users/jaharkes","html_url":"https://github.com/jaharkes","followers_url":"https://api.github.com/users/jaharkes/followers","following_url":"https://api.github.com/users/jaharkes/following{/other_user}","gists_url":"https://api.github.com/users/jaharkes/gists{/gist_id}","starred_url":"https://api.github.com/users/jaharkes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaharkes/subscriptions","organizations_url":"https://api.github.com/users/jaharkes/orgs","repos_url":"https://api.github.com/users/jaharkes/repos","events_url":"https://api.github.com/users/jaharkes/events{/privacy}","received_events_url":"https://api.github.com/users/jaharkes/received_events","type":"User","site_admin":false},"body":"Yes, good idea. Added.","created_at":"2016-03-17T11:23:40Z","updated_at":"2016-03-17T11:23:40Z","html_url":"https://github.com/balloob/netdisco/pull/15#discussion_r56489288","pull_request_url":"https://api.github.com/repos/balloob/netdisco/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/comments/56489288"},"html":{"href":"https://github.com/balloob/netdisco/pull/15#discussion_r56489288"},"pull_request":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/balloob/netdisco/pulls/15","id":63170570,"html_url":"https://github.com/balloob/netdisco/pull/15","diff_url":"https://github.com/balloob/netdisco/pull/15.diff","patch_url":"https://github.com/balloob/netdisco/pull/15.patch","issue_url":"https://api.github.com/repos/balloob/netdisco/issues/15","number":15,"state":"open","locked":false,"title":"Add discovery for local Logitech Media servers.","user":{"login":"jaharkes","id":394722,"avatar_url":"https://avatars.githubusercontent.com/u/394722?v=3","gravatar_id":"","url":"https://api.github.com/users/jaharkes","html_url":"https://github.com/jaharkes","followers_url":"https://api.github.com/users/jaharkes/followers","following_url":"https://api.github.com/users/jaharkes/following{/other_user}","gists_url":"https://api.github.com/users/jaharkes/gists{/gist_id}","starred_url":"https://api.github.com/users/jaharkes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaharkes/subscriptions","organizations_url":"https://api.github.com/users/jaharkes/orgs","repos_url":"https://api.github.com/users/jaharkes/repos","events_url":"https://api.github.com/users/jaharkes/events{/privacy}","received_events_url":"https://api.github.com/users/jaharkes/received_events","type":"User","site_admin":false},"body":"Simple combination of the discovery code submitted to home-assistant by @molobrakos in balloob/home-assistant#1561 and the existing Plex media server support code, fixes #10.","created_at":"2016-03-17T04:00:32Z","updated_at":"2016-03-17T11:23:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af505dd3f1bd6178f3829dbd0bfa3a8599b2acbe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/balloob/netdisco/pulls/15/commits","review_comments_url":"https://api.github.com/repos/balloob/netdisco/pulls/15/comments","review_comment_url":"https://api.github.com/repos/balloob/netdisco/pulls/comments{/number}","comments_url":"https://api.github.com/repos/balloob/netdisco/issues/15/comments","statuses_url":"https://api.github.com/repos/balloob/netdisco/statuses/dcac2452ed9dc9a88227486162acbc2db08c27ef","head":{"label":"jaharkes:logitech_media_server","ref":"logitech_media_server","sha":"dcac2452ed9dc9a88227486162acbc2db08c27ef","user":{"login":"jaharkes","id":394722,"avatar_url":"https://avatars.githubusercontent.com/u/394722?v=3","gravatar_id":"","url":"https://api.github.com/users/jaharkes","html_url":"https://github.com/jaharkes","followers_url":"https://api.github.com/users/jaharkes/followers","following_url":"https://api.github.com/users/jaharkes/following{/other_user}","gists_url":"https://api.github.com/users/jaharkes/gists{/gist_id}","starred_url":"https://api.github.com/users/jaharkes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaharkes/subscriptions","organizations_url":"https://api.github.com/users/jaharkes/orgs","repos_url":"https://api.github.com/users/jaharkes/repos","events_url":"https://api.github.com/users/jaharkes/events{/privacy}","received_events_url":"https://api.github.com/users/jaharkes/received_events","type":"User","site_admin":false},"repo":{"id":52934378,"name":"netdisco","full_name":"jaharkes/netdisco","owner":{"login":"jaharkes","id":394722,"avatar_url":"https://avatars.githubusercontent.com/u/394722?v=3","gravatar_id":"","url":"https://api.github.com/users/jaharkes","html_url":"https://github.com/jaharkes","followers_url":"https://api.github.com/users/jaharkes/followers","following_url":"https://api.github.com/users/jaharkes/following{/other_user}","gists_url":"https://api.github.com/users/jaharkes/gists{/gist_id}","starred_url":"https://api.github.com/users/jaharkes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaharkes/subscriptions","organizations_url":"https://api.github.com/users/jaharkes/orgs","repos_url":"https://api.github.com/users/jaharkes/repos","events_url":"https://api.github.com/users/jaharkes/events{/privacy}","received_events_url":"https://api.github.com/users/jaharkes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jaharkes/netdisco","description":"Python library to scan local network for mDNS and uPnP services and devices.","fork":true,"url":"https://api.github.com/repos/jaharkes/netdisco","forks_url":"https://api.github.com/repos/jaharkes/netdisco/forks","keys_url":"https://api.github.com/repos/jaharkes/netdisco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jaharkes/netdisco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jaharkes/netdisco/teams","hooks_url":"https://api.github.com/repos/jaharkes/netdisco/hooks","issue_events_url":"https://api.github.com/repos/jaharkes/netdisco/issues/events{/number}","events_url":"https://api.github.com/repos/jaharkes/netdisco/events","assignees_url":"https://api.github.com/repos/jaharkes/netdisco/assignees{/user}","branches_url":"https://api.github.com/repos/jaharkes/netdisco/branches{/branch}","tags_url":"https://api.github.com/repos/jaharkes/netdisco/tags","blobs_url":"https://api.github.com/repos/jaharkes/netdisco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jaharkes/netdisco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jaharkes/netdisco/git/refs{/sha}","trees_url":"https://api.github.com/repos/jaharkes/netdisco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jaharkes/netdisco/statuses/{sha}","languages_url":"https://api.github.com/repos/jaharkes/netdisco/languages","stargazers_url":"https://api.github.com/repos/jaharkes/netdisco/stargazers","contributors_url":"https://api.github.com/repos/jaharkes/netdisco/contributors","subscribers_url":"https://api.github.com/repos/jaharkes/netdisco/subscribers","subscription_url":"https://api.github.com/repos/jaharkes/netdisco/subscription","commits_url":"https://api.github.com/repos/jaharkes/netdisco/commits{/sha}","git_commits_url":"https://api.github.com/repos/jaharkes/netdisco/git/commits{/sha}","comments_url":"https://api.github.com/repos/jaharkes/netdisco/comments{/number}","issue_comment_url":"https://api.github.com/repos/jaharkes/netdisco/issues/comments{/number}","contents_url":"https://api.github.com/repos/jaharkes/netdisco/contents/{+path}","compare_url":"https://api.github.com/repos/jaharkes/netdisco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jaharkes/netdisco/merges","archive_url":"https://api.github.com/repos/jaharkes/netdisco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jaharkes/netdisco/downloads","issues_url":"https://api.github.com/repos/jaharkes/netdisco/issues{/number}","pulls_url":"https://api.github.com/repos/jaharkes/netdisco/pulls{/number}","milestones_url":"https://api.github.com/repos/jaharkes/netdisco/milestones{/number}","notifications_url":"https://api.github.com/repos/jaharkes/netdisco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jaharkes/netdisco/labels{/name}","releases_url":"https://api.github.com/repos/jaharkes/netdisco/releases{/id}","deployments_url":"https://api.github.com/repos/jaharkes/netdisco/deployments","created_at":"2016-03-02T04:41:45Z","updated_at":"2016-03-02T04:41:46Z","pushed_at":"2016-03-17T11:23:05Z","git_url":"git://github.com/jaharkes/netdisco.git","ssh_url":"git@github.com:jaharkes/netdisco.git","clone_url":"https://github.com/jaharkes/netdisco.git","svn_url":"https://github.com/jaharkes/netdisco","homepage":"","size":45,"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":"855a7a54ebad436de1a7fb0758e83d0eb16f24a1","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}","deployments_url":"https://api.github.com/repos/balloob/netdisco/deployments","created_at":"2015-01-04T06:07:06Z","updated_at":"2016-03-13T15:40:56Z","pushed_at":"2016-03-17T11:23: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":44,"stargazers_count":18,"watchers_count":18,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":3,"forks":11,"open_issues":3,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/15"},"html":{"href":"https://github.com/balloob/netdisco/pull/15"},"issue":{"href":"https://api.github.com/repos/balloob/netdisco/issues/15"},"comments":{"href":"https://api.github.com/repos/balloob/netdisco/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/balloob/netdisco/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/balloob/netdisco/statuses/dcac2452ed9dc9a88227486162acbc2db08c27ef"}}}}