Finishing URL Grabber V1 - Working On A Fix For Hugos YouTube Autoplay

October - 2020

NOTE: TODO: This page needs updates to work with MDX


[Start: 00:00:00] - Finishing Daily URL Grabber

Spent the first part of the stream finishing up the first version of my Daily URL Grabber. Two pieces of code that were helpful this snippet that sorts a dict by value:

sort_items = sorted(self.object_data.items(), key=lambda x: x[1].lower())
for item in sort_items:

And this method I setup which writes to a file after making any needed directories in its path:

import os
import os.path

def write_file_with_mkdir(*, path, content):
    directory = os.path.dirname(path)
    os.makedirs(directory, exist_ok=True)
    with open(path, "w") as output_file:

    path = "/Users/alans/Desktop/tmp/test/folder/file.txt",
    content = "the quick brown fox"

The last thing to do was to setup the trigger to capture the URLs from my tabs every 5 minutes. I used this launchd script for that:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">

<plist version="1.0">





For the setup, I decided to keep the source file in the same directory as the main script and then use a symbolic link for it in ~/Library/LaunchAgents.

The osascript call inside the python file used a relative path. It took me a bit to figure out that since I was calling the python with launchd I needed to use full paths. Once they were in place, everything worked nicely.

I've got some more work that I'd like to do cleaning and filtering URLs and updating the output template but the first version is in production.

[Time: ] - Setting Hugo YouTube Shortcode To Work With Muted Autoplay

The second

 <div class="youtube_video">
  src="https://{{ $ytHost }}/embed/{{ $id }}{{ with .Get "autoplay" }}{{ if eq . "true" }}?autoplay=1&mute=1{{ end }}{{ end }}" 
  allowfullscreen title="YouTube Video"></iframe>

Links From The Stream