C-Command Software Forum

Script to add titles to WWDC videos

I like to store my WWDC videos in EagleFiler so that I can easily search them, add notes, and keep track of which ones I’ve already watched. I download them using the unofficial WWDC app, but it saves filenames like wwdc2020_10687_hd.mp4, which makes it hard to see what each video is. Here’s a quick and dirty script combo to fetch the session names and put them into the record’s title in EagleFiler:

wwdc-title.py

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys, urllib, re
# wwdc2021-10015_hd.mp4
filename = sys.argv[1]
match = re.search("(wwdc\d{4})[-_](.+)_", filename)
# https://developer.apple.com/videos/play/wwdc2021/102/
# https://developer.apple.com/videos/play/wwdc2021/10085/
url = "https://developer.apple.com/videos/play/%s/%s/" % (match.group(1), match.group(2))
data = urllib.urlopen(url).read()
string = unicode(data, "utf-8")
# <title>Apple’s privacy pillars in focus - WWDC 2021 - Videos - Apple Developer</title>
title = re.search(u"<title>(.*?) -", string).group(1)
print title.encode("utf-8")

WWDC Title.applescript

tell application "EagleFiler"
    set _records to selected records of browser window 1
    repeat with _record in _records
        set _record's title to my titleFromFilename(_record's filename)
    end repeat
end tell

on titleFromFilename(_filename)
    return do shell script "/path/to/wwdc-title.py " & _filename's quoted form
end titleFromFilename
2 Likes