Search This Blog

Saturday, 10 February 2024

Aggregated a lot of files on a sunday

Route One - automation for bulletins

Pretty endpoint page (minimalism)

After discovering the ease of the command line YouTube downloaders, i set out to create a very quick aggregator for football content which would automatically get audio files ready for Monday mornings Route One Podcast.

Note: this project is in no way endorsed or used by anyone other than me.

First we get the channel file, listing the channels we want to draw from:

with open("channels.json", "r") as f: channels = json.loads(f.read())

Then, for each channel, we download the metadata of the last 80 videos:
for channel in channels:

id = channel["url"]
os.system(f"./yt-dlp -q --progress --skip-download --write-info-json -I 0:80:1 {id} -o 'data/%(id)s'")

Then we gather the data, sorting it and trimming off any irrelevant videos. In this case we measure "relevance" by the metric of comments on the video.

data = []
for f in [file for file in os.listdir("data") if os.path.isfile(f"data/{file}")]:
    with open(f"data/{f}", "r") as raw:
        file = json.loads(raw.read())
    #os.remove(f"data/{f}")
    if "duration" in file.keys():
        video = {
            "id":file["id"],
            "title":clean(file["title"]),
            "description":clean(file["description"]),
            "uploader":file["uploader"],
            "views":file["view_count"],
            "likes":file["like_count"],
            "comments":file["comment_count"] if "comment_count" in file.keys() else 1000
        }
        data.append(video)
# sort and trim the list of videos
data.sort(key=lambda x: x["comments"]) # sets the variable we sort by
data = data[-10:]
# delete the previously gatered audio files
for f in [file for file in os.listdir("audio") if os.path.isfile(f"audio/{file}")]:
    os.remove(f"audio/{f}")

We then download the chosen files and update the website where the audio files are available for myself.

for video in data:
    os.system(f"./yt-dlp -x --audio-format mp3 {video['id']} -o 'audio/%(id)s'")
#write the index file
with open("index.html", "w") as f:
    # get the template file
    with open("template.html", "r") as t:
        template = t.read()
    f.write(template)
    for video in data[::-1]:
        path = f"audio/{video['id']}.mp3"
        f.write(f"""
            <div class="container">
                <audio controls src='{path}'></audio>
                <p class="title"><b>Title:</b> {video['title']}<br><em>@ {video['uploader']}</em></p>
                <p><b>Views:</b> {video['views']}</p>
                <p><b>Likes:</b> {video['likes']}</p>
                <p><b>Comments:</b> {video['comments']}</p>
            </div>
        """)
    f.write("</body></html>")

Monday, 25 December 2023

100GHz

A collection of photos of my 100GHz horn antenna built from riveted aluminium.

Friday, 8 December 2023

Supermax sitcom

Introduction

Fade-in

Black to fade to cheery title sequence into a supermax sitcom world where nothing changes. Such is the life of the evergreen show, The Simpsons, Family Guy, Friends etc etc etc. But where all of NBC's horses and men cant keep Mat LeBlanc lookin' young, the same can't be said for Maggie Simpson (36).

Fifty-thousand years

‎26/‎02/‎2023

Actor is sitting on a stool on a plain, empty stage. Modern aluminum crochet hook in one hand, ball of wool of an arbitrary colour in the other.

Our tools. This is what we had. Pre-history.

A hook,

Actor holds the hook up.

Carved from wood in the gap between two roots, sheltered from the wind not rain. Carved from bone, chipped and snapped from a leg not far enough through its fifty-thousand rotations. Cast from steel only re-heated in the heart of a furnace

Just as it has been moved and twisted by my hands, mux my fifty-thousand year brothers and sisters, my hands mould to it in twin grooves.

Our tools.

Sunday, 3 December 2023

Another Year of Bodies

 Short Film Week [7]

Another Year of Bodies is in my opinion, my best short film. It was submitted twice to the Into Film of the Month festival, coming runner up.

Friday, 1 December 2023

070420

 Short Film Week [5]



The unnamed 070420 was me taking advantage of my, for the first time ever, clean room, containing only a set of draws, bed, glass and telephone.