Jump to content

Emby on VPS server pulling movies from Google Drive


Recommended Posts

Posted

Does anyone know how to pull movies from google drive with emby server on a vps?

Posted

HI, perhaps rclone?

Posted (edited)
8 hours ago, Joazier said:

Does anyone know how to pull movies from google drive with emby server on a vps?

Yep

The below is what i do on Debian you will need to get your Client Api /secret Key as per the rclone guide first as using the shared key is not advised, this takes a few minutes

 

API Keys

Visit - Google Console from the Account that has access to the drive you want to mount, the below is an excerpt from Rclone Rclone GDrive


Log into the Google API Console with your Google account. It doesn't matter what Google account you use. (It need not be the same account as the Google Drive you want to access)

Select a project or create a new project.

Under "ENABLE APIS AND SERVICES" search for "Drive", and enable the "Google Drive API".

Click "Credentials" in the left-side panel (not "Create credentials", which opens the wizard), then "Create credentials"

If you already configured an "Oauth Consent Screen", then skip to the next step; if not, click on "CONFIGURE CONSENT SCREEN" button (near the top right corner of the right panel), then select "External" and click on "CREATE"; on the next screen, enter an "Application name" ("rclone" is OK) then click on "Save" (all other data is optional). Click again on "Credentials" on the left panel to go back to the "Credentials" screen.

(PS: if you are a GSuite user, you could also select "Internal" instead of "External" above, but this has not been tested/documented so far).

Click on the "+ CREATE CREDENTIALS" button at the top of the screen, then select "OAuth client ID".

Choose an application type of "Desktop app" and click "Create". (the default name is fine)

It will show you a client ID and client secret. Make a note of these.

Go to "Oauth consent screen" and press "Publish App"

Provide the noted client ID and client secret to rclone.

Click "OAuth consent screen", then click "PUBLISH APP" button and confirm, or add your account under "Test users".

