Plex Google Drive File Stream

 admin

None of your files are accessible via Google Drive without rclone. The way we are doing this setup is to fully encrypt both the file and file names to keep our data safe and account safe. This means that you will not be able to access your media files directly from Google Drive on the web, for example, but this is how we want it.

What is rclone?

Rclone is a command-line program to manage files on cloud storage. It is a feature-rich alternative to cloud vendors’ web storage interfaces. Over 40 cloud storage products support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.

Users call rclone “The Swiss army knife of cloud storage”, and “Technology indistinguishable from magic”.

  • Plex is like mission control for your content. With our easy-to-install Plex Media Server software and Plex apps on the devices of your choosing, you can stream your video, music, and photo collections any time, anywhere, to whatever you want. Quick Start Video.
  • Google offers unlimited Drive space in its GSuite Business service. In some regions it outright says unlimited, but in most regions the description states “or 1TB per user if fewer than 5 users”, however, it’s a well-known industry secret that Google has never enforced that restriction and probably won’t do that in the near future.
  • The reason for this is when you connect to Google Drive your data will use double bandwidth for the pull from Google Drive and the push to the client, passing through the PLEX Server as a proxy. NOTE: As of July I have since dropped the original provider.

Source: rclone.com

Why use rclone?

Stream

Over time your Plex library can grow to extraordinary sizes, especially if you value a decent quality of your movies and series. The first intuitive solution would be to grab a decently sized storage VPS and mount it’s drive to our Plex server over NFS or perhaps SSHFS. The problem is that storage VPSs usually have a second, if not third-tier networking. With multiple users trying to fetch different movies you might also hit a CPU cap, especially if you encrypt the data stream (SSHFS or NFS over encrypted VPN).

At some point, you might hit the magic barrier of 10€/mo for storage at which point a storage server is no longer cost-effective, as unlimited space can be achieved under the threshold of 10€.

Google to the rescue!

Google offers unlimited Drive space in its GSuite Business service. In some regions it outright says unlimited, but in most regions the description states “or 1TB per user if fewer than 5 users”, however, it’s a well-known industry secret that Google has never enforced that restriction and probably won’t do that in the near future. If you are still unsure about your data safety - Google always downgrades (be it student plan or paid plan) accounts in a non-destructive fashion. You still have the access to all your files, you just can’t upload any more.

Rclone instalaltion

Rclone provides a one-line installation script:

You can also go to rclone.org/downloads if you want to go the more traditional way and install the package manually.

Rclone configuration

Optional, but recommended

The best practice is to obtain our own Google Drive API key as rclone’s default key is shared among its users. There is a global rate limit on the number of queries per second that each key can do set by Google. Rclone has a high quota and is working with Google to keep it high enough, however, we are power users here, aren’t we?

  1. Log into the Google API Console (the account doesn’t matter).
  2. Select a project or create a new one.
  3. Click ENABLE APIS AND SERVICES on the top, search for Drive and enable Google Drive API
  4. Now go to Credentials on your left-side panel
  5. Proceed to create an OAuth Client ID by pressing CREATE CREDENTIALS on top.
  6. If you haven’t previously created a consent screen go ahead and configure it now (choose external, you do not have to audit it). All you have to set is the name. After creating the consent screen try to create the OAuth credentials.
  7. For the Application Type choose TVs and Limited Input devices and enter any name you desire.
  8. Keep the Client ID and Secret around (you can always access it by pressing the pen icon next to the credential).

Plex Google Drive 2020

Creating the first remote in rclone

Start by executing rclone config:

Enter n for new remote and give it a name (make it memorable)

After entering the name you will be presented with a list of all available remote types, we are interested in drive

Now it’s time to enter your client ID and secret.

Now choose a scope:

If you want to restrict rclone to a specific folder inside your drive you can enter root_fodler_id in the next step. You can get the folder ID from URL when accessing Drive in the browser. For example from https://drive.google.com/drive/u/1/folders/1xDLZTo0x1kOJLXke9mUqe3l8EiUXXXXX, we obtain 1xDLZTo0x1kOJLXke9mUqe3l8EiUXXXXX. This also works with folders inside team drives.

For the sake of later convenience, I suggest creating a folder if you haven’t done it previously.

Next, you will be asked for Service Account Credentials. These are useful for using rclone in unattended mode (i.e. not tied to a specific end-user Google account); …or when you want to bypass the 750GB daily upload limit. However service accounts are beyond the scope of this tutorial, so we leave the field empty.

…also, we are not interested in advanced config so skip that part too.

In the next step, we have to give rclone permission to use our Google Drive. If you are on a desktop machine enter y; if you are on a remote or headless machine enter n.

Depending on what have you chosen, either a browser will open and rclone will obtain the code automagically or you will be given a link to Google’s OAuth page - after you grant the access you will be given verification code, paste it in the console.

Now rclone will ask if you want to use your main drive or a team drive. The decision is up to you.

The last step is to confirm if our configuration is OK

…and we are done! We can technically now mount the drive, but since we are going to use the drive for storing movies for Plex let’s proceed with some tweaks.

Cache & Crypt

Since you are now familiar with the rclone configurator there is no need to go through it for another two remotes. We will edit the rclone.conf straight away to save some time. You should have no problems understanding the syntax.

Plex Google Drive File Stream

Do not loose : after parent remote!

~/.config/rclone/rclone.conf

The only param we are now missing is obviously the encryption password and salt.

DO NOT SKIP THIS PART

Uninstall google drive file stream

To add the encryption password and salt we once again execute rclone config and we edit the crypt remote:

Mounting the Drive

Plex Stream For Free

Manual

To check if our configuration is working we can execute rclone mount and try to access the mount in another terminal/SSH session. As with any mount, make the directory earlier. The following arguments for rclone are best suited for Plex and come from my own trial and error.

On startup via systemd

Uninstall Google Drive File Stream

If our configuration is working we can proceed and make a simple service. Remember about the --config - point it to your config.

/etc/systemd/system/GDriveMrPsycho.service

That’s it!

Plex Google Drive File Stream Desktop

You can now head to Plex and add your mount.

Plex stream movies

Plex Stream Movies

If you want to use the same mount on another machine and have your file decrypted all you have to do is to copy the password and password2 from rclone.conf to the new machine.