def parse_assistant_log_caption(dic_my_activity_assistant, assistant_logs): list_assistant_geodata_logs = TakeoutHtmlParser.find_log_caption( assistant_logs) if list_assistant_geodata_logs != []: for content in list_assistant_geodata_logs: content = str(content).strip() if content == '<br/>': continue if content.startswith('<a href="https://www.google.com/maps/'): idx = content.find('">') url = content[9:idx] o = urlparse(url) list_query_value = o.query.split(';') if list_query_value != []: for query_value in list_query_value: if query_value.startswith('center='): geodata = query_value.lstrip('center=').rstrip( '&') dic_my_activity_assistant[ 'latitude'] = geodata.split(',', 1)[0] dic_my_activity_assistant[ 'longitude'] = geodata.split(',', 1)[1] elif query_value.startswith('query='): geodata = query_value.lstrip('query=') dic_my_activity_assistant[ 'latitude'] = geodata.split(',', 1)[0] dic_my_activity_assistant[ 'longitude'] = geodata.split(',', 1)[1] if dic_my_activity_assistant['geodata_description'] == "": dic_my_activity_assistant[ 'geodata_description'] = content[idx + 2:content. find('</a>')]
def parse_maps_log_caption(dic_my_activity_maps, maps_logs): list_maps_logs = TakeoutHtmlParser.find_log_caption(maps_logs) if list_maps_logs != []: for content in list_maps_logs: content = str(content).strip() if content == '<br/>': continue elif content.startswith( '<a href="https://www.google.com/maps/'): idx2 = content.find('">') url = content[9:idx2] o = urlparse(url) list_query_value = o.query.split(';') if list_query_value != []: for query_value in list_query_value: if query_value.startswith('center='): geodata = query_value.lstrip('center=').rstrip( '&') dic_my_activity_maps[ 'latitude'] = geodata.split(',')[0] dic_my_activity_maps[ 'longitude'] = geodata.split(',')[1] elif query_value.startswith('query='): geodata = query_value.lstrip('query=') dic_my_activity_maps[ 'latitude'] = geodata.split(',')[0] dic_my_activity_maps[ 'longitude'] = geodata.split(',')[1] dic_my_activity_maps['geodata_description'] = content[ idx2 + 2:content.find('</a>')] elif content == '- From your device': dic_my_activity_maps['used_device'] = 'mobile'