Home

Awesome

Kodigcs - Serve video files for Kodi from a Google Cloud Storage bucket

This is kodigcs, a server that supplies an HTTP or HTTPS “web directory source” to Kodi containing files that live in a Google Cloud Storage bucket.

In addition to presenting GCS objects as video files to Kodi, kodigcs also synthesizes matching “.nfo” files for each object, containing metadata such as title, director and actor names, release year, and so on. This data is supplied in a Google Drive spreadsheet.

To use kodigcs, you’ll need:

  1. Video files in a Google Cloud Storage bucket;
  2. “Service account” credentials for accessing the bucket, in the form of a JSON file;
  3. A server host with a public URL on which to run kodigcs;
  4. (Optional) A spreadsheet in Google Drive containing metadata for the objects in your GCS bucket.

Note: be mindful of the costs involved in storing and serving data from Google Cloud Storage.

Note: if you have a server host without a public URL, you might be able to give it one by using ngrok.

For more background about this project, see this Medium article.

Installing kodigcs

Run:

go install github.com/bobg/kodigcs@latest

Running kodigcs in server mode

kodigcs [-creds CREDS] serve -bucket BUCKETNAME [-sheet SHEET_ID] [-listen ADDR] [-cert CERT] [-key KEY] [-username USERNAME] [-password PASSWORD]

Running kodigcs to update a metadata spreadsheet

kodigcs [-creds CREDS] ssupdate -sheet SHEET_ID [-htmldir DIR]

CREDS and SHEET_ID are as described above.

In this mode, kodigcs will inspect each row of the given spreadsheet, looking for values in an IMDbID column. These are the keys that the Internet Movie Database uses for each title. For example, the main info page for The Matrix is https://www.imdb.com/title/tt0133093/, so the IMDb key is tt0133093. (Either value works in the IMDbID column: the full URL or just the IMDb key.)

If a metadata spreadsheet has an IMDbID column, and a row has a value in it, and that same row is missing some other detail, such as release year, directors, actors, etc., then ssupdate will scrape the IMDb for that info and add it to the spreadsheet. Update Feb 2023: the IMDb now prohibits this scraping. As an alternative, you can use your browser to download the HTML for the desired IMDb page into a file named Foo.iso.html (for a row with a filename of Foo.iso) in the directory named by the -htmldir option.

For this to work, the spreadsheet must be writable by the “service account” associated with the supplied credentials.

For more about the metadata spreadsheet see “The metadata spreadsheet” below.

Adding your kodigcs source to Kodi

Under Settings, go to Media, then Videos. Select “Add videos.”

In the “add video source” dialog, select “Browse” to browse for video sources.

In the “Browse for new share” dialog, select “Add network location.”

In the “Add network location” dialog, use the following settings:

After confirming this dialog, you’ll be back in the “Browse for new share” dialog. Select the newly added source and confirm this dialog. That will return you to the “add video source” dialog, where you must now give this new source a name.

The metadata spreadsheet

You may specify metadata for the files in your GCS bucket in a Google Drive spreadsheet.

Row 1 of the spreadsheet must have column headings. One of these must be Filename. Each value in this column is the name of an object in your GCS bucket.

Remaining columns may have these headings:

You must make your spreadsheet readable to at least the “service account” whose credentials kodigcs is using (with -creds). You must specify the ID of the spreadsheet to kodigcs with -sheet. The ID is the portion of the URL after docs.google.com/spreadsheets/d/ and before the next /.