<jupyter_start><jupyter_text>Generate a CSV for the timer deception analysis<jupyter_code>import binascii
from urlparse import urlparse

def get_dirname_from_url(url):
    hostname = urlparse(url).hostname
    checksum = hex(binascii.crc32(url)).split('x')[-1]
    return "%s_%s" % (hostname, checksum)

ROOT_TIMER_URL = "https://darkpatterns.cs.princeton.edu"
page_and_timer_urls = []
for l in open("../../data/monitoring/urls/timers.csv"):
    page_url = l.rstrip()
    dir_name_w_checksum = get_dirname_from_url(page_url)
    timer_url_1 = "%s/%s_timer_run_1.mp4" % (ROOT_TIMER_URL, dir_name_w_checksum)
    timer_url_2 = "%s/%s_timer_run_2.mp4" % (ROOT_TIMER_URL, dir_name_w_checksum)
    page_and_timer_urls.append((page_url, timer_url_1, timer_url_2))
    
with open("timer_slideshow_urls.csv", "a") as f:
    for page_url, timer_url_1, timer_url_2 in page_and_timer_urls:
        f.write("%s\t%s\t%s\n" % (page_url, timer_url_1, timer_url_2))
    
! head timer*
! rm<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13260219341974078, 'fraction_numerical': 0.014955134596211365, 'mean_word_length': 5.121951219512195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '353060', 'license': 'Apache-2.0', 'n_tokens_mistral': 411, 'n_tokens_neox': 413, 'n_words': 63, 'path': 'analysis/deceptive/Timer-Deception-Analysis.ipynb', 'repo_name': 'BogDAAAMN/dark-patterns', 'size': '1003'}