Replacing Youtube with Kodi plugin

Posted on Thu 26 May 2022 in Kodi, Youtube

As Google announced Gsuite is no longer free and I moved to GrapheneOs to de-google further, the last frequently used Google application I use is Youtube. For a long time Youtube has support for RSS feeds for channels although they are not publicly visible. I usually watch videos in my living room and use Kodi to play YouTube videos via it's YouTube addon. With Kodi's android app it's easy to cast videos to my TV, but I wanted to get rid of having a YouTube app on my phone.

Having previously written a Kodi addon for FOSDEM videos, writing one which parses RSS feeds and displays YouTube channels was a nice evening project. The only challenge was figuring out how to play YouTube videos listed via my addon with Kodi's YouTube addon. As it turns out Kodi can call other addons with parameters via plugin://plugin.video.youtube/play/?video_id=$id. Having created an addon with hardcoded entries, the next step was exporting my subscriptions:

  1. Go to Google takeout
  2. Select YouTube and YouTube Music for export
  3. Click next step and export the data

The export contains playlists, history, subscriptions and more. The subscriptions are in a csv file which I converted to a JSON object with a simple Python script.

#!/usr/bin/python

import csv
import json

with open('./subscriptions.csv') as fp:
    subscriptions = {}
    for line in csv.reader(fp):
        if not line:
            continue
        if line[0] == 'Channel Id':
       continue
        subscriptions[line[-1]] = line[0]

    json.dump(subscriptions, open('./subscriptions.json', mode='w'), indent=4)

The result is my Youtube RSS addon. I probably won't try to push this to the Kodi Addon Repository, as in my experience the addon then requires further polishing for which I have no time or interest for at the moment.

Note that this addon crashes with a recent Python on Arch Linux due to a bug in Python subinterpeters downgrading to 3.10.0-1 is the current workaround.