Be aware that, due to the "enhanced security" recently introduced by Google, you are theoretically expected to "submit your app for verification" and then wait a few weeks(!) for their response; in practice, you can go right ahead and use the client ID and client secret with rclone, the only issue will be a very scary confirmation screen shown when you connect via your browser for rclone to be able to get its token-id (but as this only happens during the remote configuration, it's not such a big deal).

 

POINTS TO NOTE

If you are most likely only going to be able to SET app type to external as it will not pass googles checks to make it an authorised app (you have to submite ownership urls etc etc). This places it in testing mode (fully working), with this comes one issue the token expires once a week, so you will need to refresh the token every 7 days (takes a few secs).

 

When you get to the setup Screen for scopes make sure you authorise as a minimum the following:

Scopes

 

Once you have written down your client App ID and Secret you can move on to the next stage

 

Install Rclone

curl https://rclone.org/install.sh | sudo bash

Now let's setup your first Mount

rclone config
  • Then type N for new mount, and enter a name for this mount to identify it (no spaces)
  • A list will be displayed make sure you pick Google Drive which is currently option 16 on my setup

807364361_Screenshot2022-03-16at09_56_38.jpg.b5cdbf2b3b7c52506b2fd62291c8aa23.jpg

  • Now enter your client application ID
  • Now enter your Client Secret
  • Give Full Access to the drive

178120116_Screenshot2022-03-16at09_59_36.jpg.a961317ea7c3732889614034e89a8439.jpg

  • Root Folder ID - Leave blank do not type anything click enter
  • SA Account file - Leave blank do not type anything click enter
  • Edit Advanced -  Type   press enter

The next question depends on your setup, you mention VPS so i presume that has no desktop UI and is server install so answer as follows

  • Use Autoconfig - Type Y if your machine you are running rclone on has access to a browser
  • Use Autoconfig - Type N if your machine does not have a browser i.e a server os remote
Quote

It should be noted that Google is stopping the use shortly of Rclone Connect using the second option, this obviously poses a problem for remote servers, however the workaround for this is quite simple. Youy will setup Rclone on your local machine i.e Windows or OSX and you can copy of the Rclone COnfig file from the server to your local machine. That way you can rclone authorize rather than connect as you have a local browser. All you then do is copy the token issued there into your rclone file on your server, and this is actually a faster process

Anyways I presume you have no Browser and are running remote so:

  • Click N
  • A Https link will show which you need to copy and paste into your browser
  • You will be shown the Oauth screen for the app you created at the beginning of this guide, you will need to login with the user you set as test user in the first part of the guide (security precaution), then
  • You will see several screens asking you to confirm you are happy to proceed, do this until you get to the Token screen
  • Copy the token provided and go back to your ssh session
  • Paste the key and press enter
  • Confirm you are happy to create by typing Y

You should now see your Rclone mount listed so time to mount it:

 

SYSTEMD Mount

So create a mount point where you want the drive mounted, you never mentioned if you are running base os version of emby or in docker, so adjust the following

mkdir /mount/MyMountFolderName

In this example i am creating the mount in folder mount and creating a folder called MyMountFolderName, you can change this to wherever you want it

Also for this we are going to create a cpl of extra items up front as this reduces the chance of Error 1 messages when starting the service

mkdir /rclonelogs
touch /rclonelogs/rclone_vfs_mount.log
mkdir /vfscache
mkdir /vfscache/gdrive

So now time to create the service file (location below based on debian file pathcs):

cd /etc/systemd/system

Then (name this whatever you want):

nano rclone-gdrive-mount.service

The below should be copied in and adjusted to your paths, the below is a perfect working solution for Emby and the other media server that shall not be named

[Unit]
Description=RClone Gdrive  Service
Wants=network-online.target
After=network-online.target

[Service]
Type=notify

ExecStart=/bin/rclone mount YOURRCLONENAMEHERE: /mount/MyMountFolderName \
  --config /root/.config/rclone/rclone.conf \
  --cache-dir=/vfscache/gdrive \
  --vfs-cache-max-size 80G \
  --poll-interval 15s \
  --log-level INFO \
  --dir-cache-time 5000h \
  --vfs-cache-mode writes \
  --vfs-read-chunk-size 128M \
  --vfs-cache-max-age 3h \
  --vfs-cache-poll-interval 5m \
  --allow-other \
  --bwlimit 110M \
  --no-checksum \
  --no-modtime \
  --drive-pacer-min-sleep 10ms

StandardOutput=file:/rclonelogs/rclone_vfs_mount.log
ExecStop=/bin/fusermount -uz /mount/MyMountFolderName
Restart=on-failure

[Install]
WantedBy=default.target

Points to note

  • Your clone Name should be replaced with what you named your Rclone mount earlier
    • If you only want to mount a single folder from your gdrive you can enter as follows YOURCLONENAMEHERE:/myonlyfoldername 
  • Path to your created mount folder should be just that the path to the folder you want the gdrive mounted to, make sure you also set this path in the mount point section on the line starting EXECSTop.
  • If you have good hard drive space set up vfs cache  as above
  • Se the Max Size of vfs cache to whatever you have available (leaving space of course)
  • bwlimit this is the max network bandwidth you want to use in my example its 110M or 880mbps, adjust this to lower than what you have available or remove all together if you do not need to limit
ctrl o
ctrl x

Now you have saved an exited so time to start the service

systemctl start rclone-gdrive-mount.service

Now if all has gone well then you should get no error so check if its running

systemctl status rclone-gdrive-mount.service

If it states it's running then all is good so lets enable this mount at boot

systemctl enable rclone-gdrive-mount.service

Your Gdrive should be mounted in the folder you specified now you just need to make it available in Emby but as mentioned you ddidnt mention if it was docker or base install if docker its easy just to map the folder in the compose file.

If you get an ERROR 1 when trying to start the service you will need to re-check the names and paths in the file again as most likely there is an error in how you have typed it. This is why we also created the mount and cache folders and log files earlier, to reduce that as being an issue.

Also not knowing what OS you are using there is a possibility fuse(ermount) may not be installed (debian based normally has this even in minimal install) so that may need to be checked also

If you do have to change the file you will be informed to reload the systemctl daemon, so do this before trying to re start

Edited by CassTG
  • Like 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...