<jupyter_start><jupyter_text>Demo of pywebcat<jupyter_code>import itertools
import pandas as pd
from pywebcat.utils import WebCAT<jupyter_output><empty_output><jupyter_text>Instantiate WebCAT class<jupyter_code>wc = WebCAT()<jupyter_output><empty_output><jupyter_text>Set the url & view some properties<jupyter_code>wc.generate_url("buxtoncoastalcam", 2019, 11, 13, 1000)
print(f"Generated url: {wc.url}")
print(f"Generated name: {wc.name}")
print(f"Frame width: {wc.width}")
print(f"Frame height: {wc.height}")
print(f"Total frames: {wc.frames}")
print(f"FPS: {wc.fps}")<jupyter_output>Generated url: http://webcat-video.axds.co/buxtoncoastalcam/raw/2019/2019_11/2019_11_13/buxtoncoastalcam.2019-11-13_1000.mp4
Generated name: buxtoncoastalcam_2019_11_13_1000
Frame width: 1280
Frame height: 720
Total frames: 17097
FPS: 28<jupyter_text>View some frames<jupyter_code># view average frame
step = 500 # average of every N frames
a = wc.plot_average_frame(step)<jupyter_output><empty_output><jupyter_text>Download video to local file (optional)<jupyter_code># wc.download_url()<jupyter_output><empty_output><jupyter_text>Save frames of video to .jpg files & write paths to .csv file<jupyter_code>wc.save_frames(delta_t=100, fout_path="./", save_csv=True)
pd.read_csv('buxtoncoastalcam_2019_11_13_1000.csv', index_col=0).head()<jupyter_output><empty_output><jupyter_text>LoopingThe `WebCAT()` class is constructed such that you can pass new urls without having to re-instantiate the class (good for looping!). We can do some clever tricks with `itertools` for efficient looping within a module. **However**, if you're interested in looping over videos to extract and save frames, it is recommended to use the CLI, as described in the [README](../README.md).<jupyter_code>station = ["buxtoncoastalcam"]
year = [2018]
month = [11]
day = [13]
times = [1000, 2000]  # multiple times to loop through
for item in itertools.product(station, year, month, day, times):
    wc.generate_url(*item)
    print(f"Generated url: {wc.url}")
    # do more stuff like save frames for each video<jupyter_output>Generated url: http://webcat-video.axds.co/buxtoncoastalcam/raw/2018/2018_11/2018_11_13/buxtoncoastalcam.2018-11-13_1000.mp4
Generated url: http://webcat-video.axds.co/buxtoncoastalcam/raw/2018/2018_11/2018_11_13/buxtoncoastalcam.2018-11-13_2000.mp4
{'fraction_non_alphanumeric': 0.11976047904191617, 'fraction_numerical': 0.07100085543199315, 'mean_word_length': 7.010273972602739, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '90979', 'license': 'MIT', 'n_tokens_mistral': 981, 'n_tokens_neox': 848, 'n_words': 192, 'path': 'notebooks/pywebcat_demo.ipynb', 'repo_name': 'Davidwang11/imported-webcat-project', 'size': '2338'}