User:Vanderven.se martijn/feed-entries-with-post-type-video

From IndieWeb
Jump to: navigation, search

I follow a lot of streamers on Twitch. My voice can be heard in multiple Mixer streams. I like many channels on YouTube. To support those artists I follow (“subscribe”, etc.) their channels within those silos. But I consume the actual content by subscribing to their Atom feeds (YouTube has some weird mapping for this) in my reader.

In swoops Telia and takes away my internet. Now I move a lot of video content aside in my reader. They sit there, waiting for me to leech off of someone else’s internet to be watched or downloaded.

But why can’t I have my reader sort out all video posts by itself? That would save me time. And maybe I can then also create something that automatically downloads things. So how do I know which posts are video posts? A beautiful use-case for Tantek Çelik’s post type discovery!

If the post has a "video" property with a valid URL,

Then it is a video post.

But how do I detect a video property? I first thought I should create a converter from YouTube (their Atom, API, oEmbed, Schema.org, …) to h-feed. But as far as I could find a video property is always a URL to a video file in microformats. Outsourcing video hosting to specialised silos (almost) always means there is no video file to link to.

The next feed format I looked at (also on the list from post type discovery) is jf2. This offers an interesting example, where the video property can be more descriptive than just the URL:

{
  "type": "entry",
  "video": [
    {
      "content-type": "video/mp4",
      "url": "sample_h264.mov"
    }
  ]
}

By a happy accident Microsub, “a standardized way for clients to consume and interact with feeds”, also builds on jf2! So not only have I found a feed format that (in its current draft iteration) supports video posts, but it can also be served by the server over an interoperable format to readers implementing the draft Microsub specification.

I am now planning to link the video through its embeddable URL, as almost every video silo has one of those. I will then set the content-type to text/html. A reader can use this to know that it should load the video in an iframe instead of video element. Much like how it might learn in the future that certain types cannot be rendered by a browser at all and might skip them completely instead of forcing it into a video element.

Looking closely at what data can be scraped from a YouTube video post permalink, I discovered the people at Google had exactly the same idea! They leverage the Open Graph protocol’s structured properties by setting the following meta elements:

<meta property="og:type" content="video">
<meta property="og:video:url" content="https://www.youtube.com/embed/ZTIwTVPo-sU">
<meta property="og:video:secure_url" content="https://www.youtube.com/embed/ZTIwTVPo-sU">
<meta property="og:video:type" content="text/html">

So now I am teaching XRay to extract jf2 compatible entries from YouTube URLs. I am hoping for an output akin to the following:

{
  "type": "entry",
  "name": "What is the IndieWeb - Keynote - IndieWeb Summit 2017",
  "url": "https://www.youtube.com/watch?v=UAfjDXc1U0w",
  "author": {
    "type": "card",
    "name": "IndieWebCamp",
    "photo": "https://yt3.ggpht.com/-V4bGNJhcSlc/AAAAAAAAAAI/AAAAAAAAAAA/ObnfgHTttqI/s288-c-k-no-mo-rj-c0xffffff/photo.jpg",
    "url": "https://www.youtube.com/channel/UCco4TTt7ikz9xnB35HrD5gQ"
  },
  "video": [
    {
      "content-type": "text/html",
      "url": "https://www.youtube.com/embed/UAfjDXc1U0w"
    }
  ],
  "photo": [
    "https://i.ytimg.com/vi/UAfjDXc1U0w/maxresdefault.jpg"
  ],
}

Wish me luck~

External links

  1. 2017-07-08 Peter Molnar: Bookmarks, favs, likes - backfilling years of gaps (archived)
  2. 2017-07-16 Martijn van der Ven: What is with my internet connection? (archived)
  3. 2017-08-01 Tantek Çelik: Post Type Discovery (archived)
  4. 2017-10-26 Ben Roberts, Kevin Marks: JF2 Post Serialization Format (archived)
  5. 2017-07-27 Facebook and contributors: The Open Graph protocol (archived)

Other formats