{"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"rickmote.py","language":"python","identifier":"matching_line","parameters":"(lines, keyword)","argument_list":"","return_statement":"return None","docstring":"Returns the first matching line in a list of lines. See match()","docstring_summary":"Returns the first matching line in a list of lines. See match()","docstring_tokens":["Returns","the","first","matching","line","in","a","list","of","lines",".","See","match","()"],"function":"def matching_line(lines, keyword):\n \"\"\"Returns the first matching line in a list of lines. See match()\"\"\"\n for line in lines:\n matching=match(line,keyword)\n if matching!=None:\n return matching\n return None","function_tokens":["def","matching_line","(","lines",",","keyword",")",":","for","line","in","lines",":","matching","=","match","(","line",",","keyword",")","if","matching","!=","None",":","return","matching","return","None"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/rickmote.py#L68-L74"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"rickmote.py","language":"python","identifier":"match","parameters":"(line,keyword)","argument_list":"","return_statement":"","docstring":"If the first part of line (modulo blanks) matches keyword,\n returns the end of that line. Otherwise returns None","docstring_summary":"If the first part of line (modulo blanks) matches keyword,\n returns the end of that line. Otherwise returns None","docstring_tokens":["If","the","first","part","of","line","(","modulo","blanks",")","matches","keyword","returns","the","end","of","that","line",".","Otherwise","returns","None"],"function":"def match(line,keyword):\n \"\"\"If the first part of line (modulo blanks) matches keyword,\n returns the end of that line. Otherwise returns None\"\"\"\n line=line.lstrip()\n length=len(keyword)\n if line[:length] == keyword:\n return line[length:]\n else:\n return None","function_tokens":["def","match","(","line",",","keyword",")",":","line","=","line",".","lstrip","(",")","length","=","len","(","keyword",")","if","line","[",":","length","]","==","keyword",":","return","line","[","length",":","]","else",":","return","None"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/rickmote.py#L76-L84"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"rickmote.py","language":"python","identifier":"parse_cell","parameters":"(cell)","argument_list":"","return_statement":"return parsed_cell","docstring":"Applies the rules to the bunch of text describing a cell and returns the\n corresponding dictionary","docstring_summary":"Applies the rules to the bunch of text describing a cell and returns the\n corresponding dictionary","docstring_tokens":["Applies","the","rules","to","the","bunch","of","text","describing","a","cell","and","returns","the","corresponding","dictionary"],"function":"def parse_cell(cell):\n \"\"\"Applies the rules to the bunch of text describing a cell and returns the\n corresponding dictionary\"\"\"\n parsed_cell={}\n for key in rules:\n rule=rules[key]\n parsed_cell.update({key:rule(cell)})\n return parsed_cell","function_tokens":["def","parse_cell","(","cell",")",":","parsed_cell","=","{","}","for","key","in","rules",":","rule","=","rules","[","key","]","parsed_cell",".","update","(","{","key",":","rule","(","cell",")","}",")","return","parsed_cell"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/rickmote.py#L86-L93"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/dial.py","language":"python","identifier":"start_app","parameters":"(host, app_id, data=None)","argument_list":"","return_statement":"","docstring":"Starts an application.\n\n If your TV is not on will turn it on unless app_id == APP_ID_HOME.","docstring_summary":"Starts an application.","docstring_tokens":["Starts","an","application","."],"function":"def start_app(host, app_id, data=None):\n \"\"\" Starts an application.\n\n If your TV is not on will turn it on unless app_id == APP_ID_HOME. \"\"\"\n\n if data is None:\n data = {\"\": \"\"}\n\n CC_SESSION.post(_craft_app_url(host, app_id), data=data)","function_tokens":["def","start_app","(","host",",","app_id",",","data","=","None",")",":","if","data","is","None",":","data","=","{","\"\"",":","\"\"","}","CC_SESSION",".","post","(","_craft_app_url","(","host",",","app_id",")",",","data","=","data",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/dial.py#L21-L29"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/dial.py","language":"python","identifier":"quit_app","parameters":"(host, app_id=None)","argument_list":"","return_statement":"","docstring":"Quits specified application if it is running.\n If no app_id specified will quit current running app.","docstring_summary":"Quits specified application if it is running.\n If no app_id specified will quit current running app.","docstring_tokens":["Quits","specified","application","if","it","is","running",".","If","no","app_id","specified","will","quit","current","running","app","."],"function":"def quit_app(host, app_id=None):\n \"\"\" Quits specified application if it is running.\n If no app_id specified will quit current running app. \"\"\"\n\n if not app_id:\n status = get_app_status(host)\n\n if status:\n app_id = status.app_id\n\n if app_id:\n CC_SESSION.delete(_craft_app_url(host, app_id))","function_tokens":["def","quit_app","(","host",",","app_id","=","None",")",":","if","not","app_id",":","status","=","get_app_status","(","host",")","if","status",":","app_id","=","status",".","app_id","if","app_id",":","CC_SESSION",".","delete","(","_craft_app_url","(","host",",","app_id",")",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/dial.py#L32-L43"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/dial.py","language":"python","identifier":"reboot","parameters":"(host)","argument_list":"","return_statement":"","docstring":"Reboots the chromecast.","docstring_summary":"Reboots the chromecast.","docstring_tokens":["Reboots","the","chromecast","."],"function":"def reboot(host):\n \"\"\" Reboots the chromecast. \"\"\"\n CC_SESSION.post(FORMAT_BASE_URL.format(host) + \"\/setup\/reboot\",\n data='{\"params\":\"now\"}')","function_tokens":["def","reboot","(","host",")",":","CC_SESSION",".","post","(","FORMAT_BASE_URL",".","format","(","host",")","+","\"\/setup\/reboot\"",",","data","=","'{\"params\":\"now\"}'",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/dial.py#L46-L49"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/dial.py","language":"python","identifier":"get_device_status","parameters":"(host)","argument_list":"","return_statement":"","docstring":"Returns the device status as a named tuple.","docstring_summary":"Returns the device status as a named tuple.","docstring_tokens":["Returns","the","device","status","as","a","named","tuple","."],"function":"def get_device_status(host):\n \"\"\" Returns the device status as a named tuple. \"\"\"\n\n try:\n req = CC_SESSION.get(\n FORMAT_BASE_URL.format(host) + \"\/ssdp\/device-desc.xml\")\n\n status_el = ET.fromstring(req.text.encode(\"UTF-8\"))\n\n device_info_el = status_el.find(XML_NS_UPNP_DEVICE + \"device\")\n api_version_el = status_el.find(XML_NS_UPNP_DEVICE + \"specVersion\")\n\n friendly_name = _read_xml_element(device_info_el, XML_NS_UPNP_DEVICE,\n \"friendlyName\", \"Unknown Chromecast\")\n model_name = _read_xml_element(device_info_el, XML_NS_UPNP_DEVICE,\n \"modelName\", \"Unknown model name\")\n manufacturer = _read_xml_element(device_info_el, XML_NS_UPNP_DEVICE,\n \"manufacturer\",\n \"Unknown manufacturer\")\n\n api_version = (int(_read_xml_element(api_version_el,\n XML_NS_UPNP_DEVICE, \"major\", -1)),\n int(_read_xml_element(api_version_el,\n XML_NS_UPNP_DEVICE, \"minor\", -1)))\n\n return DeviceStatus(friendly_name, model_name, manufacturer,\n api_version)\n\n except (requests.exceptions.RequestException, ET.ParseError):\n return None","function_tokens":["def","get_device_status","(","host",")",":","try",":","req","=","CC_SESSION",".","get","(","FORMAT_BASE_URL",".","format","(","host",")","+","\"\/ssdp\/device-desc.xml\"",")","status_el","=","ET",".","fromstring","(","req",".","text",".","encode","(","\"UTF-8\"",")",")","device_info_el","=","status_el",".","find","(","XML_NS_UPNP_DEVICE","+","\"device\"",")","api_version_el","=","status_el",".","find","(","XML_NS_UPNP_DEVICE","+","\"specVersion\"",")","friendly_name","=","_read_xml_element","(","device_info_el",",","XML_NS_UPNP_DEVICE",",","\"friendlyName\"",",","\"Unknown Chromecast\"",")","model_name","=","_read_xml_element","(","device_info_el",",","XML_NS_UPNP_DEVICE",",","\"modelName\"",",","\"Unknown model name\"",")","manufacturer","=","_read_xml_element","(","device_info_el",",","XML_NS_UPNP_DEVICE",",","\"manufacturer\"",",","\"Unknown manufacturer\"",")","api_version","=","(","int","(","_read_xml_element","(","api_version_el",",","XML_NS_UPNP_DEVICE",",","\"major\"",",","-","1",")",")",",","int","(","_read_xml_element","(","api_version_el",",","XML_NS_UPNP_DEVICE",",","\"minor\"",",","-","1",")",")",")","return","DeviceStatus","(","friendly_name",",","model_name",",","manufacturer",",","api_version",")","except","(","requests",".","exceptions",".","RequestException",",","ET",".","ParseError",")",":","return","None"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/dial.py#L52-L81"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/dial.py","language":"python","identifier":"get_app_status","parameters":"(host, app_id=None)","argument_list":"","return_statement":"","docstring":"Returns the status of the specified app\n or else the current running app.","docstring_summary":"Returns the status of the specified app\n or else the current running app.","docstring_tokens":["Returns","the","status","of","the","specified","app","or","else","the","current","running","app","."],"function":"def get_app_status(host, app_id=None):\n \"\"\" Returns the status of the specified app\n or else the current running app. \"\"\"\n # \/apps\/ will redirect to the active app\n url = (FORMAT_APP_PATH.format(host, app_id) if app_id\n else FORMAT_BASE_URL.format(host) + \"\/apps\/\")\n\n try:\n req = CC_SESSION.get(url)\n\n if req.status_code == 204:\n return None\n\n status_el = ET.fromstring(req.text.encode(\"UTF-8\"))\n options = status_el.find(XML_NS_DIAL + \"options\").attrib\n\n app_id = _read_xml_element(status_el, XML_NS_DIAL,\n \"name\", \"Unknown application\")\n\n state = _read_xml_element(status_el, XML_NS_DIAL,\n \"state\", \"unknown\")\n\n service_el = status_el.find(XML_NS_CAST + \"servicedata\")\n\n if service_el is not None:\n service_url = _read_xml_element(service_el, XML_NS_CAST,\n \"connectionSvcURL\", None)\n\n protocols_el = service_el.find(XML_NS_CAST + \"protocols\")\n\n if protocols_el is not None:\n protocols = [el.text for el in protocols_el]\n else:\n protocols = []\n\n else:\n service_url = None\n protocols = []\n\n activity_el = status_el.find(XML_NS_CAST + \"activity-status\")\n\n if activity_el is not None:\n description = _read_xml_element(activity_el, XML_NS_CAST,\n \"description\", app_id)\n else:\n description = app_id\n\n return AppStatus(app_id, description, state,\n options, service_url, protocols)\n\n except (requests.exceptions.RequestException, ET.ParseError):\n return None","function_tokens":["def","get_app_status","(","host",",","app_id","=","None",")",":","# \/apps\/ will redirect to the active app","url","=","(","FORMAT_APP_PATH",".","format","(","host",",","app_id",")","if","app_id","else","FORMAT_BASE_URL",".","format","(","host",")","+","\"\/apps\/\"",")","try",":","req","=","CC_SESSION",".","get","(","url",")","if","req",".","status_code","==","204",":","return","None","status_el","=","ET",".","fromstring","(","req",".","text",".","encode","(","\"UTF-8\"",")",")","options","=","status_el",".","find","(","XML_NS_DIAL","+","\"options\"",")",".","attrib","app_id","=","_read_xml_element","(","status_el",",","XML_NS_DIAL",",","\"name\"",",","\"Unknown application\"",")","state","=","_read_xml_element","(","status_el",",","XML_NS_DIAL",",","\"state\"",",","\"unknown\"",")","service_el","=","status_el",".","find","(","XML_NS_CAST","+","\"servicedata\"",")","if","service_el","is","not","None",":","service_url","=","_read_xml_element","(","service_el",",","XML_NS_CAST",",","\"connectionSvcURL\"",",","None",")","protocols_el","=","service_el",".","find","(","XML_NS_CAST","+","\"protocols\"",")","if","protocols_el","is","not","None",":","protocols","=","[","el",".","text","for","el","in","protocols_el","]","else",":","protocols","=","[","]","else",":","service_url","=","None","protocols","=","[","]","activity_el","=","status_el",".","find","(","XML_NS_CAST","+","\"activity-status\"",")","if","activity_el","is","not","None",":","description","=","_read_xml_element","(","activity_el",",","XML_NS_CAST",",","\"description\"",",","app_id",")","else",":","description","=","app_id","return","AppStatus","(","app_id",",","description",",","state",",","options",",","service_url",",","protocols",")","except","(","requests",".","exceptions",".","RequestException",",","ET",".","ParseError",")",":","return","None"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/dial.py#L84-L135"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/dial.py","language":"python","identifier":"_craft_app_url","parameters":"(host, app_id=None)","argument_list":"","return_statement":"return (FORMAT_APP_PATH.format(host, app_id) if app_id\n else FORMAT_BASE_URL.format(host))","docstring":"Helper method to create a ChromeCast url given\n a host and an optional app_id.","docstring_summary":"Helper method to create a ChromeCast url given\n a host and an optional app_id.","docstring_tokens":["Helper","method","to","create","a","ChromeCast","url","given","a","host","and","an","optional","app_id","."],"function":"def _craft_app_url(host, app_id=None):\n \"\"\" Helper method to create a ChromeCast url given\n a host and an optional app_id. \"\"\"\n return (FORMAT_APP_PATH.format(host, app_id) if app_id\n else FORMAT_BASE_URL.format(host))","function_tokens":["def","_craft_app_url","(","host",",","app_id","=","None",")",":","return","(","FORMAT_APP_PATH",".","format","(","host",",","app_id",")","if","app_id","else","FORMAT_BASE_URL",".","format","(","host",")",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/dial.py#L138-L142"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/dial.py","language":"python","identifier":"_read_xml_element","parameters":"(element, xml_ns, tag_name, default=\"\")","argument_list":"","return_statement":"","docstring":"Helper method to read text from an element.","docstring_summary":"Helper method to read text from an element.","docstring_tokens":["Helper","method","to","read","text","from","an","element","."],"function":"def _read_xml_element(element, xml_ns, tag_name, default=\"\"):\n \"\"\" Helper method to read text from an element. \"\"\"\n try:\n return element.find(xml_ns + tag_name).text\n\n except AttributeError:\n return default","function_tokens":["def","_read_xml_element","(","element",",","xml_ns",",","tag_name",",","default","=","\"\"",")",":","try",":","return","element",".","find","(","xml_ns","+","tag_name",")",".","text","except","AttributeError",":","return","default"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/dial.py#L145-L151"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/upnp.py","language":"python","identifier":"discover_chromecasts","parameters":"(max_devices=None, timeout=DISCOVER_TIMEOUT)","argument_list":"","return_statement":"return ips","docstring":"Sends a message over the network to discover Chromecasts and returns\n a list of found IP addresses.\n\n Inspired by Crimsdings\n https:\/\/github.com\/crimsdings\/ChromeCast\/blob\/master\/cc_discovery.py","docstring_summary":"Sends a message over the network to discover Chromecasts and returns\n a list of found IP addresses.","docstring_tokens":["Sends","a","message","over","the","network","to","discover","Chromecasts","and","returns","a","list","of","found","IP","addresses","."],"function":"def discover_chromecasts(max_devices=None, timeout=DISCOVER_TIMEOUT):\n \"\"\"\n Sends a message over the network to discover Chromecasts and returns\n a list of found IP addresses.\n\n Inspired by Crimsdings\n https:\/\/github.com\/crimsdings\/ChromeCast\/blob\/master\/cc_discovery.py\n \"\"\"\n ips = []\n\n calc_now = dt.datetime.now\n start = calc_now()\n\n try:\n sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n\n sock.sendto(SSDP_REQUEST.encode(\"ascii\"), (SSDP_ADDR, SSDP_PORT))\n\n sock.setblocking(0)\n\n while True:\n time_diff = calc_now() - start\n\n seconds_left = timeout - time_diff.seconds\n\n if seconds_left <= 0:\n return ips\n\n ready = select.select([sock], [], [], seconds_left)[0]\n\n if ready:\n response = sock.recv(1024).decode(\"ascii\")\n\n found_ip = found_st = None\n\n headers = response.split(\"\\r\\n\\r\\n\", 1)[0]\n\n for header in headers.split(\"\\r\\n\"):\n parts = header.split(\": \", 1)\n\n # Headers start with something like 'HTTP\/1.1 200 OK'\n # We cannot split that up in key-value pair, so skip\n if len(parts) != 2:\n continue\n\n key, value = parts\n\n if key == \"LOCATION\":\n url = urlparse.urlparse(value)\n\n found_ip = url.hostname\n\n elif key == \"ST\":\n found_st = value\n\n if found_st == SSDP_ST and found_ip:\n ips.append(found_ip)\n\n if max_devices and len(ips) == max_devices:\n return ips\n\n except socket.error:\n logging.getLogger(__name__).exception(\n \"Socket error while discovering Chromecasts\")\n\n finally:\n sock.close()\n\n return ips","function_tokens":["def","discover_chromecasts","(","max_devices","=","None",",","timeout","=","DISCOVER_TIMEOUT",")",":","ips","=","[","]","calc_now","=","dt",".","datetime",".","now","start","=","calc_now","(",")","try",":","sock","=","socket",".","socket","(","socket",".","AF_INET",",","socket",".","SOCK_DGRAM",")","sock",".","sendto","(","SSDP_REQUEST",".","encode","(","\"ascii\"",")",",","(","SSDP_ADDR",",","SSDP_PORT",")",")","sock",".","setblocking","(","0",")","while","True",":","time_diff","=","calc_now","(",")","-","start","seconds_left","=","timeout","-","time_diff",".","seconds","if","seconds_left","<=","0",":","return","ips","ready","=","select",".","select","(","[","sock","]",",","[","]",",","[","]",",","seconds_left",")","[","0","]","if","ready",":","response","=","sock",".","recv","(","1024",")",".","decode","(","\"ascii\"",")","found_ip","=","found_st","=","None","headers","=","response",".","split","(","\"\\r\\n\\r\\n\"",",","1",")","[","0","]","for","header","in","headers",".","split","(","\"\\r\\n\"",")",":","parts","=","header",".","split","(","\": \"",",","1",")","# Headers start with something like 'HTTP\/1.1 200 OK'","# We cannot split that up in key-value pair, so skip","if","len","(","parts",")","!=","2",":","continue","key",",","value","=","parts","if","key","==","\"LOCATION\"",":","url","=","urlparse",".","urlparse","(","value",")","found_ip","=","url",".","hostname","elif","key","==","\"ST\"",":","found_st","=","value","if","found_st","==","SSDP_ST","and","found_ip",":","ips",".","append","(","found_ip",")","if","max_devices","and","len","(","ips",")","==","max_devices",":","return","ips","except","socket",".","error",":","logging",".","getLogger","(","__name__",")",".","exception","(","\"Socket error while discovering Chromecasts\"",")","finally",":","sock",".","close","(",")","return","ips"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/upnp.py#L30-L98"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/config.py","language":"python","identifier":"get_possible_app_ids","parameters":"()","argument_list":"","return_statement":"","docstring":"Returns all possible app ids.","docstring_summary":"Returns all possible app ids.","docstring_tokens":["Returns","all","possible","app","ids","."],"function":"def get_possible_app_ids():\n \"\"\" Returns all possible app ids. \"\"\"\n\n try:\n req = requests.get(\n \"https:\/\/clients3.google.com\/cast\/chromecast\/device\/baseconfig\")\n data = json.loads(req.text[4:])\n\n return [app['app_id'] for app in data['applications']] + \\\n data[\"enabled_app_ids\"]\n\n except ValueError:\n # If json fails to parse\n return []","function_tokens":["def","get_possible_app_ids","(",")",":","try",":","req","=","requests",".","get","(","\"https:\/\/clients3.google.com\/cast\/chromecast\/device\/baseconfig\"",")","data","=","json",".","loads","(","req",".","text","[","4",":","]",")","return","[","app","[","'app_id'","]","for","app","in","data","[","'applications'","]","]","+","data","[","\"enabled_app_ids\"","]","except","ValueError",":","# If json fails to parse","return","[","]"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/config.py#L34-L47"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/config.py","language":"python","identifier":"get_app_config","parameters":"(app_id)","argument_list":"","return_statement":"","docstring":"Get specific configuration for 'app_id'.","docstring_summary":"Get specific configuration for 'app_id'.","docstring_tokens":["Get","specific","configuration","for","app_id","."],"function":"def get_app_config(app_id):\n \"\"\" Get specific configuration for 'app_id'. \"\"\"\n try:\n req = requests.get(\n (\"https:\/\/clients3.google.com\/\"\n \"cast\/chromecast\/device\/app?a={}\").format(app_id))\n\n return json.loads(req.text[4:]) if req.status_code == 200 else {}\n\n except ValueError:\n # If json fails to parse\n return {}","function_tokens":["def","get_app_config","(","app_id",")",":","try",":","req","=","requests",".","get","(","(","\"https:\/\/clients3.google.com\/\"","\"cast\/chromecast\/device\/app?a={}\"",")",".","format","(","app_id",")",")","return","json",".","loads","(","req",".","text","[","4",":","]",")","if","req",".","status_code","==","200","else","{","}","except","ValueError",":","# If json fails to parse","return","{","}"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/config.py#L50-L61"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"create_websocket_client","parameters":"(app_status)","argument_list":"","return_statement":"return client","docstring":"Creates and returns a RAMP client based on the supplied app status.\n Will return None if RAMP client is not supported.\n Will raise ValueError if unable to retrieve the websocket url.","docstring_summary":"Creates and returns a RAMP client based on the supplied app status.\n Will return None if RAMP client is not supported.\n Will raise ValueError if unable to retrieve the websocket url.","docstring_tokens":["Creates","and","returns","a","RAMP","client","based","on","the","supplied","app","status",".","Will","return","None","if","RAMP","client","is","not","supported",".","Will","raise","ValueError","if","unable","to","retrieve","the","websocket","url","."],"function":"def create_websocket_client(app_status):\n \"\"\"\n Creates and returns a RAMP client based on the supplied app status.\n Will return None if RAMP client is not supported.\n Will raise ValueError if unable to retrieve the websocket url.\n \"\"\"\n\n # Check if current app has no service url or no protocols.\n if not app_status.service_url or not app_status.service_protocols:\n return None\n\n req = requests.post(app_status.service_url,\n data=\"{}\".encode(\"ascii\"),\n headers={\"Content-Type\": \"application\/json\"})\n\n if req.status_code != 200:\n raise error.ConnectionError(\n \"Could not retrieve websocket url ({}).\".format(req.status_code))\n\n conn_data = json.loads(req.text)\n\n client = ChromecastWebSocketClient(conn_data['URL'],\n app_status.service_protocols)\n\n client.connect()\n\n atexit.register(_clean_open_clients)\n\n return client","function_tokens":["def","create_websocket_client","(","app_status",")",":","# Check if current app has no service url or no protocols.","if","not","app_status",".","service_url","or","not","app_status",".","service_protocols",":","return","None","req","=","requests",".","post","(","app_status",".","service_url",",","data","=","\"{}\"",".","encode","(","\"ascii\"",")",",","headers","=","{","\"Content-Type\"",":","\"application\/json\"","}",")","if","req",".","status_code","!=","200",":","raise","error",".","ConnectionError","(","\"Could not retrieve websocket url ({}).\"",".","format","(","req",".","status_code",")",")","conn_data","=","json",".","loads","(","req",".","text",")","client","=","ChromecastWebSocketClient","(","conn_data","[","'URL'","]",",","app_status",".","service_protocols",")","client",".","connect","(",")","atexit",".","register","(","_clean_open_clients",")","return","client"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L87-L115"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"_clean_open_clients","parameters":"()","argument_list":"","return_statement":"","docstring":"Called on exit of Python to close open clients.","docstring_summary":"Called on exit of Python to close open clients.","docstring_tokens":["Called","on","exit","of","Python","to","close","open","clients","."],"function":"def _clean_open_clients():\n \"\"\" Called on exit of Python to close open clients. \"\"\"\n for client_weakref in list(_OPEN_CLIENTS):\n client = client_weakref()\n\n if client and not client.terminated:\n client.close_connection()","function_tokens":["def","_clean_open_clients","(",")",":","for","client_weakref","in","list","(","_OPEN_CLIENTS",")",":","client","=","client_weakref","(",")","if","client","and","not","client",".","terminated",":","client",".","close_connection","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L118-L124"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"ChromecastWebSocketClient.opened","parameters":"(self)","argument_list":"","return_statement":"","docstring":"When connection is opened initiate the protocol handlers.","docstring_summary":"When connection is opened initiate the protocol handlers.","docstring_tokens":["When","connection","is","opened","initiate","the","protocol","handlers","."],"function":"def opened(self):\n \"\"\" When connection is opened initiate the protocol handlers. \"\"\"\n _OPEN_CLIENTS.append(self._weakref)\n\n self.handlers[PROTOCOL_COMMAND] = CommandSubprotocol(self)\n\n _known_prot = KNOWN_PROTOCOLS\n\n # Instantiate supported subprotocols.\n for protocol in self.supported_protocols:\n handler = _known_prot.get(protocol)\n\n if handler:\n self.handlers[protocol] = handler(self)\n else:\n self.logger.warning(\n \"Unsupported protocol: {}\".format(protocol))","function_tokens":["def","opened","(","self",")",":","_OPEN_CLIENTS",".","append","(","self",".","_weakref",")","self",".","handlers","[","PROTOCOL_COMMAND","]","=","CommandSubprotocol","(","self",")","_known_prot","=","KNOWN_PROTOCOLS","# Instantiate supported subprotocols.","for","protocol","in","self",".","supported_protocols",":","handler","=","_known_prot",".","get","(","protocol",")","if","handler",":","self",".","handlers","[","protocol","]","=","handler","(","self",")","else",":","self",".","logger",".","warning","(","\"Unsupported protocol: {}\"",".","format","(","protocol",")",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L139-L155"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"ChromecastWebSocketClient.closed","parameters":"(self, code, reason=None)","argument_list":"","return_statement":"","docstring":"Clear protocol handlers when connection is lost.","docstring_summary":"Clear protocol handlers when connection is lost.","docstring_tokens":["Clear","protocol","handlers","when","connection","is","lost","."],"function":"def closed(self, code, reason=None):\n \"\"\" Clear protocol handlers when connection is lost. \"\"\"\n # Clear reference to client\n _OPEN_CLIENTS.remove(self._weakref)\n\n for handler in self.handlers.values():\n handler.client = None\n\n self.handlers.clear()","function_tokens":["def","closed","(","self",",","code",",","reason","=","None",")",":","# Clear reference to client","_OPEN_CLIENTS",".","remove","(","self",".","_weakref",")","for","handler","in","self",".","handlers",".","values","(",")",":","handler",".","client","=","None","self",".","handlers",".","clear","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L157-L165"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"ChromecastWebSocketClient.received_message","parameters":"(self, message)","argument_list":"","return_statement":"","docstring":"When a new message is received.","docstring_summary":"When a new message is received.","docstring_tokens":["When","a","new","message","is","received","."],"function":"def received_message(self, message):\n \"\"\" When a new message is received. \"\"\"\n\n # We do not support binary message\n if message.is_binary:\n return False\n\n try:\n protocol, data = json.loads(message.data.decode('utf8'))\n except ValueError:\n # If error while parsing JSON\n # if unpack error: more then 2 items in the list\n logging.getLogger(__name__).exception(\n \"Error parsing incoming message: {}\".format(\n message.data.decode(\"utf8\")))\n\n return\n\n if _DEBUG:\n logging.getLogger(__name__).info(\"Receiving {}\".format(data))\n\n handler = self.handlers.get(protocol)\n\n if handler:\n handler._receive_protocol(data) # pylint: disable=protected-access\n else:\n logging.getLogger(__name__).warning(\n \"Unknown protocol received: {}, {}\".format(protocol, data))","function_tokens":["def","received_message","(","self",",","message",")",":","# We do not support binary message","if","message",".","is_binary",":","return","False","try",":","protocol",",","data","=","json",".","loads","(","message",".","data",".","decode","(","'utf8'",")",")","except","ValueError",":","# If error while parsing JSON","# if unpack error: more then 2 items in the list","logging",".","getLogger","(","__name__",")",".","exception","(","\"Error parsing incoming message: {}\"",".","format","(","message",".","data",".","decode","(","\"utf8\"",")",")",")","return","if","_DEBUG",":","logging",".","getLogger","(","__name__",")",".","info","(","\"Receiving {}\"",".","format","(","data",")",")","handler","=","self",".","handlers",".","get","(","protocol",")","if","handler",":","handler",".","_receive_protocol","(","data",")","# pylint: disable=protected-access","else",":","logging",".","getLogger","(","__name__",")",".","warning","(","\"Unknown protocol received: {}, {}\"",".","format","(","protocol",",","data",")",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L167-L194"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"BaseSubprotocol._send_protocol","parameters":"(self, data)","argument_list":"","return_statement":"","docstring":"Default handler for sending messages as subprotocol.","docstring_summary":"Default handler for sending messages as subprotocol.","docstring_tokens":["Default","handler","for","sending","messages","as","subprotocol","."],"function":"def _send_protocol(self, data):\n \"\"\" Default handler for sending messages as subprotocol. \"\"\"\n if _DEBUG:\n self.logger.info(\"Sending {}\".format(data))\n\n if not self.client:\n raise error.ConnectionError(\"Not connected to Chromecast\")\n\n try:\n self.client.send(json.dumps([self.protocol, data]).encode(\"utf8\"))\n\n except socket.error:\n # if an error occured sending data over the socket\n raise error.ConnectionError(\"Error communicating with Chromecast\")","function_tokens":["def","_send_protocol","(","self",",","data",")",":","if","_DEBUG",":","self",".","logger",".","info","(","\"Sending {}\"",".","format","(","data",")",")","if","not","self",".","client",":","raise","error",".","ConnectionError","(","\"Not connected to Chromecast\"",")","try",":","self",".","client",".","send","(","json",".","dumps","(","[","self",".","protocol",",","data","]",")",".","encode","(","\"utf8\"",")",")","except","socket",".","error",":","# if an error occured sending data over the socket","raise","error",".","ConnectionError","(","\"Error communicating with Chromecast\"",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L206-L219"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"BaseSubprotocol._receive_protocol","parameters":"(self, data)","argument_list":"","return_statement":"","docstring":"Default handler for receiving messages as subprotocol.","docstring_summary":"Default handler for receiving messages as subprotocol.","docstring_tokens":["Default","handler","for","receiving","messages","as","subprotocol","."],"function":"def _receive_protocol(self, data):\n \"\"\" Default handler for receiving messages as subprotocol. \"\"\"\n self.logger.warning(\n \"Unhandled {} message: {}\".format(self.protocol, data))","function_tokens":["def","_receive_protocol","(","self",",","data",")",":","self",".","logger",".","warning","(","\"Unhandled {} message: {}\"",".","format","(","self",".","protocol",",","data",")",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L221-L224"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"BaseSubprotocol.is_active","parameters":"(self)","argument_list":"","return_statement":"return not self.client.terminated","docstring":"Returns if this subprotocol is active.","docstring_summary":"Returns if this subprotocol is active.","docstring_tokens":["Returns","if","this","subprotocol","is","active","."],"function":"def is_active(self):\n \"\"\" Returns if this subprotocol is active. \"\"\"\n return not self.client.terminated","function_tokens":["def","is_active","(","self",")",":","return","not","self",".","client",".","terminated"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L227-L229"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"CommandSubprotocol._receive_protocol","parameters":"(self, data)","argument_list":"","return_statement":"","docstring":"Handles an incoming COMMAND message.","docstring_summary":"Handles an incoming COMMAND message.","docstring_tokens":["Handles","an","incoming","COMMAND","message","."],"function":"def _receive_protocol(self, data):\n \"\"\" Handles an incoming COMMAND message. \"\"\"\n\n if data[COMMAND_ATTR_TYPE] == COMMAND_TYPE_PING:\n self._send_protocol({COMMAND_ATTR_TYPE: COMMAND_TYPE_PONG})\n else:\n BaseSubprotocol._receive_protocol(self, data)","function_tokens":["def","_receive_protocol","(","self",",","data",")",":","if","data","[","COMMAND_ATTR_TYPE","]","==","COMMAND_TYPE_PING",":","self",".","_send_protocol","(","{","COMMAND_ATTR_TYPE",":","COMMAND_TYPE_PONG","}",")","else",":","BaseSubprotocol",".","_receive_protocol","(","self",",","data",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L238-L244"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol._receive_protocol","parameters":"(self, data)","argument_list":"","return_statement":"","docstring":"Handles an incoming Ramp message.","docstring_summary":"Handles an incoming Ramp message.","docstring_tokens":["Handles","an","incoming","Ramp","message","."],"function":"def _receive_protocol(self, data):\n \"\"\" Handles an incoming Ramp message. \"\"\"\n message_type = data[RAMP_ATTR_TYPE]\n\n if message_type == RAMP_TYPE_STATUS:\n self._update_status(data[RAMP_ATTR_STATUS])\n\n elif message_type == RAMP_TYPE_RESPONSE:\n # Match it with the command that we send\n try:\n cmd_type, cmd_event = \\\n self.commands.pop(data[RAMP_ATTR_CMD_ID])\n\n except KeyError:\n # If CMD_ID did not exist or we do not recognize command\n return\n\n # Handle response, currently no response handlers\n if cmd_type in (RAMP_TYPE_PLAY, RAMP_TYPE_VOLUME,\n RAMP_TYPE_INFO):\n\n self._update_status(data[RAMP_ATTR_STATUS])\n\n else:\n self.logger.warning(\n \"Unhandled response for command {}: {}\".format(\n cmd_type, data))\n\n # Alert code that is waiting for this command to get response\n if cmd_event:\n cmd_event.set()\n\n else:\n BaseSubprotocol._receive_protocol(self, data)","function_tokens":["def","_receive_protocol","(","self",",","data",")",":","message_type","=","data","[","RAMP_ATTR_TYPE","]","if","message_type","==","RAMP_TYPE_STATUS",":","self",".","_update_status","(","data","[","RAMP_ATTR_STATUS","]",")","elif","message_type","==","RAMP_TYPE_RESPONSE",":","# Match it with the command that we send","try",":","cmd_type",",","cmd_event","=","self",".","commands",".","pop","(","data","[","RAMP_ATTR_CMD_ID","]",")","except","KeyError",":","# If CMD_ID did not exist or we do not recognize command","return","# Handle response, currently no response handlers","if","cmd_type","in","(","RAMP_TYPE_PLAY",",","RAMP_TYPE_VOLUME",",","RAMP_TYPE_INFO",")",":","self",".","_update_status","(","data","[","RAMP_ATTR_STATUS","]",")","else",":","self",".","logger",".","warning","(","\"Unhandled response for command {}: {}\"",".","format","(","cmd_type",",","data",")",")","# Alert code that is waiting for this command to get response","if","cmd_event",":","cmd_event",".","set","(",")","else",":","BaseSubprotocol",".","_receive_protocol","(","self",",","data",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L259-L292"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol._send_ramp","parameters":"(self, data, blocking=False)","argument_list":"","return_statement":"","docstring":"Sends a RAMP message.\n Set blocking=True to wait till the Chromecast sends a response\n to the command.","docstring_summary":"Sends a RAMP message.\n Set blocking=True to wait till the Chromecast sends a response\n to the command.","docstring_tokens":["Sends","a","RAMP","message",".","Set","blocking","=","True","to","wait","till","the","Chromecast","sends","a","response","to","the","command","."],"function":"def _send_ramp(self, data, blocking=False):\n \"\"\"\n Sends a RAMP message.\n Set blocking=True to wait till the Chromecast sends a response\n to the command.\n \"\"\"\n data[RAMP_ATTR_CMD_ID] = self.command_id\n\n event = threading.Event() if blocking else None\n\n # Save type to match later with response\n self.commands[self.command_id] = (data[RAMP_ATTR_TYPE], event)\n\n self._send_protocol(data)\n\n self.command_id += 1\n\n if blocking:\n event.wait()","function_tokens":["def","_send_ramp","(","self",",","data",",","blocking","=","False",")",":","data","[","RAMP_ATTR_CMD_ID","]","=","self",".","command_id","event","=","threading",".","Event","(",")","if","blocking","else","None","# Save type to match later with response","self",".","commands","[","self",".","command_id","]","=","(","data","[","RAMP_ATTR_TYPE","]",",","event",")","self",".","_send_protocol","(","data",")","self",".","command_id","+=","1","if","blocking",":","event",".","wait","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L295-L313"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.is_playing","parameters":"(self)","argument_list":"","return_statement":"return self.is_active and self.state == RAMP_STATE_PLAYING","docstring":"Property that represents if content is being played.","docstring_summary":"Property that represents if content is being played.","docstring_tokens":["Property","that","represents","if","content","is","being","played","."],"function":"def is_playing(self):\n \"\"\" Property that represents if content is being played. \"\"\"\n return self.is_active and self.state == RAMP_STATE_PLAYING","function_tokens":["def","is_playing","(","self",")",":","return","self",".","is_active","and","self",".","state","==","RAMP_STATE_PLAYING"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L316-L318"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.play","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Send the PLAY-command to the RAMP-target.","docstring_summary":"Send the PLAY-command to the RAMP-target.","docstring_tokens":["Send","the","PLAY","-","command","to","the","RAMP","-","target","."],"function":"def play(self):\n \"\"\" Send the PLAY-command to the RAMP-target. \"\"\"\n self._send_ramp({RAMP_ATTR_TYPE: RAMP_TYPE_PLAY})","function_tokens":["def","play","(","self",")",":","self",".","_send_ramp","(","{","RAMP_ATTR_TYPE",":","RAMP_TYPE_PLAY","}",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L320-L322"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.pause","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Send the PAUSE-command to the RAMP-target.","docstring_summary":"Send the PAUSE-command to the RAMP-target.","docstring_tokens":["Send","the","PAUSE","-","command","to","the","RAMP","-","target","."],"function":"def pause(self):\n \"\"\" Send the PAUSE-command to the RAMP-target. \"\"\"\n # The STOP command actually pauses the media\n self._send_ramp({RAMP_ATTR_TYPE: RAMP_TYPE_STOP})","function_tokens":["def","pause","(","self",")",":","# The STOP command actually pauses the media","self",".","_send_ramp","(","{","RAMP_ATTR_TYPE",":","RAMP_TYPE_STOP","}",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L324-L327"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.playpause","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Plays if paused, pauses if playing.","docstring_summary":"Plays if paused, pauses if playing.","docstring_tokens":["Plays","if","paused","pauses","if","playing","."],"function":"def playpause(self):\n \"\"\" Plays if paused, pauses if playing. \"\"\"\n if self.state == RAMP_STATE_PLAYING:\n self.pause()\n else:\n self.play()","function_tokens":["def","playpause","(","self",")",":","if","self",".","state","==","RAMP_STATE_PLAYING",":","self",".","pause","(",")","else",":","self",".","play","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L329-L334"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.seek","parameters":"(self, seconds)","argument_list":"","return_statement":"","docstring":"Seek within the content played at RAMP-target.","docstring_summary":"Seek within the content played at RAMP-target.","docstring_tokens":["Seek","within","the","content","played","at","RAMP","-","target","."],"function":"def seek(self, seconds):\n \"\"\" Seek within the content played at RAMP-target. \"\"\"\n self._send_ramp({RAMP_ATTR_TYPE: RAMP_TYPE_PLAY,\n RAMP_ATTR_POSITION: seconds})","function_tokens":["def","seek","(","self",",","seconds",")",":","self",".","_send_ramp","(","{","RAMP_ATTR_TYPE",":","RAMP_TYPE_PLAY",",","RAMP_ATTR_POSITION",":","seconds","}",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L336-L339"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.rewind","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Rewinds current media item.","docstring_summary":"Rewinds current media item.","docstring_tokens":["Rewinds","current","media","item","."],"function":"def rewind(self):\n \"\"\" Rewinds current media item. \"\"\"\n self.seek(0)","function_tokens":["def","rewind","(","self",")",":","self",".","seek","(","0",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L341-L343"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.next","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Skip to the next content at the RAMP-target.","docstring_summary":"Skip to the next content at the RAMP-target.","docstring_tokens":["Skip","to","the","next","content","at","the","RAMP","-","target","."],"function":"def next(self):\n \"\"\" Skip to the next content at the RAMP-target. \"\"\"\n if self.duration != 0:\n self.seek(self.duration-.1)","function_tokens":["def","next","(","self",")",":","if","self",".","duration","!=","0",":","self",".","seek","(","self",".","duration","-",".1",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L345-L348"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.set_volume","parameters":"(self, volume)","argument_list":"","return_statement":"","docstring":"Set volume at the RAMP-target.","docstring_summary":"Set volume at the RAMP-target.","docstring_tokens":["Set","volume","at","the","RAMP","-","target","."],"function":"def set_volume(self, volume):\n \"\"\" Set volume at the RAMP-target. \"\"\"\n # volume is double between 0 and 1\n self._send_ramp({RAMP_ATTR_TYPE: RAMP_TYPE_VOLUME,\n RAMP_ATTR_VOLUME: volume})","function_tokens":["def","set_volume","(","self",",","volume",")",":","# volume is double between 0 and 1","self",".","_send_ramp","(","{","RAMP_ATTR_TYPE",":","RAMP_TYPE_VOLUME",",","RAMP_ATTR_VOLUME",":","volume","}",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L350-L354"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.volume_up","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Increases volume.","docstring_summary":"Increases volume.","docstring_tokens":["Increases","volume","."],"function":"def volume_up(self):\n \"\"\" Increases volume. \"\"\"\n if self.volume < 1:\n self.set_volume(min(self.volume+.1, 1))","function_tokens":["def","volume_up","(","self",")",":","if","self",".","volume","<","1",":","self",".","set_volume","(","min","(","self",".","volume","+",".1",",","1",")",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L356-L359"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.volume_down","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Decreases volume.","docstring_summary":"Decreases volume.","docstring_tokens":["Decreases","volume","."],"function":"def volume_down(self):\n \"\"\" Decreases volume. \"\"\"\n if self.volume > 0:\n self.set_volume(max(self.volume-.1, 0))","function_tokens":["def","volume_down","(","self",")",":","if","self",".","volume",">","0",":","self",".","set_volume","(","max","(","self",".","volume","-",".1",",","0",")",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L361-L364"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.refresh","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Refresh data at the RAMP-target.","docstring_summary":"Refresh data at the RAMP-target.","docstring_tokens":["Refresh","data","at","the","RAMP","-","target","."],"function":"def refresh(self):\n \"\"\" Refresh data at the RAMP-target. \"\"\"\n self._send_ramp({RAMP_ATTR_TYPE: RAMP_TYPE_INFO})","function_tokens":["def","refresh","(","self",")",":","self",".","_send_ramp","(","{","RAMP_ATTR_TYPE",":","RAMP_TYPE_INFO","}",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L366-L368"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol._update_status","parameters":"(self, status)","argument_list":"","return_statement":"","docstring":"Updates the RAMP status.","docstring_summary":"Updates the RAMP status.","docstring_tokens":["Updates","the","RAMP","status","."],"function":"def _update_status(self, status):\n \"\"\" Updates the RAMP status. \"\"\"\n con_inf = status.get(RAMP_ATTR_CONTENT_INFO, {})\n\n self.state = status.get(RAMP_STATUS_ATTR_STATE, 0)\n self.volume = status.get(RAMP_STATUS_ATTR_VOLUME, 1)\n self.muted = status.get(RAMP_STATUS_ATTR_MUTED, False)\n self.content_id = status.get(RAMP_STATUS_ATTR_CONTENT_ID)\n self.title = status.get(RAMP_STATUS_ATTR_TITLE)\n self.artist = con_inf.get(RAMP_STATUS_CONTENT_INFO_ATTR_ARTIST)\n self.album = con_inf.get(RAMP_STATUS_CONTENT_INFO_ATTR_ALBUM_TITLE)\n self._current_time = status.get(RAMP_STATUS_ATTR_CURRENT_TIME, 0)\n self.duration = status.get(RAMP_STATUS_ATTR_DURATION, 0)\n self.image_url = status.get(RAMP_STATUS_ATTR_IMAGE_URL)\n self.time_progress = status.get(RAMP_ATTR_TIME_PROGRESS, False)\n\n self.last_updated = dt.datetime.now()","function_tokens":["def","_update_status","(","self",",","status",")",":","con_inf","=","status",".","get","(","RAMP_ATTR_CONTENT_INFO",",","{","}",")","self",".","state","=","status",".","get","(","RAMP_STATUS_ATTR_STATE",",","0",")","self",".","volume","=","status",".","get","(","RAMP_STATUS_ATTR_VOLUME",",","1",")","self",".","muted","=","status",".","get","(","RAMP_STATUS_ATTR_MUTED",",","False",")","self",".","content_id","=","status",".","get","(","RAMP_STATUS_ATTR_CONTENT_ID",")","self",".","title","=","status",".","get","(","RAMP_STATUS_ATTR_TITLE",")","self",".","artist","=","con_inf",".","get","(","RAMP_STATUS_CONTENT_INFO_ATTR_ARTIST",")","self",".","album","=","con_inf",".","get","(","RAMP_STATUS_CONTENT_INFO_ATTR_ALBUM_TITLE",")","self",".","_current_time","=","status",".","get","(","RAMP_STATUS_ATTR_CURRENT_TIME",",","0",")","self",".","duration","=","status",".","get","(","RAMP_STATUS_ATTR_DURATION",",","0",")","self",".","image_url","=","status",".","get","(","RAMP_STATUS_ATTR_IMAGE_URL",")","self",".","time_progress","=","status",".","get","(","RAMP_ATTR_TIME_PROGRESS",",","False",")","self",".","last_updated","=","dt",".","datetime",".","now","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L370-L386"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/websocket.py","language":"python","identifier":"RampSubprotocol.current_time","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Returns current time of the content.","docstring_summary":"Returns current time of the content.","docstring_tokens":["Returns","current","time","of","the","content","."],"function":"def current_time(self):\n \"\"\" Returns current time of the content. \"\"\"\n\n # If time is progressing we have to calculate the current time based on\n # time the status was retrieved and the then current time.\n if self.time_progress:\n timediff = dt.datetime.now() - self.last_updated\n\n return min(self._current_time + timediff.seconds, self.duration)\n\n else:\n return self._current_time","function_tokens":["def","current_time","(","self",")",":","# If time is progressing we have to calculate the current time based on","# time the status was retrieved and the then current time.","if","self",".","time_progress",":","timediff","=","dt",".","datetime",".","now","(",")","-","self",".","last_updated","return","min","(","self",".","_current_time","+","timediff",".","seconds",",","self",".","duration",")","else",":","return","self",".","_current_time"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/websocket.py#L389-L400"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"play_youtube_video","parameters":"(video_id, host=None)","argument_list":"","return_statement":"","docstring":"Starts the YouTube app if it is not running and plays\n specified video.","docstring_summary":"Starts the YouTube app if it is not running and plays\n specified video.","docstring_tokens":["Starts","the","YouTube","app","if","it","is","not","running","and","plays","specified","video","."],"function":"def play_youtube_video(video_id, host=None):\n \"\"\" Starts the YouTube app if it is not running and plays\n specified video. \"\"\"\n\n if not host:\n host = _auto_select_chromecast()\n\n start_app(host, APP_ID[\"YOUTUBE\"], {\"v\": video_id})","function_tokens":["def","play_youtube_video","(","video_id",",","host","=","None",")",":","if","not","host",":","host","=","_auto_select_chromecast","(",")","start_app","(","host",",","APP_ID","[","\"YOUTUBE\"","]",",","{","\"v\"",":","video_id","}",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L17-L24"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"play_youtube_playlist","parameters":"(playlist_id, host=None)","argument_list":"","return_statement":"","docstring":"Starts the YouTube app if it is not running and plays\n specified playlist.","docstring_summary":"Starts the YouTube app if it is not running and plays\n specified playlist.","docstring_tokens":["Starts","the","YouTube","app","if","it","is","not","running","and","plays","specified","playlist","."],"function":"def play_youtube_playlist(playlist_id, host=None):\n \"\"\" Starts the YouTube app if it is not running and plays\n specified playlist. \"\"\"\n\n if not host:\n host = _auto_select_chromecast()\n\n start_app(host, APP_ID[\"YOUTUBE\"],\n {\"listType\": \"playlist\", \"list\": playlist_id})","function_tokens":["def","play_youtube_playlist","(","playlist_id",",","host","=","None",")",":","if","not","host",":","host","=","_auto_select_chromecast","(",")","start_app","(","host",",","APP_ID","[","\"YOUTUBE\"","]",",","{","\"listType\"",":","\"playlist\"",",","\"list\"",":","playlist_id","}",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L27-L35"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"_auto_select_chromecast","parameters":"()","argument_list":"","return_statement":"","docstring":"Discovers local Chromecasts and returns first one found.\n Raises exception if none can be found.","docstring_summary":"Discovers local Chromecasts and returns first one found.\n Raises exception if none can be found.","docstring_tokens":["Discovers","local","Chromecasts","and","returns","first","one","found",".","Raises","exception","if","none","can","be","found","."],"function":"def _auto_select_chromecast():\n \"\"\"\n Discovers local Chromecasts and returns first one found.\n Raises exception if none can be found.\n \"\"\"\n ips = discover_chromecasts(1)\n\n if ips:\n return ips[0]\n else:\n raise NoChromecastFoundError(\"Unable to detect Chromecast\")","function_tokens":["def","_auto_select_chromecast","(",")",":","ips","=","discover_chromecasts","(","1",")","if","ips",":","return","ips","[","0","]","else",":","raise","NoChromecastFoundError","(","\"Unable to detect Chromecast\"",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L38-L48"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"PyChromecast.app_id","parameters":"(self)","argument_list":"","return_statement":"return self.app.app_id if self.app else None","docstring":"Returns the current app_id.","docstring_summary":"Returns the current app_id.","docstring_tokens":["Returns","the","current","app_id","."],"function":"def app_id(self):\n \"\"\" Returns the current app_id. \"\"\"\n return self.app.app_id if self.app else None","function_tokens":["def","app_id","(","self",")",":","return","self",".","app",".","app_id","if","self",".","app","else","None"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L73-L75"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"PyChromecast.app_description","parameters":"(self)","argument_list":"","return_statement":"return self.app.description if self.app else None","docstring":"Returns the name of the current running app.","docstring_summary":"Returns the name of the current running app.","docstring_tokens":["Returns","the","name","of","the","current","running","app","."],"function":"def app_description(self):\n \"\"\" Returns the name of the current running app. \"\"\"\n return self.app.description if self.app else None","function_tokens":["def","app_description","(","self",")",":","return","self",".","app",".","description","if","self",".","app","else","None"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L78-L80"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"PyChromecast.get_protocol","parameters":"(self, protocol)","argument_list":"","return_statement":"","docstring":"Returns the current RAMP content info and controls.","docstring_summary":"Returns the current RAMP content info and controls.","docstring_tokens":["Returns","the","current","RAMP","content","info","and","controls","."],"function":"def get_protocol(self, protocol):\n \"\"\" Returns the current RAMP content info and controls. \"\"\"\n if self.websocket_client:\n return self.websocket_client.handlers.get(protocol)\n else:\n return None","function_tokens":["def","get_protocol","(","self",",","protocol",")",":","if","self",".","websocket_client",":","return","self",".","websocket_client",".","handlers",".","get","(","protocol",")","else",":","return","None"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L82-L87"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"PyChromecast.refresh","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Queries the Chromecast for the current status.\n Starts a websocket client if possible.","docstring_summary":"Queries the Chromecast for the current status.\n Starts a websocket client if possible.","docstring_tokens":["Queries","the","Chromecast","for","the","current","status",".","Starts","a","websocket","client","if","possible","."],"function":"def refresh(self):\n \"\"\"\n Queries the Chromecast for the current status.\n Starts a websocket client if possible.\n \"\"\"\n self.logger.info(\"Refreshing app status\")\n\n # If we are refreshing but a refresh was planned, cancel that one\n with self._refresh_lock:\n if self._refresh_timer:\n self._refresh_timer.cancel()\n self._refresh_timer = None\n\n cur_app = self.app\n cur_ws = self.websocket_client\n\n self.app = app = get_app_status(self.host)\n\n # If no previous app and no new app there is nothing to do\n if not cur_app and not app:\n is_diff_app = False\n else:\n is_diff_app = (not cur_app and app or cur_app and not app or\n cur_app.app_id != app.app_id)\n\n # Clean up websocket if:\n # - there is a different app and a connection exists\n # - if it is the same app but the connection is terminated\n if cur_ws and (is_diff_app or cur_ws.terminated):\n\n if not cur_ws.terminated:\n cur_ws.close_connection()\n\n self.websocket_client = cur_ws = None\n\n # Create a new websocket client if there is no connection\n if not cur_ws and app:\n\n try:\n # If the current app is not capable of a websocket client\n # This method will return None so nothing is lost\n self.websocket_client = cur_ws = create_websocket_client(app)\n\n except ConnectionError:\n pass\n\n # Ramp service does not always immediately show up in the app\n # status. If we do not have a websocket client but the app is\n # known to be RAMP controllable, then plan refresh.\n if not cur_ws and app.app_id in RAMP_ENABLED:\n self._delayed_refresh()","function_tokens":["def","refresh","(","self",")",":","self",".","logger",".","info","(","\"Refreshing app status\"",")","# If we are refreshing but a refresh was planned, cancel that one","with","self",".","_refresh_lock",":","if","self",".","_refresh_timer",":","self",".","_refresh_timer",".","cancel","(",")","self",".","_refresh_timer","=","None","cur_app","=","self",".","app","cur_ws","=","self",".","websocket_client","self",".","app","=","app","=","get_app_status","(","self",".","host",")","# If no previous app and no new app there is nothing to do","if","not","cur_app","and","not","app",":","is_diff_app","=","False","else",":","is_diff_app","=","(","not","cur_app","and","app","or","cur_app","and","not","app","or","cur_app",".","app_id","!=","app",".","app_id",")","# Clean up websocket if:","# - there is a different app and a connection exists","# - if it is the same app but the connection is terminated","if","cur_ws","and","(","is_diff_app","or","cur_ws",".","terminated",")",":","if","not","cur_ws",".","terminated",":","cur_ws",".","close_connection","(",")","self",".","websocket_client","=","cur_ws","=","None","# Create a new websocket client if there is no connection","if","not","cur_ws","and","app",":","try",":","# If the current app is not capable of a websocket client","# This method will return None so nothing is lost","self",".","websocket_client","=","cur_ws","=","create_websocket_client","(","app",")","except","ConnectionError",":","pass","# Ramp service does not always immediately show up in the app","# status. If we do not have a websocket client but the app is","# known to be RAMP controllable, then plan refresh.","if","not","cur_ws","and","app",".","app_id","in","RAMP_ENABLED",":","self",".","_delayed_refresh","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L89-L139"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"PyChromecast.start_app","parameters":"(self, app_id, data=None)","argument_list":"","return_statement":"","docstring":"Start an app on the Chromecast.","docstring_summary":"Start an app on the Chromecast.","docstring_tokens":["Start","an","app","on","the","Chromecast","."],"function":"def start_app(self, app_id, data=None):\n \"\"\" Start an app on the Chromecast. \"\"\"\n self.logger.info(\"Starting app {}\".format(app_id))\n\n # data parameter has to contain atleast 1 key\n # or else some apps won't show\n start_app(self.host, app_id, data)\n\n self._delayed_refresh()","function_tokens":["def","start_app","(","self",",","app_id",",","data","=","None",")",":","self",".","logger",".","info","(","\"Starting app {}\"",".","format","(","app_id",")",")","# data parameter has to contain atleast 1 key","# or else some apps won't show","start_app","(","self",".","host",",","app_id",",","data",")","self",".","_delayed_refresh","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L141-L149"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"PyChromecast.quit_app","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Tells the Chromecast to quit current app_id.","docstring_summary":"Tells the Chromecast to quit current app_id.","docstring_tokens":["Tells","the","Chromecast","to","quit","current","app_id","."],"function":"def quit_app(self):\n \"\"\" Tells the Chromecast to quit current app_id. \"\"\"\n self.logger.info(\"Quiting current app\")\n\n quit_app(self.host)\n\n self._delayed_refresh()","function_tokens":["def","quit_app","(","self",")",":","self",".","logger",".","info","(","\"Quiting current app\"",")","quit_app","(","self",".","host",")","self",".","_delayed_refresh","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L151-L157"} {"nwo":"BishopFox\/rickmote","sha":"2a8469657f9de7d6ee1d4cc65ce83235c1e582d9","path":"pychromecast\/__init__.py","language":"python","identifier":"PyChromecast._delayed_refresh","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Give the ChromeCast time to start the app, then refresh app.","docstring_summary":"Give the ChromeCast time to start the app, then refresh app.","docstring_tokens":["Give","the","ChromeCast","time","to","start","the","app","then","refresh","app","."],"function":"def _delayed_refresh(self):\n \"\"\" Give the ChromeCast time to start the app, then refresh app. \"\"\"\n with self._refresh_lock:\n if self._refresh_timer:\n self._refresh_timer.cancel()\n\n self._refresh_timer = threading.Timer(5, self.refresh)\n self._refresh_timer.start()","function_tokens":["def","_delayed_refresh","(","self",")",":","with","self",".","_refresh_lock",":","if","self",".","_refresh_timer",":","self",".","_refresh_timer",".","cancel","(",")","self",".","_refresh_timer","=","threading",".","Timer","(","5",",","self",".","refresh",")","self",".","_refresh_timer",".","start","(",")"],"url":"https:\/\/github.com\/BishopFox\/rickmote\/blob\/2a8469657f9de7d6ee1d4cc65ce83235c1e582d9\/pychromecast\/__init__.py#L159-L166"}